2 Copyright (C) 2004-2011 Parallel Realities
3 Copyright (C) 2011-2015 Perpendicular Dimensions
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 See the GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
39 hasAquaLung = hasJetPack = continueFromCheckPoint = false;
40 score = stagesCleared = 0;
41 totalHours = totalMinutes = totalSeconds = 0;
42 currentMissionHours = currentMissionMinutes = currentMissionSeconds = 0;
43 totalEnemiesDefeated = totalItemsCollected = totalBonusesCollected = 0;
44 totalObjectivesCompleted = totalMIAsRescued = 0;
45 currentMissionEnemiesDefeated = currentMissionItemsCollected = 0;
49 currentComboHits = maxComboHits = 0;
55 for (int i = 0 ; i < 5 ; i++)
57 bulletsHit[i] = bulletsFired[i] = 0;
60 strlcpy(mapName, "data/grasslands1", sizeof mapName);
61 strlcpy(stageName, "Grasslands", sizeof stageName);
75 void Game::incrementMissionTime()
77 currentMissionSeconds++;
78 if (currentMissionSeconds == 60)
80 currentMissionSeconds = 0;
81 currentMissionMinutes++;
82 if (currentMissionMinutes == 60)
84 currentMissionMinutes = 0;
85 currentMissionHours++;
90 void Game::setObjectiveCheckPoint()
92 objectiveCheckPointX = checkPointX;
93 objectiveCheckPointY = checkPointY;
97 void Game::useObjectiveCheckPoint()
99 checkPointX = objectiveCheckPointX;
100 checkPointY = objectiveCheckPointY;
105 void Game::setCheckPoint(float x, float y)
107 checkPointX = (int)x;
108 checkPointY = (int)y;
111 void Game::getCheckPoint(float *x, float *y) const
119 if (lastComboTime == 0)
120 currentComboHits = 0;
124 if (currentComboHits > maxComboHits)
125 maxComboHits = currentComboHits;
129 Math::limitChar(&maxComboHits, 0, 99);
130 Math::limitChar(¤tComboHits, 0, 99);
133 void Game::incBulletsFired()
135 bulletsFired[currentWeapon]++;
138 void Game::incBulletsHit()
140 bulletsHit[currentWeapon]++;
143 int Game::getWeaponAccuracy(int weapon)
145 if (bulletsHit[weapon])
147 return (int)(((0.0 + bulletsHit[weapon]) / (0.0 + bulletsFired[weapon])) * 100.0);
153 int Game::getTotalBulletsFired() const
155 return bulletsFired[0] + bulletsFired[1] + bulletsFired[2] + bulletsFired[3] + bulletsFired[4];
158 int Game::getTotalAccuracy()
160 int fired = getTotalBulletsFired();
161 int hits = bulletsHit[0] + bulletsHit[1] + bulletsHit[2] + bulletsHit[3] + bulletsHit[4];
165 return (int)(((0.0 + hits) / (0.0 + fired)) * 100.0);
171 int Game::getMostUsedWeapon()
173 unsigned int mostUsed = 0;
174 unsigned int mostFired = 0;
176 for (int i = 0 ; i < 5 ; i++)
178 if (bulletsFired[i] > mostFired)
181 mostFired = bulletsFired[i];
188 void Game::totalUpStats()
190 totalEnemiesDefeated += currentMissionEnemiesDefeated;
191 totalItemsCollected += currentMissionItemsCollected;
193 totalSeconds += currentMissionSeconds;
194 totalMinutes += currentMissionMinutes;
195 totalHours += currentMissionHours;
197 while (totalSeconds > 59)
203 while (totalMinutes > 59)
209 currentMissionEnemiesDefeated = currentMissionItemsCollected = 0;
210 currentMissionSeconds = currentMissionMinutes = currentMissionHours = 0;
213 void Game::setStageName(const char *name)
215 strlcpy(stageName, name, sizeof stageName);
218 void Game::setMapName(const char *name)
220 strlcpy(mapName, name, sizeof mapName);
223 void Game::setMissionOver(int reason)
225 if ((missionOver == 0) || (reason == MIS_TIMEUP))
230 missionOver = MAX_FPS;
233 missionOver = (int)(MAX_FPS * 2.5);
237 missionOver = MAX_FPS * 5;
239 case MIS_PLAYERESCAPE:
240 missionOver = MAX_FPS * 2;
242 case MIS_GAMECOMPLETE:
243 missionOver = MAX_FPS * 8;
246 missionOver = MAX_FPS;
251 missionOverReason = reason;
254 void Game::resetMissionOver()
256 missionOver = missionOverReason = 0;