-
Notifications
You must be signed in to change notification settings - Fork 0
/
game.h
75 lines (55 loc) · 1.31 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
#ifndef GAME_H
#define GAME_H
#include "resourse_manager.h"
#include <stack>
#include <iostream>
#include <fstream>
extern const unsigned WINDOW_WIDTH;
extern const unsigned WINDOW_HEIGHT;
extern const sf::String TITLE;
extern const sf::Time TIME_PER_FRAME;
extern const int HIGHSCORES_CNT;
class GameState;
namespace States {
enum Code {
Menu,
Game,
Scores,
Pause,
EndGame
};
}
struct ScoreRecord {
std::string name;
unsigned scores;
};
class Game {
public:
Game();
~Game();
void run();
void addState(States::Code state);
void popState();
void changeState(States::Code state);
GameState* getState() const;
sf::RenderWindow *getWindow();
ResourseManager& getResourseManager();
void loadHighScores(std::vector<ScoreRecord> &scores) const;
void saveScore();
void setGameScore(unsigned score);
unsigned getPlayerScore() const;
std::string getPlayerName() const;
void changePauseState();
bool getPauseState() const;
void setWinnerStatus(bool is_win);
bool isWin() const;
private:
sf::RenderWindow window;
const sf::Time time_per_frame;
std::stack<GameState*> screens;
ResourseManager resourse_manager;
ScoreRecord player_score;
bool isPaused;
bool isWinner;
};
#endif