-
Notifications
You must be signed in to change notification settings - Fork 1
/
game.h
65 lines (49 loc) · 1.13 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
#ifndef _GAME_H_
#define _GAME_H_
#include <allegro5/allegro5.h>
#include "resources.h"
#include "level.h"
#include "hud.h"
#include "collisionchecker.h"
#include "ai.h"
enum GameState {
GS_Title,
GS_Playing,
GS_GameOver,
GS_LevelWon,
GS_GameWon
};
/* This class contains the main loop and owns game resources */
class Game
{
public:
static const int SCORE_KILL = 10; // only by shooting, not direct contact
static const int SCORE_FOOD = 50;
static const int SCORE_LEVEL = 500;
static const int WIDTH = 800;
static const int HEIGHT = 600;
static Game *globalGame;
Level* currentLevel;
GameState state;
CollisionChecker* collisionChecker;
int levelCounter;
int score;
int ignoreKeyboardTicks; // ignore keyboard for a number of ticks
void init ();
void mainLoop ();
void shutdown ();
void restart ();
void changeMusic(const char* path);
private:
void update();
void draw();
void drawLevelAndHud();
static const int FPS = 60;
ALLEGRO_DISPLAY * display; // TODO: move to somewhere else
ALLEGRO_TIMER *timer;
Resources* resources; // Game assets from files (images, sounds, ...)
Hud* hud;
AI* ai;
ALLEGRO_EVENT_QUEUE *queue;
};
#endif