2 Copyright (C) 2004 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.
25 game.getCheckPoint(&player.x, &player.y);
30 player.environment = ENV_AIR;
33 addTeleportParticles(player.x + 10, player.y + 10, 50, SND_TELEPORT2);
35 Math::removeBit(&player.flags, ENT_FLIES);
36 Math::removeBit(&player.flags, ENT_TELEPORTING);
37 player.setSprites(graphics.getSprite("BobRight", true), graphics.getSprite("BobLeft", true), graphics.getSprite("BobSpin", true));
40 map.windChangeTime = 90;
46 int amount = (game.gore) ? 25 : 150;
48 for (int i = 0 ; i < amount ; i++)
50 x = player.x + Math::rrand(-3, 3);
51 y = player.y + Math::rrand(-3, 3);
55 dx = Math::rrand(-5, 5);
56 dy = Math::rrand(-15, -5);
57 addEffect(x, y, dx, dy, EFF_BLEEDS);
61 dx = Math::rrand(-5, 5);
62 dy = Math::rrand(-5, 5);
63 addColoredEffect(x, y, dx, dy, graphics.yellow, EFF_COLORED + EFF_WEIGHTLESS);
67 (game.gore) ? audio.playSound(SND_SPLAT, CH_ANY) : audio.playSound(SND_POP, CH_ANY);
70 void checkPlayerBulletCollisions(Entity *bullet)
72 if ((bullet->health < 1) || (player.health <= -60))
77 if ((player.flags & ENT_TELEPORTING) || (game.missionOver > 0))
82 if (bullet->owner != &player)
84 if (Collision::collision(&player, bullet))
86 if ((!player.immune) && (!(bullet->flags & ENT_EXPLODES)))
88 addBlood(&player, bullet->dx / 4, Math::rrand(-6, -3), 1);
89 audio.playSound(SND_HIT, CH_ANY);
90 if (game.missionOverReason == MIS_INPROGRESS)
92 player.health -= bullet->damage;
97 Math::removeBit(&bullet->flags, ENT_SPARKS);
98 Math::removeBit(&bullet->flags, ENT_PUFFS);
100 if (player.health <= 0)
102 player.dx = bullet->dx;
104 audio.playSound(SND_DEATH1 + Math::prand() % 3, CH_DEATH);
108 if (bullet->id == WP_LASER)
110 debug(("Laser Hit Player"));
111 throwAndDamageEntity(&player, 0, -3, 3, -8);
123 if (engine.cheatHealth)
125 player.health = MAX_HEALTH;
128 if (game.missionOverReason == MIS_PLAYERESCAPE)
133 if (player.y > (map.limitDown + 500))
135 if (game.missionOver == 0)
140 if (player.health > 0)
142 game.setMissionOver(MIS_PLAYEROUT);
146 game.setMissionOver(MIS_PLAYERDEAD);
150 if (player.flags & ENT_TELEPORTING)
156 if (game.missionOverReason == MIS_PLAYEROUT)
158 graphics.blit(player.getFaceImage(), (int)(player.x - engine.playerPosX), (int)(player.y - engine.playerPosY), graphics.screen, false);
163 if ((player.health < 1) || (player.immune > 120))
165 if (player.health <= -60)
172 if (game.hasAquaLung)
179 graphics.blit(player.getFaceImage(), (int)(player.x - engine.playerPosX), (int)(player.y - engine.playerPosY), graphics.screen, false);
181 if (player.health < 1)
186 if (player.health <= -60)
194 if ((!(player.flags & ENT_FLIES)) && (!map.isIceLevel))
199 // toggles the Jetpack if available
200 if (config.isControl(CONTROL::JETPACK))
202 if ((game.hasJetPack) || (engine.cheatExtras))
204 if (player.flags & ENT_FLIES)
206 Math::removeBit(&player.flags, ENT_FLIES);
207 player.setSprites(graphics.getSprite("BobRight", true), graphics.getSprite("BobLeft", true), graphics.getSprite("BobSpin", true));
211 if ((player.fuel > 3) && (player.environment == ENV_AIR))
213 Math::addBit(&player.flags, ENT_FLIES);
214 player.setSprites(graphics.getSprite("JPBobRight", true), graphics.getSprite("JPBobLeft", true), graphics.getSprite("BobSpin", true));
216 else if ((player.environment == ENV_WATER))
218 engine.setInfoMessage("Jetpack cannot be used underwater", 0, INFO_NORMAL);
222 engine.setInfoMessage("Jetpack is recharging...", 0, INFO_NORMAL);
228 engine.setInfoMessage("Don't have jetpack!", 0, INFO_NORMAL);
231 config.resetControl(CONTROL::JETPACK);
234 if (map.isBlizzardLevel)
236 if ((!config.isControl(CONTROL::LEFT)) && (!config.isControl(CONTROL::RIGHT)))
238 if ((player.dx > -2) && (player.dx < 2))
240 player.dx += map.windPower * 0.1;
245 if (config.isControl(CONTROL::LEFT))
249 if (player.flags & ENT_FLIES)
252 Math::limitFloat(&player.dx, -PLAYER_FLY_SPEED, PLAYER_FLY_SPEED);
254 else if (map.isIceLevel)
257 Math::limitFloat(&player.dx, -PLAYER_WALK_SPEED * 1.25, PLAYER_WALK_SPEED * 1.25);
262 player.dx = -PLAYER_WALK_SPEED;
266 if (engine.cheatSpeed)
271 else if (config.isControl(CONTROL::RIGHT))
275 if (player.flags & ENT_FLIES)
278 Math::limitFloat(&player.dx, -PLAYER_FLY_SPEED, PLAYER_FLY_SPEED);
280 else if (map.isIceLevel)
284 Math::limitFloat(&player.dx, -PLAYER_WALK_SPEED * 1.25, PLAYER_WALK_SPEED * 1.25);
288 player.dx = PLAYER_WALK_SPEED;
292 if (engine.cheatSpeed)
297 else if (!(player.flags & ENT_FLIES))
300 player.currentFrame = 0;
303 Math::limitFloat(&player.x, 10, map.limitRight + 608);
304 Math::limitFloat(&player.y, map.limitUp + 5, (MAPHEIGHT * BRICKSIZE) + 64);
306 // Keyboard break fix - Feb 09
307 if ((config.isControl(CONTROL::UP)) || (config.isControl(CONTROL::JUMP)))
309 if (player.flags & ENT_FLIES)
312 Math::limitFloat(&player.dy, -PLAYER_FLY_SPEED, PLAYER_FLY_SPEED);
313 if (engine.cheatSpeed)
318 else if ((player.environment == ENV_AIR) && (player.falling == false))
320 player.falling = true;
321 player.dy = PLAYER_JUMP_SPEED;
322 config.resetControl(CONTROL::UP);
323 config.resetControl(CONTROL::JUMP);
325 else if (player.environment != ENV_AIR)
327 player.dy = -PLAYER_WALK_SPEED;
329 if (engine.cheatSpeed)
336 if (config.isControl(CONTROL::DOWN))
338 if (player.flags & ENT_FLIES)
341 Math::limitFloat(&player.dy, -PLAYER_FLY_SPEED, PLAYER_FLY_SPEED);
343 else if (player.environment != ENV_AIR)
349 if (engine.cheatSpeed)
356 if (engine.keyState[SDLK_1])
357 player.currentWeapon = &weapon[WP_PISTOL];
358 else if (engine.keyState[SDLK_2])
359 player.currentWeapon = &weapon[WP_MACHINEGUN];
360 else if (engine.keyState[SDLK_3])
361 player.currentWeapon = &weapon[WP_GRENADES];
362 else if (engine.keyState[SDLK_4])
363 player.currentWeapon = &weapon[WP_LASER];
364 else if (engine.keyState[SDLK_5])
365 player.currentWeapon = &weapon[WP_SPREAD];
370 // Math::limitFloat(&player.x, 10, map.limitRight + 608);
371 // moveEntity() limits x < 10
372 if (player.x > map.limitRight + 608)
374 player.x = map.limitRight + 608;
380 // Math::limitFloat(&player.y, map.limitUp + 5, (MAPHEIGHT * BRICKSIZE) + 64);
381 if (player.y < map.limitUp + 5)
383 player.y = map.limitUp + 5;
389 else if (player.y > (MAPHEIGHT * BRICKSIZE) + 64)
391 player.y = (MAPHEIGHT * BRICKSIZE) + 64;
394 if (config.isControl(CONTROL::FIRE))
396 if (player.reload == 0)
398 addBullet(&player, player.currentWeapon->getSpeed(player.face), 0);
399 if (player.currentWeapon == &weapon[WP_SPREAD])
401 addBullet(&player, player.currentWeapon->getSpeed(player.face), 2);
402 addBullet(&player, player.currentWeapon->getSpeed(player.face), -2);
407 if (player.environment == ENV_WATER)
409 Math::removeBit(&player.flags, ENT_FLIES);
411 addBubble(player.x, player.y);
413 if ((player.thinktime == 30) && (player.oxygen == 0))
415 audio.playSound(SND_DROWNING, CH_ANY);
421 if (player.fuel == 0)
423 player.setSprites(graphics.getSprite("BobRight", true), graphics.getSprite("BobLeft", true), graphics.getSprite("BobSpin", true));
426 if ((game.hasAquaLung) || (engine.cheatExtras))
431 if (engine.cheatFuel)
436 if (((player.immune % 5) == 0) && (!(player.flags & ENT_TELEPORTING)))
438 if ((game.missionOverReason == MIS_COMPLETE) || (game.missionOverReason == MIS_INPROGRESS) || (game.missionOverReason == MIS_GAMECOMPLETE))
440 if (player.flags & ENT_FLIES)
443 addFireTrailParticle(player.x + (player.face * 16) + Math::rrand(-1, 1), player.y + 10 + Math::rrand(-1, 1));
445 graphics.blit(player.getFaceImage(), (int)(player.x - engine.playerPosX), (int)(player.y - engine.playerPosY), graphics.screen, false);