-
Notifications
You must be signed in to change notification settings - Fork 1
/
Game.h
69 lines (53 loc) · 1.62 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
#ifndef GAME_H
#define GAME_H
#include <vector>
#include <string>
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include <iostream>
#include "TextureManager.h"
#include "GameObject.h"
#include "Enemy.h"
#include "Player.h"
#include "GameStateMachine.h"
#include "MenuState.h"
#include "PlayState.h"
using namespace std;
class Game //SINGLETON
{
public:
//SINGLETON creation
static Game* Instance()
{
if(s_pInstance == 0)
{
s_pInstance = new Game();
return s_pInstance;
}
return s_pInstance;
}
SDL_Renderer* getRenderer() const {return m_pRenderer;}
//Constructors
~Game();
//Game methods
bool init(char* title, int xpos, int ypos, int width, int height, Uint32 flags); //conjunt de coses que configurar al iniciar el programa
void render(); //conjunt de coses que fan veure en pantalla
void update();//actualitzacions bufferianes
void handleEvents();//tractament de evenets (inputs)
void clean();//delete
void quit();//calls clean
//GETs
bool running() const;
GameStateMachine* getStateMachine();
private:
//SINGLETON transformation
Game();
static Game* s_pInstance;
//Atributs
bool m_running; //Atribut per mirar si continua el loop del joc.
SDL_Window* m_pWindow; //Window del joc.
SDL_Renderer* m_pRenderer; //Renderer del joc.
GameStateMachine* m_pGameStateMachine; //ACTUAL GAMESTATEMACHINE
};
typedef Game TheGame;
#endif // GAME_H