-
Notifications
You must be signed in to change notification settings - Fork 0
/
BaseEventHandler.cpp
59 lines (51 loc) · 973 Bytes
/
BaseEventHandler.cpp
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
#include "BaseEventHandler.h"
void BaseEventHandler::Handle()
{
SDL_Event event;
MousePos mousePos;
while (SDL_PollEvent(&event))
{
switch (event.type)
{
case SDL_QUIT:
exit(0);
break;
case SDL_MOUSEBUTTONDOWN:
MouseStatus = true;
SDL_GetMouseState(&mousePos.x, &mousePos.y);
MouseDownCheck(mousePos);
break;
case SDL_MOUSEBUTTONUP:
MouseStatus = false;
SDL_GetMouseState(&mousePos.x, &mousePos.y);
MouseUpCheck(mousePos);
break;
}
}
RunProcess();
};
void BaseEventHandler::MouseDownCheck(MousePos mousePos)
{
for (Interactable* inter : checkList)
{
inter->MouseDown(mousePos);
}
}
void BaseEventHandler::MouseUpCheck(MousePos mousePos)
{
for (Interactable* inter : checkList)
{
inter->MouseUp(mousePos);
}
}
void BaseEventHandler::RunProcess()
{
for (Interactable* inter : checkList)
{
inter->Process();
}
}
void BaseEventHandler::AddInteractable(Interactable* toAdd)
{
checkList.push_front(toAdd);
}