-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsingleplayer.h
More file actions
executable file
·107 lines (81 loc) · 2.54 KB
/
singleplayer.h
File metadata and controls
executable file
·107 lines (81 loc) · 2.54 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
99
100
101
102
103
104
105
106
107
#ifndef singleplayer_h
#define singleplayer_h
#include "gamestate.h"
enum type { WALL, TELEPORT, NOM_NOM };
struct Block
{
int x;
int y;
int z;
type tp;
};
class Singleplayer : public GameState
{
private:
//std::vector<SDL_Rect> snk;
std::vector<Block> snk;
//SDL_Rect nom_nom;
Block nom_nom;
std::vector<Block> walls;
std::vector<Block> field;
//std::vector<SDL_Rect> movingObstacles;
char scoreC[100] = "score ";
kiss_label scoreLabel = {0};
kiss_label score_Num = {0};
std::string scoreStr;
SDL_RWops* saveFile;
Block teleportEnter;
Block teleportExit;
//SDL_Rect teleportEnter;
//SDL_Rect teleportExit;
bool teleportFlag;
bool tFlag;
int level;
int score;
int speed;
int direction;
int oldDirection;
SDL_Event event;
int frameStart;
int frameEnd;
int frameDuration;
int width;
int height;
int cellWidth;
int fieldWidth;
std::function<void()> nextStateCallback;
std::function<void()> quitCallback;
//std::function<void()> nextCallback;
std::shared_ptr<SDL_Texture> fruitTexture;
std::shared_ptr<SDL_Texture> nom_nomTexture;
std::shared_ptr<SDL_Texture> teleportTexture;
std::shared_ptr<SDL_Texture> wallTexture;
std::shared_ptr<SDL_Texture> backgroundTexture;
std::shared_ptr<RenderManager> rend;
public:
bool Init(GameEngine* game);
void Update(GameEngine* game);
void HandleEvents(GameEngine* game);
void GenerateNextRound();
void Restart();
SDL_Rect GenerateWallBlock();
SDL_Rect GenerateNom_NomBlock();
SDL_Rect GenerateTeleportBlocks();
bool CheckSelfCollision();
bool UpdateScore();
void setNextStateCallback(std::function<void()> callback)
{nextStateCallback = callback;};
void DrawLabel(std::shared_ptr<RenderManager>& rend, int x, int
y, int z);
void DrawNom_Nom(std::shared_ptr<RenderManager>& rend, int x,
int y, int z);
void DrawWall(std::shared_ptr<RenderManager>& rend, int x, int
y, int z);
void DrawTeleportEnter(std::shared_ptr<RenderManager>& rend, int x, int
y, int z);
void DrawTeleportExit(std::shared_ptr<RenderManager>& rend, int x, int
y, int z);
void DrawBackground(std::shared_ptr<RenderManager>& rend, int x, int y, int w, int h);
void Draw(std::shared_ptr<RenderManager>& rend);
};
#endif