-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmenus.cpp
More file actions
54 lines (45 loc) · 1.08 KB
/
menus.cpp
File metadata and controls
54 lines (45 loc) · 1.08 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
#include <SDL/SDL_image.h>
#include <assert.h>
#include "menus.h"
namespace dragonfighting {
MainMenu::MainMenu() :
bkImage(NULL),
keyInputer(NULL),
current_key_state(0),
repeatTimer(0)
{
// Background
SDL_Surface *imgloaded = IMG_Load("./kingdragonstitle.png");
bkImage = SDL_DisplayFormat(imgloaded);
SDL_FreeSurface(imgloaded);
}
MainMenu::~MainMenu()
{
SDL_FreeSurface(bkImage);
}
void MainMenu::update(Uint32 frameStamp)
{
assert(keyInputer != NULL);
struct Ctrl_KeyEvent event;
if (this->keyInputer->readEvent(&event, frameStamp) == 1) {
if (event.type == Ctrl_KEYDOWN) {
current_key_state |= event.key;
} else if (event.type == Ctrl_KEYUP) {
current_key_state &= ~event.key;
}
}
if (repeatTimer == 0) {
} else {
repeatTimer --;
}
}
void MainMenu::draw(SDL_Surface *dst)
{
SDL_Rect screenposition = getPositionScreenCoor();
SDL_BlitSurface(bkImage, NULL, dst, &screenposition);
}
void MainMenu::setInputer(CtrlKeyReader *inputer)
{
this->keyInputer = inputer;
}
}