-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame_mode.cpp
executable file
·114 lines (91 loc) · 1.5 KB
/
game_mode.cpp
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
#include "headers/game_mode.h"
GameMode::GameMode()
{
mWidth = 4;
mHeight = 5;
mCombo = 1;
mBlockScore = 50;
mObjectiveDone = false;
mHasScore = true;
mGoalScore = 20000;
mCurrentScore = 0;
mMaxMoves = 25;
mCurrentMoves = mMaxMoves;
mHasTimer = false;
mMaxTimer = 25;
mCurrentTimer = mMaxTimer;
mDestroyBlocks = false;
}
int GameMode::GetWidth()
{
return mWidth;
}
int GameMode::GetBlockScore()
{
return mBlockScore;
}
float GameMode::GetCombo()
{
return mCombo;
}
void GameMode::ModifyCombo(float _amt)
{
mCombo += _amt;
}
void GameMode::ResetCombo()
{
mCombo = 1;
}
int GameMode::GetHeight()
{
return mHeight;
}
void GameMode::Update(double deltaTime)
{
mCurrentTimer -= deltaTime;
UpdateObjective();
}
void GameMode::UpdateObjective()
{
mObjectiveDone = (mHasScore && (mCurrentScore >= mGoalScore)); /*&&
(mHasTimer && (mCurrentTimer < mMaxTimer))*/
if(mDestroyBlocks)
{
for(std::map<Block::Type,int>::iterator itr = mNumberOfBlocksToDestroy.begin()
; itr != mNumberOfBlocksToDestroy.end(); itr++)
{
if(itr->second > 0)
{
mObjectiveDone &= false;
}
}
}
}
bool GameMode::GameWon()
{
return mObjectiveDone;
}
void GameMode::DecrementMoves()
{
mCurrentMoves--;
}
int GameMode::GetCurrentMoves()
{
return mCurrentMoves;
}
int GameMode::GetMaxMoves()
{
return mMaxMoves;
}
void GameMode::ModifyScore(int _amt)
{
mCurrentScore += _amt;
}
int GameMode::GetCurrentScore()
{
return mCurrentScore;
}
int GameMode::GetCurrentTimer()
{
return mCurrentTimer;
}