-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAppController.h
More file actions
54 lines (42 loc) · 1.03 KB
/
AppController.h
File metadata and controls
54 lines (42 loc) · 1.03 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
#pragma once
#include "MenuScreen.h"
#include "Screen.h"
#define WINDOW_TITLE "Tetris"
#define WINDOW_WIDTH_PX 640
#define WINDOW_HEIGHT_PX 480
#define ANIMATION_INTERVAL 50 // 50 ms
#define DEMO_INTERVAL 20*1000 // 20 sec
class AppController {
public:
AppController();
~AppController();
int start();
private:
void handleEvent(SDL_Event& e);
void onKeyPressMenu(SDL_KeyboardEvent& keyEvent);
void onKeyPressGame(SDL_KeyboardEvent& keyEvent);
void pause();
void startNewGame();
void onTimer();
void gameOver();
enum {
STATE_INCEPTION,
STATE_DEMO,
STATE_GAME,
STATE_PAUSE
};
Uint32 m_tickInterval;
Uint32 m_lastTick;
Uint32 m_lastAnimationTick;
Uint32 m_lastDemoWaitingTick;
Uint32 m_lastDemoTick;
int m_state;
bool m_quit;
int m_score;
Singer m_singer;
SDL_Window *m_window;
SDL_Renderer *m_renderer;
Painter *m_painter;
Screen *m_screen;
MenuScreen *m_menuScreen;
};