-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCAppStateMenu.cpp
68 lines (54 loc) · 1000 Bytes
/
CAppStateMenu.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
60
61
62
63
64
65
66
67
#include "CAppStateMenu.h"
#include "CAppStateManager.h"
#include "CAppStateGame.h"
CAppStateMenu CAppStateMenu::Instance;
CAppStateMenu::CAppStateMenu()
{
Surf_Menu = NULL;
}
void CAppStateMenu::OnActivate()
{
// Load Simple Menu
Surf_Menu = CSurface::OnLoad("menu.png");
start_game = false;
}
void CAppStateMenu::OnKeyDown(SDLKey sym, SDLMod mod, Uint16 unicode)
{
switch(sym)
{
case SDLK_RETURN:
{
start_game = true;
break;
}
default:
{
}
}
}
void CAppStateMenu::OnDeactivate()
{
if(Surf_Menu)
{
SDL_FreeSurface(Surf_Menu);
Surf_Menu = NULL;
}
}
void CAppStateMenu::OnLoop()
{
if(start_game)
{
CAppStateManager::SetActiveAppState(APPSTATE_GAME);
}
}
void CAppStateMenu::OnRender(SDL_Surface* Surf_Display)
{
if(Surf_Menu)
{
CSurface::OnDraw(Surf_Display, Surf_Menu, 0, 0);
}
}
CAppStateMenu* CAppStateMenu::GetInstance()
{
return &Instance;
}