-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathworld.h
More file actions
41 lines (30 loc) · 1.07 KB
/
world.h
File metadata and controls
41 lines (30 loc) · 1.07 KB
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
#ifndef WORLD_H
#define WORLD_H
#include "entity.h"
#include "player.h"
class World{
public:
World();
~World();
void addEntity(Entity *e);
void draw();
void frame();
Player* getPlayer();
/// true if the given rect is intersecting with nothing. The entity 'exeption' is not checked
bool isFree(IntRect const& r, Entity *exeption=nullptr) const;
/// return a list of colliding entities with the given rect
std::vector<Player *> collision(IntRect const& r) const;
/// applies the callback to every entity in the given rect. return nb of true the callback returned
int areaEffect(IntRect const& r, EntityCallback callback);
int areaEffect(IntRect const& r, EntityGenericCallback callback, const void *data);
Entity **firstEntity() {return entities;}
Entity **lastEntity() {return entities + nbEntities;}
private:
static const int max_entities = 500;
Entity *entities[max_entities];
int nbEntities = 0;
/// rm the entities flagged 'mustRemove'
void cleanEntities();
Player* player;
};
#endif // WORLD_H