-
Notifications
You must be signed in to change notification settings - Fork 0
/
Game.h
88 lines (67 loc) · 1.52 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
76
77
78
79
80
81
82
83
84
85
86
87
88
#pragma once
#include "Map.h"
#include "SDLSample.h"
enum Event {
QUIT,
NO_EVENT,
MOVE_UP,
MOVE_LEFT,
MOVE_RIGHT,
MOVE_DOWN,
NEW_GAME,
NEXT_MAP
};
//class containing all game methods and info
class Game {
public:
Game();
~Game();
//initializes the interface
bool initialize();
//initializes SDL and graphics parameters
bool initSDL();
bool initRenderer();
SDL_Surface* loadBMP(char* path);
bool loadSurface(SDL_Surface** surface, char* path);
bool loadTextures();
void mapColors();
void initTime();
void freeSpace();
void update();
void render();
void handleEvents();
void cleanSDL();
void drawMenu();
void drawVictoryMenu();
//whole game loop
void gameLoop();
void setQuit(const bool value);
//creates the map on screen and in memory
void createMap();
void allocMap();
Map* getMap();
SDL_Surface* getScreen();
private:
const int MAP_COUNT = 14;
int currentMapID;
//used for window and renderer setup
int rc;
// t1 - starting time, t2 - current time (all in miliseconds)
int t1, t2;
// delta - t2-t1 in seconds
// worldTime - time since program started (seconds)
double delta, worldTime;
bool victory = false;
//used for quitting the game
bool quit;
//used for handling colours
int black, green, red, blue;
int coolBlue;
//used for storing text used in menu
char text[128];
SDL_Surface *screen, *charset;
SDL_Texture *scrtex;
SDL_Window *window;
SDL_Renderer *renderer;
Map* gameMap_;
};