-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathEngine.h
125 lines (103 loc) · 2.54 KB
/
Engine.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#pragma once
#include "Player.h"
#include "Level.h"
#include "Food.h"
#include "Records.h"
#include "PointAnimation.h"
#include "Point.h"
#include "Audio.h"
using namespace std;
using namespace sf;
//game statistics
class Staty
{
public:
struct GameStatistics
{
int points = 0;
int lives = 3;
int nrLevel = 1;
int maxLevel = 15;
int toNewLive = 50000;
static const int howmanylevels = 30;
Records tabWithRecords[howmanylevels];
bool ifRecord[howmanylevels];
bool ifGameRecord[3];
bool flagsoundingame = false;
Audio audio2;
};
};
class Engine
{
public:
Engine(RenderWindow &win, Staty::GameStatistics &gameStatistics);
~Engine( );
void runEngine(RenderWindow &window,Staty::GameStatistics &gameStatistics);
enum state2 { MENU_AGAIN, NEXT_LEVEL, LEVEL_AGAIN, NEXT, GAME_OVER, END };
state2 GameState2;
private:
RectangleShape
barsBackground,
powerbar,
underGameOver,
underNewGameRecord;
Text
pointsString,
livesString,
levelString,
tonextlevelString,
powerString,
keycodeString,
endlifeString,
gameover1String,
pauseString,
pictureNextLevel,
fullscreanString,
newRecordString,
newGameRecordString,
newLife;
Font font;
static const int howmanyFood = 5;
int to_new_level;
int how_to_next_level;
int maxLevel;
float powerCapacity;
float state2;
float speed_powerbar;
bool isPause;
bool isEndLife;
bool flagtogameover;
bool flagtogameover2;
bool flagtonextlevel;
int tonextLevelpicture;
int toCountdownPoints;
int levelpoints;
bool isNextLevel;
bool fullScrean;
bool flagtosaverecords;
bool flagrecordpoints;
bool ifgamerecord;
bool flagtoanimationNewLife;
bool flagtocompletelevel;
Player player;
Level level;
Food tabFood[howmanyFood];
PointAnimation pointAnimation;
Texture texture[Level::COUNT];
Sprite sprite[Level::height][Level::width];
Clock clock;
Clock pauseClock;
Clock newLifeClock;
Time pauseElapsedTime;
Time pauseElapsedTimeInAllLevel;
Shader blurEffect;
void check_collision();
void check_collision_withFood(Staty::GameStatistics &gameStatistics);
void update_GUI(Staty::GameStatistics &gameStatistics);
void processEvents(RenderWindow &window, Staty::GameStatistics &gameStatistics);
void render(RenderWindow &window, Staty::GameStatistics &gameStatistics);
float getPowerState(RenderWindow &window, Staty::GameStatistics &gameStatistics);
void writing(int n_levelPoints, int n_setline);
void update_records_file(const string path, string newLine, size_t werse);
string getDate();
};