-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameManager.h
More file actions
98 lines (75 loc) · 1.53 KB
/
GameManager.h
File metadata and controls
98 lines (75 loc) · 1.53 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
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
88
89
90
91
92
93
94
95
96
97
98
#include <SDL.h>
#include <SDL_image.h>
#include <SDL_ttf.h>
#include <SDL_mixer.h>
#include <windows.h>
#include"MenuScene.h"
#include"MainGame.h"
using namespace std;
const int screen_width = SCREEN_WIDTH;
const int screen_height = SCREEN_HEIGHT;
struct windowDeleter
{
void operator()(SDL_Window* window)
{
SDL_DestroyWindow(window);
}
};
struct rendererDeleter
{
void operator()(SDL_Renderer* renderer)
{
SDL_DestroyRenderer(renderer);
}
};
class GameManager
{
private:
static GameManager* instance;
int fps;
bool quiet;
GameManager();
~GameManager();
SDL_Window* gWindow;
SDL_Renderer* gRenderer;
vector<TTF_Font*> fontManager;
TTF_Font* smallFont;
TTF_Font* normalFont;
TTF_Font* titleFont;
std::vector<SDL_Surface*> images;
std::vector<Mix_Chunk*> musics;
bool init();
bool loadMedia();
float limitFrame;
float deltaTime;
LARGE_INTEGER freq;
LARGE_INTEGER start;
LARGE_INTEGER end;
void clockInit();
void clockStart();
void clockEnd();
void clockRestart();
void fpsControl();
void changeScene(int nextSceneNum);
public:
std::unique_ptr<Scene> currentScene;
static GameManager* GetInstance()
{
if (!instance)
{
instance = new GameManager();
}
return instance;
}
SDL_Texture* crashTexture;
void DestroyGameManager();
void LoopGame();
void quietGame() { quiet = true; }
void ClearWindow();
void SwapScreen();
int startSound(SoundNumber num,bool loop);
void stopSound(int channel);
TTF_Font* getFont(FONTS fonts);
SDL_Renderer* getRenderer();
SDL_Texture* getTexture(int index);
};