-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathEventHandler.h
More file actions
64 lines (45 loc) · 1.3 KB
/
Copy pathEventHandler.h
File metadata and controls
64 lines (45 loc) · 1.3 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#ifndef EVENTHANDLER_H
#define EVENTHANDLER_H
#include <SDL2/SDL.h>
#include <set>
#include "ControllerIntf.h"
#include "Vortex.h"
#include "Ships.h"
#include "ShipIntf.h"
class Walls;
class b2World;
class b2Body;
//Interface to receive events from some kind of controller object.
class EventHandler : public ControllerIntf
{
private:
typedef std::set< std::pair<b2Body*, b2Body*> > CollisionSet;
bool m_bQuit;
SDL_Window* m_pWindow;
Uint32 m_controlEvent;
SDL_Event m_templateEvent;
Ships& m_ships;
//Box2D stuff
float32 m_timeStep;
int32 m_velocityIterations;
int32 m_positionIterations;
b2World& m_world;
Walls& m_walls;
void ProcessShips() const;
void ProcessEffects();
uint32 KeyUp(SDL_Scancode scankeycode) const;
uint32 KeyDown(SDL_Scancode scankeycode) const;
//set of all unique collision
CollisionSet m_collisionSet;
public:
EventHandler(SDL_Window *pWindow,b2World& world,Ships& ships, Walls& walls);
//Main Event Loop
void EventLoop();
//Destructor
virtual ~EventHandler();
//Accessor functions to add events to the event handler
virtual void ButtonHome(int controllerIndex);
virtual void ButtonPushed(int controller, int buttons);
void CollisionHappened(b2Body* bodyA, b2Body* b2BodyB);
};
#endif