-
Notifications
You must be signed in to change notification settings - Fork 0
/
Game.h
87 lines (63 loc) · 1.4 KB
/
Game.h
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
//
// Game.h
// SDL Game Programming Book
//
//
#ifndef __SDL_Game_Programming_Book__Game__
#define __SDL_Game_Programming_Book__Game__
#include "SDL.h"
#include <utils/Vector2D.h>
#include <vector>
#include <atomic>
#include <memory>
class Match;
class PlayState;
class Game
{
public:
static Game* Instance()
{
if(s_pInstance == 0)
{
s_pInstance = new Game();
return s_pInstance;
}
return s_pInstance;
}
/**
* @brief init
* @param title
* @param xpos
* @param ypos
* @param width
* @param height
* @param fullscreen
* @param FPS
* @return
*/
bool init(const char* title, int xpos, int ypos, int width, int height, bool fullscreen, int FPS);
void render();
void update();
void handleEvents();
void clean();
SDL_Renderer* getRenderer() const { return m_pRenderer; }
SDL_Window* getWindow() const { return m_pWindow; }
bool running() { return m_bRunning; }
void quit() { m_bRunning = false; }
int getFPS() const { return m_FPS; }
Match& getMatch();
private:
std::unique_ptr<Match> m_match;
SDL_Window* m_pWindow;
SDL_Renderer* m_pRenderer;
std::unique_ptr<PlayState> m_playState;
bool m_bRunning;
static Game* s_pInstance;
int m_FPS;
Game();
~Game();
Game(const Game&);
Game& operator=(const Game&);
};
typedef Game TheGame;
#endif /* defined(__SDL_Game_Programming_Book__Game__) */