The Game Engine  1
Level.h
Go to the documentation of this file.
1 #ifndef __LEVEL_H__
2 #define __LEVEL_H__
3 #include "Sprite.h"
4 #include "Background.h"
5 #include "HUD.h"
6 #include "Font.h"
7 #include "Menu.h"
8 #include "ParticleSystem.h"
9 #include "Player.h"
10 #include <vector>
11 #include <map>
12 #include <string>
13 
14 
15 using std::vector;
16 using std::string;
17 
18 class Text;
19 
32 class Level
33 {
34 public:
44  Level(string name, Condition winCond, Behavior loadBehave = NULL,
45  Behavior updateBehave = NULL, Behavior endBehave = NULL, Behavior pBehave = NULL);
46 
47  ~Level();
48 
52  void drawScene();
53 
58  void LoadBG(string name);
59 
63  virtual void postEvent(SDL_Event event);
64 
69  void update();
70 
74  void load();
75 
79  void unload();
80 
85  void addObject(WorldObject* o);
86 
91  void removeObject(WorldObject* o);
92 
97  void removeAllSprites(string name);
98 
104 
110 
115  void removeAllParticleSystems(string name);
116 
121  string getName() { return mName; }
122 
128  delete mBackground;
129  mBackground=b;
130  }
131 
137 
143  Sprite* findSprite(string name);
144 
151  vector<Sprite*> findSprites(string name, int count=-1);
152 
158  ParticleSystem* findParticleSystem(string name);
159 
166  vector<ParticleSystem*> findParticleSystems(string name, int count=-1);
167 
171  bool Loaded;
172 
176  unsigned int getNumPlayers();
177 
181  unsigned int getMaxNumPlayers();
182 
186  void setMaxNumPlayers(unsigned int i);
187 
191  Player* getPlayer(unsigned int index);
192 
198  bool addPlayer(Player* p);
199 
205  bool removePlayer(Player* p);
206 
212  int removePlayers(int count);
213 
214 protected: // allow inheritance
218  void DrawCollisions();
219 
223  void DrawMenus();
224 
228  void clearData();
229 
230  string mName;
234  vector<WorldObject*> mWorldObjects;
236  vector<Sprite*> mSprites;
238  vector<WorldObject*> ToAdd;
240  vector<WorldObject*> ToRemove;
242  vector<ParticleSystem*> mParticleSystems;
245 
256 
258  vector<Menu> mMenus;
259 
261  vector<Player*> mPlayers;
262 
264  unsigned int mMaxNumPlayers;
265 };
266 #endif