-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinit.h
83 lines (64 loc) · 1.61 KB
/
init.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#ifndef INIT
#define INIT
#include <GL/glut.h>
#include "globals.h"
#include <fstream>
using namespace std;
// This temp for testing
void processfile(){
ifstream level_file ("level.txt");
if (level_file.is_open())
{
// read in the floor dimensions (30x30 max)
level_file >> world.x;
level_file >> world.y;
// fill in the wall data
for(int i=0;i<world.x;i++)
for(int j=0;j<world.y;j++)
level_file >> world.walls[i][j];
int box_num;
double x,y;
level_file >> box_num;
for(int i=0; i<box_num; i++)
{
level_file >> x >> y;
world.addBox( box(x, y) );
}
// read in bin coordinates
// should be as many bins as boxes
for(int i=0; i<box_num; i++)
{
level_file >> x >> y;
world.addBin( bin(x,y) );
}
world.syncBinsBoxes();
// Read in toggles
int toggle_num;
level_file >> toggle_num;
for(int i=0; i<toggle_num; i++)
{
level_file >> x >> y;
world.addToggle( toggle(x,y) );
}
// Read in lights -- this number should never exceed 7
int num_lights;
level_file >> num_lights;
for(int i=0; i<num_lights; i++)
{
level_file >> x >> y;
//world.addBox( box(x,y) );
world.addLight( light(i,x,y,3) );
cout << "Light drawn at: " << x << " " << y << endl;
}
int num_spikeTraps;
level_file >> num_spikeTraps;
for(int i=0; i<num_spikeTraps; i++)
{
level_file >> x >> y;
world.addSpikeTrap(spikeTrap(x,y));
}
level_file.close();
}
else cout << "Unable to open level.txt which stores the level information";
}
#endif