-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModuleCollision.h
More file actions
60 lines (46 loc) · 987 Bytes
/
ModuleCollision.h
File metadata and controls
60 lines (46 loc) · 987 Bytes
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
#ifndef __ModuleCollision_H__
#define __ModuleCollision_H__
#include "Module.h"
#include "p2List.h"
enum COLLIDER_TYPE
{
COLLIDER_NONE = -1,
COLLIDER_WALL,
COLLIDER_PLAYER,
COLLIDER_ENEMY,
COLLIDER_PLAYER_SHOT,
COLLIDER_ENEMY_SHOT,
COLLIDER_MAX
};
struct Collider
{
SDL_Rect rect;
bool enabled;
COLLIDER_TYPE type;
Module* callback;
Collider(SDL_Rect rectangle, COLLIDER_TYPE type, Module* callback = NULL) :
rect(rectangle),
type(type),
callback(callback),
enabled(true)
{}
void SetPos(int x, int y)
{
rect.x = x;
rect.y = y;
}
bool CheckCollision(SDL_Rect r) const;
};
class ModuleCollision : public Module
{
public:
ModuleCollision(Application* app, bool start_enabled = true);
~ModuleCollision();
update_status Update();
bool CleanUp();
Collider* AddCollider(SDL_Rect rect, COLLIDER_TYPE type, Module* callback = NULL);
private:
p2List<Collider*> colliders;
bool matrix[COLLIDER_MAX][COLLIDER_MAX];
};
#endif // __ModuleCollision_H__