2 Copyright (C) 2004-2011 Parallel Realities
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 See the GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
38 hasAquaLung = hasJetPack = continueFromCheckPoint = false;
39 score = stagesCleared = 0;
40 totalHours = totalMinutes = totalSeconds = 0;
41 currentMissionHours = currentMissionMinutes = currentMissionSeconds = 0;
42 totalEnemiesDefeated = totalItemsCollected = totalBonusesCollected = 0;
43 totalObjectivesCompleted = totalMIAsRescued = 0;
44 currentMissionEnemiesDefeated = currentMissionItemsCollected = 0;
48 currentComboHits = maxComboHits = 0;
54 for (int i = 0 ; i < 5 ; i++)
56 bulletsHit[i] = bulletsFired[i] = 0;
59 strlcpy(mapName, "data/grasslands1", sizeof mapName);
60 strlcpy(stageName, "Grasslands", sizeof stageName);
74 void Game::incrementMissionTime()
76 currentMissionSeconds++;
77 if (currentMissionSeconds == 60)
79 currentMissionSeconds = 0;
80 currentMissionMinutes++;
81 if (currentMissionMinutes == 60)
83 currentMissionMinutes = 0;
84 currentMissionHours++;
89 void Game::setObjectiveCheckPoint()
91 objectiveCheckPointX = checkPointX;
92 objectiveCheckPointY = checkPointY;
96 void Game::useObjectiveCheckPoint()
98 checkPointX = objectiveCheckPointX;
99 checkPointY = objectiveCheckPointY;
104 void Game::setCheckPoint(float x, float y)
106 checkPointX = (int)x;
107 checkPointY = (int)y;
110 void Game::getCheckPoint(float *x, float *y) const
118 if (lastComboTime == 0)
119 currentComboHits = 0;
123 if (currentComboHits > maxComboHits)
124 maxComboHits = currentComboHits;
128 Math::limitChar(&maxComboHits, 0, 99);
129 Math::limitChar(¤tComboHits, 0, 99);
132 void Game::incBulletsFired()
134 bulletsFired[currentWeapon]++;
137 void Game::incBulletsHit()
139 bulletsHit[currentWeapon]++;
142 int Game::getWeaponAccuracy(int weapon)
144 if (bulletsHit[weapon])
146 return (int)(((0.0 + bulletsHit[weapon]) / (0.0 + bulletsFired[weapon])) * 100.0);
152 int Game::getTotalBulletsFired() const
154 return bulletsFired[0] + bulletsFired[1] + bulletsFired[2] + bulletsFired[3] + bulletsFired[4];
157 int Game::getTotalAccuracy()
159 int fired = getTotalBulletsFired();
160 int hits = bulletsHit[0] + bulletsHit[1] + bulletsHit[2] + bulletsHit[3] + bulletsHit[4];
164 return (int)(((0.0 + hits) / (0.0 + fired)) * 100.0);
170 int Game::getMostUsedWeapon()
172 unsigned int mostUsed = 0;
173 unsigned int mostFired = 0;
175 for (int i = 0 ; i < 5 ; i++)
177 if (bulletsFired[i] > mostFired)
180 mostFired = bulletsFired[i];
187 void Game::totalUpStats()
189 totalEnemiesDefeated += currentMissionEnemiesDefeated;
190 totalItemsCollected += currentMissionItemsCollected;
192 totalSeconds += currentMissionSeconds;
193 totalMinutes += currentMissionMinutes;
194 totalHours += currentMissionHours;
196 while (totalSeconds > 59)
202 while (totalMinutes > 59)
208 currentMissionEnemiesDefeated = currentMissionItemsCollected = 0;
209 currentMissionSeconds = currentMissionMinutes = currentMissionHours = 0;
212 void Game::setStageName(const char *name)
214 strlcpy(stageName, name, sizeof stageName);
217 void Game::setMapName(const char *name)
219 strlcpy(mapName, name, sizeof mapName);
222 void Game::setMissionOver(int reason)
224 if ((missionOver == 0) || (reason == MIS_TIMEUP))
229 missionOver = MAX_FPS;
232 missionOver = (int)(MAX_FPS * 2.5);
236 missionOver = MAX_FPS * 5;
238 case MIS_PLAYERESCAPE:
239 missionOver = MAX_FPS * 2;
241 case MIS_GAMECOMPLETE:
242 missionOver = MAX_FPS * 8;
245 missionOver = MAX_FPS;
250 missionOverReason = reason;
253 void Game::resetMissionOver()
255 missionOver = missionOverReason = 0;