-
Notifications
You must be signed in to change notification settings - Fork 0
/
GameWorld.h
95 lines (73 loc) · 1.28 KB
/
GameWorld.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
#ifndef GAMEWORLD_H_
#define GAMEWORLD_H_
#include "GameConstants.h"
#include <string>
const int START_PLAYER_LIVES = 3;
class GameController;
class GameWorld
{
public:
GameWorld(std::string assetPath)
: m_lives(START_PLAYER_LIVES), m_score(0), m_level(1),
m_controller(nullptr), m_assetPath(assetPath)
{
}
virtual ~GameWorld()
{
}
virtual int init() = 0;
virtual int move() = 0;
virtual void cleanUp() = 0;
void setGameStatText(std::string text);
bool getKey(int& value);
void playSound(int soundID);
int getLevel() const
{
return m_level;
}
int getLives() const
{
return m_lives;
}
void decLives()
{
m_lives--;
}
void incLives()
{
m_lives++;
}
int getScore() const
{
return m_score;
}
void increaseScore(int howMuch)
{
m_score += howMuch;
}
// The following should be used by only the framework, not the student
bool isGameOver() const
{
return m_lives == 0;
}
void advanceToNextLevel()
{
++m_level;
}
void setController(GameController* controller)
{
m_controller = controller;
}
std::string assetPath() const
{
return m_assetPath;
}
void setMsPerTick(int ms_per_tick);
private:
int m_lives;
int m_score;
int m_level;
GameController* m_controller;
std::string m_assetPath;
};
#endif // GAMEWORLD_H_