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.
34 if (SDL_GetGamma(&r, &g, &b) != -1) {
35 if (r != g || g != b) {
48 hasAquaLung = hasJetPack = continueFromCheckPoint = false;
49 score = stagesCleared = 0;
50 totalHours = totalMinutes = totalSeconds = 0;
51 currentMissionHours = currentMissionMinutes = currentMissionSeconds = 0;
52 totalEnemiesDefeated = totalItemsCollected = totalBonusesCollected = 0;
53 totalObjectivesCompleted = totalMIAsRescued = 0;
54 currentMissionEnemiesDefeated = currentMissionItemsCollected = 0;
58 currentComboHits = maxComboHits = 0;
64 for (int i = 0 ; i < 5 ; i++)
66 bulletsHit[i] = bulletsFired[i] = 0;
69 strlcpy(mapName, "data/grasslands1", sizeof mapName);
70 strlcpy(stageName, "Grasslands", sizeof stageName);
84 void Game::incrementMissionTime()
86 currentMissionSeconds++;
87 if (currentMissionSeconds == 60)
89 currentMissionSeconds = 0;
90 currentMissionMinutes++;
91 if (currentMissionMinutes == 60)
93 currentMissionMinutes = 0;
94 currentMissionHours++;
99 void Game::setObjectiveCheckPoint()
101 objectiveCheckPointX = checkPointX;
102 objectiveCheckPointY = checkPointY;
106 void Game::useObjectiveCheckPoint()
108 checkPointX = objectiveCheckPointX;
109 checkPointY = objectiveCheckPointY;
114 void Game::setCheckPoint(float x, float y)
116 checkPointX = (int)x;
117 checkPointY = (int)y;
120 void Game::getCheckPoint(float *x, float *y) const
128 if (lastComboTime == 0)
129 currentComboHits = 0;
133 if (currentComboHits > maxComboHits)
134 maxComboHits = currentComboHits;
138 Math::limitChar(&maxComboHits, 0, 99);
139 Math::limitChar(¤tComboHits, 0, 99);
142 void Game::incBulletsFired()
144 bulletsFired[currentWeapon]++;
147 void Game::incBulletsHit()
149 bulletsHit[currentWeapon]++;
152 int Game::getWeaponAccuracy(int weapon)
154 if (bulletsHit[weapon])
156 return (int)(((0.0 + bulletsHit[weapon]) / (0.0 + bulletsFired[weapon])) * 100.0);
162 int Game::getTotalBulletsFired() const
164 return bulletsFired[0] + bulletsFired[1] + bulletsFired[2] + bulletsFired[3] + bulletsFired[4];
167 int Game::getTotalAccuracy()
169 int fired = getTotalBulletsFired();
170 int hits = bulletsHit[0] + bulletsHit[1] + bulletsHit[2] + bulletsHit[3] + bulletsHit[4];
174 return (int)(((0.0 + hits) / (0.0 + fired)) * 100.0);
180 int Game::getMostUsedWeapon()
182 unsigned int mostUsed = 0;
183 unsigned int mostFired = 0;
185 for (int i = 0 ; i < 5 ; i++)
187 if (bulletsFired[i] > mostFired)
190 mostFired = bulletsFired[i];
197 void Game::totalUpStats()
199 totalEnemiesDefeated += currentMissionEnemiesDefeated;
200 totalItemsCollected += currentMissionItemsCollected;
202 totalSeconds += currentMissionSeconds;
203 totalMinutes += currentMissionMinutes;
204 totalHours += currentMissionHours;
206 while (totalSeconds > 59)
212 while (totalMinutes > 59)
218 currentMissionEnemiesDefeated = currentMissionItemsCollected = 0;
219 currentMissionSeconds = currentMissionMinutes = currentMissionHours = 0;
222 void Game::setStageName(const char *name)
224 strlcpy(stageName, name, sizeof stageName);
227 void Game::setMapName(const char *name)
229 strlcpy(mapName, name, sizeof mapName);
232 void Game::setMissionOver(int reason)
234 if ((missionOver == 0) || (reason == MIS_TIMEUP))
239 missionOver = MAX_FPS;
242 missionOver = (int)(MAX_FPS * 2.5);
246 missionOver = MAX_FPS * 5;
248 case MIS_PLAYERESCAPE:
249 missionOver = MAX_FPS * 2;
251 case MIS_GAMECOMPLETE:
252 missionOver = MAX_FPS * 8;
255 missionOver = MAX_FPS;
260 missionOverReason = reason;
263 void Game::resetMissionOver()
265 missionOver = missionOverReason = 0;