3 // SuperTux - A Jump'n Run
4 // Copyright (C) 2003 Tobias Glaesser <tobi.web@gmx.de>
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // 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.
24 #include "app/globals.h"
25 #include "app/gettext.h"
30 #include "special/sprite.h"
35 #include "resources.h"
36 #include "interactive_object.h"
37 #include "video/screen.h"
38 #include "statistics.h"
41 // behavior definitions:
42 #define TILES_FOR_BUTTJUMP 3
43 // animation times (in ms):
44 #define SHOOTING_TIME 320
46 #define AUTOSCROLL_DEAD_INTERVAL 300
48 // time before idle animation starts
49 #define IDLE_TIME 2500
52 Surface* growingtux_left[GROWING_FRAMES];
53 Surface* growingtux_right[GROWING_FRAMES];
57 Sprite* smalltux_gameover;
58 Sprite* smalltux_star;
61 TuxBodyParts* small_tux;
62 TuxBodyParts* big_tux;
63 TuxBodyParts* fire_tux;
64 TuxBodyParts* ice_tux;
68 PlayerKeymap::PlayerKeymap()
70 keymap.jump = SDLK_SPACE;
71 keymap.activate = SDLK_UP;
72 keymap.duck = SDLK_DOWN;
73 keymap.left = SDLK_LEFT;
74 keymap.right = SDLK_RIGHT;
75 keymap.fire = SDLK_LCTRL;
78 void player_input_init(player_input_type* pplayer_input)
80 pplayer_input->down = UP;
81 pplayer_input->fire = UP;
82 pplayer_input->left = UP;
83 pplayer_input->old_fire = UP;
84 pplayer_input->right = UP;
85 pplayer_input->up = UP;
86 pplayer_input->old_up = UP;
87 pplayer_input->activate = UP;
91 TuxBodyParts::set_action(std::string action)
94 head->set_action(action);
96 body->set_action(action);
98 arms->set_action(action);
100 feet->set_action(action);
104 TuxBodyParts::one_time_animation()
107 head->start_animation(1);
109 body->start_animation(1);
111 arms->start_animation(1);
113 feet->start_animation(1);
117 TuxBodyParts::draw(DrawingContext& context, const Vector& pos, int layer,
118 Uint32 drawing_effect)
121 head->draw(context, pos, layer-1, drawing_effect);
123 body->draw(context, pos, layer-3, drawing_effect);
125 arms->draw(context, pos, layer, drawing_effect);
127 feet->draw(context, pos, layer-2, drawing_effect);
142 holding_something = false;
148 got_power = NONE_POWER;
152 previous_base = old_base = base;
160 fall_mode = ON_GROUND;
165 falling_from_flap = false;
166 enable_hover = false;
172 player_input_init(&input);
174 invincible_timer.init(true);
175 skidding_timer.init(true);
176 safe_timer.init(true);
177 frame_timer.init(true);
178 kick_timer.init(true);
179 shooting_timer.init(true);
180 growing_timer.init(true);
181 idle_timer.init(true);
182 flapping_timer.init(true);
188 Player::key_event(SDLKey key, int state)
190 idle_timer.start(IDLE_TIME);
192 if(key == keymap.right)
197 else if(key == keymap.left)
202 else if(key == keymap.jump)
207 else if(key == keymap.duck)
212 else if(key == keymap.fire)
219 else if(key == keymap.activate)
221 input.activate = state;
224 /** check for interactive objects */
225 for(Sector::InteractiveObjects::iterator i
226 = Sector::current()->interactive_objects.begin();
227 i != Sector::current()->interactive_objects.end(); ++i) {
228 if(rectcollision(base, (*i)->get_area())) {
229 (*i)->interaction(INTERACTION_ACTIVATE);
241 Player::level_begin()
245 previous_base = old_base = base;
250 player_input_init(&input);
252 invincible_timer.init(true);
253 skidding_timer.init(true);
254 safe_timer.init(true);
255 frame_timer.init(true);
256 growing_timer.init(true);
257 idle_timer.init(true);
263 Player::action(float elapsed_time)
265 bool jumped_in_solid = false;
267 if(dying && !dying_timer.check()) {
272 if (input.fire == UP)
273 holding_something = false;
276 previous_base = base;
278 /* --- HANDLE TUX! --- */
279 if(dying == DYING_NOT)
282 physic.apply(elapsed_time, base.x, base.y, Sector::current()->gravity);
284 if(dying == DYING_NOT)
286 base_type target = base;
288 collision_swept_object_map(&old_base, &base);
290 if ((!invincible_timer.started() && !safe_timer.started())
291 && (isspike(base.x, base.y) || isspike(base.x + base.width, base.y)
292 || isspike(base.x, base.y + base.height)
293 || isspike(base.x + base.width, base.y + base.height)))
298 // Don't accelerate Tux if he is running against a wall
299 if (target.x != base.x)
301 physic.set_velocity_x(0);
304 // special exception for cases where we're stuck under tiles after
305 // being ducked. In this case we drift out
306 if(!duck && on_ground() && old_base.x == base.x && old_base.y == base.y
307 && collision_object_map(base))
309 base.x += elapsed_time * WALK_SPEED * (dir ? 1: -1);
310 previous_base = old_base = base;
316 physic.enable_gravity(true);
320 physic.set_velocity_y(0);
321 jumped_in_solid = true;
329 if (physic.get_velocity_y() < 0)
331 base.y = (int)(((int)base.y / 32) * 32);
332 physic.set_velocity_y(0);
335 physic.enable_gravity(false);
336 /* Reset score multiplier (for multi-hits): */
337 if (!invincible_timer.started())
339 if(player_status.score_multiplier > 2)
342 sprintf(str, _("%d bad guys in a row!"), player_status.score_multiplier-1);
343 Sector::current()->add_floating_text(base, str);
345 player_status.score_multiplier = 1;
351 if (isbrick(base.x, base.y) ||
352 isfullbox(base.x, base.y))
354 Sector::current()->trygrabdistro(
355 Vector(base.x, base.y - 32), BOUNCE);
356 Sector::current()->trybumpbadguy(Vector(base.x, base.y - 64));
358 Sector::current()->trybreakbrick(
359 Vector(base.x, base.y), size == SMALL);
361 bumpbrick(base.x, base.y);
362 Sector::current()->tryemptybox(Vector(base.x, base.y), RIGHT);
365 if (isbrick(base.x+ 31, base.y) ||
366 isfullbox(base.x+ 31, base.y))
368 Sector::current()->trygrabdistro(
369 Vector(base.x+ 31, base.y - 32), BOUNCE);
370 Sector::current()->trybumpbadguy(Vector(base.x+ 31, base.y - 64));
373 Sector::current()->trybreakbrick(
374 Vector(base.x+ 31, base.y), size == SMALL);
376 bumpbrick(base.x+ 31, base.y);
377 Sector::current()->tryemptybox(Vector(base.x+ 31, base.y), LEFT);
389 /* Make sure jumping is off. */
396 /* ---- DONE HANDLING TUX! --- */
399 skidding_timer.check();
400 invincible_timer.check();
408 return ( issolid(base.x + base.width / 2, base.y + base.height) ||
409 issolid(base.x + 1, base.y + base.height) ||
410 issolid(base.x + base.width - 1, base.y + base.height));
414 Player::under_solid()
416 return ( issolid(base.x + base.width / 2, base.y) ||
417 issolid(base.x + 1, base.y) ||
418 issolid(base.x + base.width - 1, base.y) );
422 Player::tiles_on_air(int tiles)
424 for(int t = 0; t != tiles; t++)
426 if(issolid(base.x + base.width / 2, base.y + base.height + (tiles*32)) ||
427 issolid(base.x + 1, base.y + base.height + (tiles*32)) ||
428 issolid(base.x + base.width - 1, base.y + base.height + (tiles*32)))
435 Player::handle_horizontal_input()
437 float vx = physic.get_velocity_x();
438 float vy = physic.get_velocity_y();
439 float ax = physic.get_acceleration_x();
440 float ay = physic.get_acceleration_y();
443 if(input.left == DOWN && input.right == UP && (!duck || physic.get_velocity_y() != 0)) {
447 } else if(input.left == UP && input.right == DOWN && (!duck || physic.get_velocity_y() != 0)) {
453 if (input.fire == UP) {
454 ax = dirsign * WALK_ACCELERATION_X;
456 if(vx >= MAX_WALK_XM && dirsign > 0) {
459 } else if(vx <= -MAX_WALK_XM && dirsign < 0) {
464 ax = dirsign * RUN_ACCELERATION_X;
466 if(vx >= MAX_RUN_XM && dirsign > 0) {
469 } else if(vx <= -MAX_RUN_XM && dirsign < 0) {
475 // we can reach WALK_SPEED without any acceleration
476 if(dirsign != 0 && fabs(vx) < WALK_SPEED) {
477 vx = dirsign * WALK_SPEED;
480 // changing directions?
481 if(on_ground() && ((vx < 0 && dirsign >0) || (vx>0 && dirsign<0))) {
482 if(fabs(vx)>SKID_XM && !skidding_timer.check()) {
483 skidding_timer.start(SKID_TIME);
484 SoundManager::get()->play_sound(IDToSound(SND_SKID));
491 // we get slower when not pressing any keys
493 if(fabs(vx) < WALK_SPEED) {
497 ax = WALK_ACCELERATION_X * 1.5;
499 ax = WALK_ACCELERATION_X * -1.5;
503 // if we're on ice slow down acceleration or deceleration
504 if (isice(base.x, base.y + base.height))
506 /* the acceleration/deceleration rate on ice is inversely proportional to
507 * the current velocity.
510 // increasing 1 will increase acceleration/deceleration rate
511 // decreasing 1 will decrease acceleration/deceleration rate
512 // must stay above zero, though
513 if (ax != 0) ax *= 1 / fabs(vx);
516 physic.set_velocity(vx, vy);
517 physic.set_acceleration(ax, ay);
521 Player::handle_vertical_input()
526 fall_mode = ON_GROUND;
527 last_ground_y = base.y;
529 if(base.y > last_ground_y)
531 else if(fall_mode == ON_GROUND)
536 if(input.up == DOWN && can_jump && on_ground())
538 if(duck) { // only jump a little bit when in duck mode {
539 physic.set_velocity_y(3);
541 // jump higher if we are running
542 if (fabs(physic.get_velocity_x()) > MAX_WALK_XM)
543 physic.set_velocity_y(5.8);
545 physic.set_velocity_y(5.2);
554 SoundManager::get()->play_sound(IDToSound(SND_JUMP));
556 SoundManager::get()->play_sound(IDToSound(SND_BIGJUMP));
558 // Let go of jump key
559 else if(input.up == UP)
561 if (!flapping && !duck && !falling_from_flap && !on_ground())
565 if (jumping && physic.get_velocity_y() > 0)
568 physic.set_velocity_y(0);
573 if (input.up == DOWN && can_flap)
575 if (!flapping_timer.started())
577 flapping_timer.start(TUX_FLAPPING_TIME);
579 if (!flapping_timer.check())
582 falling_from_flap = true;
586 if (flapping_timer.get_gone() <= TUX_FLAPPING_TIME)
588 physic.set_velocity_y((float)flapping_timer.get_gone()/450);
593 //(disabled by default, use cheat code "hover" to toggle on/off)
594 //TODO: needs some tweaking, especially when used together with double jump and jumping off badguys
595 if (enable_hover && input.up == DOWN && !jumping && !butt_jump && physic.get_velocity_y() <= 0)
597 physic.set_velocity_y(-1);
600 /* In case the player has pressed Down while in a certain range of air,
601 enable butt jump action */
602 if (input.down == DOWN && !butt_jump && !duck)
603 if(tiles_on_air(TILES_FOR_BUTTJUMP) && jumping)
606 /* When Down is not held anymore, disable butt jump */
607 if(butt_jump && input.down == UP)
611 if (butt_jump && on_ground() && size == BIG)
615 Sector::current()->add_smoke_cloud(Vector(base.x - 32, base.y));
617 Sector::current()->add_smoke_cloud(Vector(base.x - 32, base.y + 32));
621 // Break bricks beneath Tux
622 if(Sector::current()->trybreakbrick(
623 Vector(base.x + 1, base.y + base.height), false)
624 || Sector::current()->trybreakbrick(
625 Vector(base.x + base.width - 1, base.y + base.height), false))
627 physic.set_velocity_y(2);
631 // Kill nearby badguys
632 std::vector<GameObject*> gameobjects = Sector::current()->gameobjects;
633 for (std::vector<GameObject*>::iterator i = gameobjects.begin();
634 i != gameobjects.end();
637 BadGuy* badguy = dynamic_cast<BadGuy*> (*i);
640 // don't kill when badguys are already dying or in a certain mode
641 if(badguy->dying == DYING_NOT && badguy->mode != BadGuy::BOMB_TICKING &&
642 badguy->mode != BadGuy::BOMB_EXPLODE)
644 if (fabsf(base.x - badguy->base.x) < 150 &&
645 fabsf(base.y - badguy->base.y) < 60 &&
646 (issolid(badguy->base.x + 1, badguy->base.y + badguy->base.height) ||
647 issolid(badguy->base.x + badguy->base.width - 1, badguy->base.y + badguy->base.height)))
654 if ( (issolid(base.x + base.width / 2, base.y + base.height + 64) ||
655 issolid(base.x + 1, base.y + base.height + 64) ||
656 issolid(base.x + base.width - 1, base.y + base.height + 64))
660 && input.old_up == UP)
665 if(on_ground()) /* Make sure jumping is off. */
669 falling_from_flap = false;
670 if (flapping_timer.started()) {flapping_timer.stop();}
673 input.old_up = input.up;
677 Player::handle_input()
679 /* Handle horizontal movement: */
680 handle_horizontal_input();
684 if (on_ground() && input.up == UP)
686 handle_vertical_input();
689 if (input.fire == DOWN && input.old_fire == UP && got_power != NONE_POWER)
691 if(Sector::current()->add_bullet(Vector(base.x, base.y + (base.height/2)),
692 physic.get_velocity_x(), dir))
693 shooting_timer.start(SHOOTING_TIME);
694 input.old_fire = DOWN;
697 /* tux animations: */
698 if(!frame_timer.check())
700 frame_timer.start(25);
701 if (input.right == UP && input.left == UP)
708 if ((input.fire == DOWN && (global_frame_counter % 2) == 0) ||
709 (global_frame_counter % 4) == 0)
710 frame_main = (frame_main + 1) % 4;
720 if (input.down == DOWN && size == BIG && !duck && physic.get_velocity_y() == 0 && on_ground())
725 // changing base size confuses collision otherwise
726 old_base = previous_base = base;
728 else if(input.down == UP && size == BIG && duck)
730 // try if we can really unduck
733 // when unducking in air we need some space to do so
734 if(on_ground() || !collision_object_map(base)) {
736 // changing base size confuses collision otherwise
737 old_base = previous_base = base;
739 // undo the ducking changes
747 Player::grow(bool animate)
757 growing_timer.start(GROWING_TIME);
759 old_base = previous_base = base;
763 Player::grabdistros()
768 Sector::current()->trygrabdistro(Vector(base.x, base.y), NO_BOUNCE);
769 Sector::current()->trygrabdistro(Vector(base.x+ 31, base.y), NO_BOUNCE);
770 Sector::current()->trygrabdistro(
771 Vector(base.x, base.y + base.height), NO_BOUNCE);
772 Sector::current()->trygrabdistro(
773 Vector(base.x+ 31, base.y + base.height), NO_BOUNCE);
777 Sector::current()->trygrabdistro(
778 Vector(base.x, base.y + base.height / 2), NO_BOUNCE);
779 Sector::current()->trygrabdistro(
780 Vector(base.x+ 31, base.y + base.height / 2), NO_BOUNCE);
785 /* Enough distros for a One-up? */
786 if (player_status.distros >= DISTROS_LIFEUP)
788 player_status.distros = player_status.distros - DISTROS_LIFEUP;
789 if(player_status.lives < MAX_LIVES)
790 ++player_status.lives;
791 /*We want to hear the sound even, if MAX_LIVES is reached*/
792 SoundManager::get()->play_sound(IDToSound(SND_LIFEUP));
797 Player::draw(DrawingContext& context)
799 TuxBodyParts* tux_body;
802 tux_body = small_tux;
803 else if (got_power == FIRE_POWER)
805 else if (got_power == ICE_POWER)
810 int layer = LAYER_OBJECTS - 1;
811 Vector pos = Vector(base.x, base.y);
813 /* Set Tux sprite action */
814 if (duck && size == BIG)
817 tux_body->set_action("duck-left");
819 tux_body->set_action("duck-right");
821 else if (skidding_timer.started())
824 tux_body->set_action("skid-left");
826 tux_body->set_action("skid-right");
828 else if (kick_timer.started())
831 tux_body->set_action("kick-left");
833 tux_body->set_action("kick-right");
838 tux_body->set_action("buttjump-left");
840 tux_body->set_action("buttjump-right");
842 else if (physic.get_velocity_y() != 0)
845 tux_body->set_action("jump-left");
847 tux_body->set_action("jump-right");
851 if (fabsf(physic.get_velocity_x()) < 1.0f) // standing
854 tux_body->set_action("stand-left");
856 tux_body->set_action("stand-right");
861 tux_body->set_action("walk-left");
863 tux_body->set_action("walk-right");
867 if(idle_timer.get_left() < 0)
872 tux_body->head->set_action("idle-left");
874 tux_body->head->set_action("idle-right");
876 tux_body->head->start_animation(1);
879 idle_timer.start(IDLE_TIME);
882 // Tux is holding something
883 if ((holding_something && physic.get_velocity_y() == 0) ||
884 shooting_timer.check())
889 tux_body->arms->set_action("duck+grab-left");
891 tux_body->arms->set_action("duck+grab-right");
896 tux_body->arms->set_action("grab-left");
898 tux_body->arms->set_action("grab-right");
903 if (dying == DYING_SQUISHED)
905 smalltux_gameover->draw(context, pos, LAYER_FOREGROUNDTILES+1);
907 else if(growing_timer.check())
912 context.draw_surface(growingtux_right[GROWING_FRAMES-1 -
913 ((growing_timer.get_gone() *
914 GROWING_FRAMES) / GROWING_TIME)], pos, layer);
916 context.draw_surface(growingtux_left[GROWING_FRAMES-1 -
917 ((growing_timer.get_gone() *
918 GROWING_FRAMES) / GROWING_TIME)], pos, layer);
923 context.draw_surface(growingtux_right[(growing_timer.get_gone() *
924 GROWING_FRAMES) / GROWING_TIME], pos, layer);
926 context.draw_surface(growingtux_left[(growing_timer.get_gone() *
927 GROWING_FRAMES) / GROWING_TIME], pos, layer);
930 else if (safe_timer.started() && global_frame_counter%2)
933 tux_body->draw(context, pos, layer, dir == LEFT ? HORIZONTAL_FLIP : NONE_EFFECT);
935 // Draw blinking star overlay
936 if (invincible_timer.started() &&
937 (invincible_timer.get_left() > TUX_INVINCIBLE_TIME_WARNING || global_frame_counter % 3)
940 if (size == SMALL || duck)
941 smalltux_star->draw(context, pos, LAYER_OBJECTS + 2);
943 bigtux_star->draw(context, pos, LAYER_OBJECTS + 2);
947 context.draw_filled_rect(Vector(base.x, base.y),
948 Vector(base.width, base.height), Color(75,75,75, 150), LAYER_OBJECTS+1);
952 Player::collision(const MovingObject& other, int collision_type)
955 (void) collision_type;
956 // will be implemented later
960 Player::collision(void* p_c_object, int c_object)
962 BadGuy* pbad_c = NULL;
963 Trampoline* ptramp_c = NULL;
964 FlyingPlatform* pplatform_c = NULL;
969 pbad_c = (BadGuy*) p_c_object;
971 /* Hurt player if he touches a badguy */
972 if (!pbad_c->dying && !dying &&
973 !safe_timer.started() &&
974 pbad_c->mode != BadGuy::HELD)
976 if (pbad_c->mode == BadGuy::FLAT && input.fire == DOWN
977 && !holding_something)
979 holding_something = true;
980 pbad_c->mode = BadGuy::HELD;
983 else if (pbad_c->mode == BadGuy::FLAT)
985 // Don't get hurt if we're kicking a flat badguy!
987 else if (pbad_c->mode == BadGuy::KICK)
989 /* Hurt if you get hit by kicked laptop: */
990 if (!invincible_timer.started())
997 else if (pbad_c->frozen_timer.check() && (pbad_c->kind == BAD_MRBOMB
998 || pbad_c->kind == BAD_JUMPY || pbad_c->kind == BAD_FISH
999 || pbad_c->kind == BAD_SPIKY))
1000 pbad_c->kill_me(20);
1003 if (!invincible_timer.started())
1009 pbad_c->kill_me(25);
1012 player_status.score_multiplier++;
1017 ptramp_c = (Trampoline*) p_c_object;
1019 // Pick up trampoline
1020 if (ptramp_c->mode != Trampoline::M_HELD && input.fire == DOWN && !holding_something && on_ground())
1022 holding_something = true;
1023 ptramp_c->mode = Trampoline::M_HELD;
1024 ptramp_c->base.y -= 8;
1026 // Set down trampoline
1027 else if (ptramp_c->mode == Trampoline::M_HELD && input.fire != DOWN)
1029 holding_something = false;
1030 ptramp_c->mode = Trampoline::M_NORMAL;
1031 ptramp_c->base.y += 8;
1032 ptramp_c->physic.set_velocity(physic.get_velocity_x(), physic.get_velocity_y());
1035 // ptramp_c->base.x = base.x + base.width+1;
1037 // ptramp_c->base.x = base.x - base.width-1;
1040 // Don't let tux walk through trampoline
1041 else if (ptramp_c->mode != Trampoline::M_HELD && on_ground())
1043 if (physic.get_velocity_x() > 0) // RIGHT
1045 physic.set_velocity_x(0);
1046 base.x = ptramp_c->base.x - base.width;
1048 else if (physic.get_velocity_x() < 0) // LEFT
1050 physic.set_velocity_x(0);
1051 base.x = ptramp_c->base.x + ptramp_c->base.width;
1056 case CO_FLYING_PLATFORM:
1057 pplatform_c = (FlyingPlatform*) p_c_object;
1059 base.y = pplatform_c->base.y - base.height;
1060 physic.set_velocity_x(pplatform_c->get_vel_x());
1062 physic.enable_gravity(false);
1064 fall_mode = ON_GROUND;
1076 Player::kill(HurtMode mode)
1081 SoundManager::get()->play_sound(IDToSound(SND_HURT));
1083 physic.set_velocity_x(0);
1085 if (mode == SHRINK && size == BIG)
1087 if (got_power != NONE_POWER)
1089 safe_timer.start(TUX_SAFE_TIME);
1090 got_power = NONE_POWER;
1094 growing_timer.start(GROWING_TIME);
1095 safe_timer.start(TUX_SAFE_TIME + GROWING_TIME);
1103 physic.enable_gravity(true);
1104 physic.set_acceleration(0, 0);
1105 physic.set_velocity(0, 7);
1106 --player_status.lives;
1107 dying = DYING_SQUISHED;
1108 dying_timer.start(3000);
1112 /* Remove Tux's power ups */
1114 Player::remove_powerups()
1116 got_power = NONE_POWER;
1122 Player::move(const Vector& vector)
1126 old_base = previous_base = base;
1130 Player::check_bounds(Camera* camera)
1132 /* Keep tux in bounds: */
1134 { // Lock Tux to the size of the level, so that he doesn't fall of
1139 /* Keep in-bounds, vertically: */
1140 if (base.y > Sector::current()->solids->get_height() * 32)
1146 bool adjust = false;
1147 // can happen if back scrolling is disabled
1148 if(base.x < camera->get_translation().x) {
1149 base.x = camera->get_translation().x;
1152 if(base.x >= camera->get_translation().x + screen->w - base.width) {
1153 base.x = camera->get_translation().x + screen->w - base.width;
1159 if(collision_object_map(base)) {
1167 Player::bounce(BadGuy* badguy)
1169 //Make sure we stopped flapping
1171 falling_from_flap = false;
1174 physic.set_velocity_y(5.2);
1176 physic.set_velocity_y(2);
1178 // Move the player a little bit above the badguy to avoid collision
1179 // between badguy and player directly after the bounce has happend
1180 base.y = badguy->base.y - base.height - 2;