1 #ifndef DENGINE_EVENTSYSTEM_H 2 #define DENGINE_EVENTSYSTEM_H 7 #include <unordered_map> 68 eventCallbacks[eventType] = callback;
76 eventCallbacks.erase(eventType);
85 while (SDL_PollEvent(&event)) {
86 if (event.type == SDL_QUIT) {
91 if (eventCallbacks.find(event.type) != eventCallbacks.end()) {
93 eventCallbacks[
event.type](event);
104 #endif //DENGINE_EVENTSYSTEM_H void RegisterEventCallback(Uint32 eventType, EventCallback callback)
Function to register an event callback.
Definition: EventSystem.h:67
A struct containing event data.
Definition: EventSystem.h:17
std::function< void(SDL_Event &)> EventCallback
Definition: EventSystem.h:30
void setGameState(int state)
Set the game state. This can be done with an int or with the GAMESTATES enum.
Definition: GameState.cpp:19
void DeregisterEventCallback(Uint32 eventType)
Function to deregister an event callback.
Definition: EventSystem.h:75
std::map< Uint32, EventCallback > eventCallbacks
Definition: EventSystem.h:31
Event System.
Definition: EventSystem.h:26
void processEvents()
Process events, including custom events.
Definition: EventSystem.h:82
User initiated quit.
Definition: GameStates.h:29
std::string stringValue
Definition: EventSystem.h:20
The namespace containing the engine's code.
Definition: Collider.h:9
static GameState & GetInstance()
Definition: GameState.cpp:23
int intValue
Definition: EventSystem.h:19