-
Notifications
You must be signed in to change notification settings - Fork 0
/
Level.h
165 lines (135 loc) · 3.53 KB
/
Level.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#ifndef _LEVEL_H_
#define _LEVEL_H_
#include <fstream>
#include "StoneBlock.h"
#include "SpikeBlock.h"
#include "Player.h"
#include "Enemy.h"
#include "GoodSmiley.h"
using namespace std;
enum ObjectType{
BLOCK_STONE, BLOCK_SPIKE, SMILEY_CATCH, SMILEY_PLAYER, SMILEY_ENEMY
};
union Object{
SpikeBlock* spikeBlock;
StoneBlock* stoneBlock;
GoodSmiley* goodSmiley;
Enemy* enemy;
Object(){
spikeBlock = NULL;
};
};
struct Symbol{
ObjectType type;
int anzahl;
char symbol;
int texture;
Object object;
};
class Level
{
public:
//standartkonstruktor, no other avialble
Level(void);
//destruktor
~Level(void);
//loads a lvl from a txt file
bool loadLvl(ifstream& lvlFile);
//additonal lvlreading functions
void readTextures(ifstream& in);
void readBackground(ifstream& in);
int getSymbolAnzahl(ifstream& in);
Symbol* readSymbols(ifstream& in, int anzahl);
void readLvl(ifstream& in, Symbol* symbols, int anzahl);
//cleans all objects
void cleanup();
void deleteTextures();
//loads a texture from a file
bool loadTexture(const char* textureFileName, int index);
//gets the background image
GLuint getBackground();
bool isBackgroundEnabled();
//returns the block with index <index>
StoneBlock& getStoneBlock(int index);
//returns how many blocks the lvl contains
int getStoneBlockAnzahl();
//returns the block with index <index>
SpikeBlock& getSpikeBlock(int index);
//returns how many blocks the lvl contains
int getSpikeBlockAnz();
//returns the ball with index <index>
GoodSmiley& getGoodSmiley(int index);
//returns how many smileys the lvl contains
int getGoodSmileyAnzahl(void);
//returns the ball with index <index>
Enemy& getEnemy(int index);
//returns how many smileys the lvl contains
int getEnemyAnzahl(void);
//returns the object with index i of the lvl
Drawable& getObject(int index);
//returns the amount of objects in this lvl
int getObjectAnzahl();
//returns the width of the lvl (in units)
int getWidth();
//returns the height of the lvl (default 100, in units)
int getHeight();
void setWidth(int width);
//returns width of the background image
GLfloat getBackgroundFaktorX();
//Returns height of the background image
GLfloat getBackgroundFaktorY();
bool isBackgroundRepeatedY();
//returns the number of good smileys left in the lvl
int getActiveSmileys(void);
GLfloat getTimePlaying();
void addTimePlaying(GLfloat time);
void setTimePlaying(GLfloat time);
void setPlayerToStart();
Player& getPlayer();
GLfloat getStartX();
GLfloat getStartY();
private:
//lvl width and height in units
int width;
int height;
//background width
GLfloat bg_width;
//bakcground height
GLfloat bg_height;
//background skalierungsfaktor x
GLfloat bg_faktor_x;
//background skalierungsfaktor y
GLfloat bg_faktor_y;
//background repeat modus on/off
bool bg_repeated_y;
//background enable
bool bg_enabled;
//Time since the level was started
GLfloat time_playing;
//stoneblocks which the lvl contains
StoneBlock* stoneBlocks;
//number of stoneblocks it the lvl
int stoneBlocksAnz;
//SpikeBlocks whicht the lvl contains
SpikeBlock* spikeBlocks;
//number of death blocks in the lvl
int spikeBlocksAnz;
//lvl Player Object
Player player;
//player startposition x
GLfloat start_x;
//player startposition y
GLfloat start_y;
//smileys which the lvl contains
GoodSmiley* goodSmileys;
//number of smileys in the lvl
int goodSmileysAnz;
//enmys of the lvl
Enemy* enemys;
//amount of enemys
int enemysAnz;
//textures needed for this lvl
GLuint* texture;
int textureAnz;
};
#endif