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.
27 #include "app/globals.h"
28 #include "app/gettext.h"
33 #include "special/sprite.h"
38 #include "resources.h"
39 #include "video/screen.h"
40 #include "statistics.h"
42 #include "trigger/trigger_base.h"
44 // behavior definitions:
45 #define TILES_FOR_BUTTJUMP 3
46 // animation times (in ms):
47 #define SHOOTING_TIME .150
49 // time before idle animation starts
50 #define IDLE_TIME 2.500
53 Surface* growingtux_left[GROWING_FRAMES];
54 Surface* growingtux_right[GROWING_FRAMES];
56 Surface* tux_life = 0;
58 Sprite* smalltux_gameover = 0;
59 Sprite* smalltux_star = 0;
60 Sprite* bigtux_star = 0;
62 TuxBodyParts* small_tux = 0;
63 TuxBodyParts* big_tux = 0;
64 TuxBodyParts* fire_tux = 0;
65 TuxBodyParts* ice_tux = 0;
69 PlayerKeymap::PlayerKeymap()
72 keymap.down = SDLK_DOWN;
73 keymap.left = SDLK_LEFT;
74 keymap.right = SDLK_RIGHT;
76 keymap.power = SDLK_LCTRL;
77 keymap.jump = SDLK_LALT;
80 void player_input_init(player_input_type* pplayer_input)
82 pplayer_input->up = UP;
83 pplayer_input->old_up = UP;
84 pplayer_input->down = UP;
85 pplayer_input->fire = UP;
86 pplayer_input->left = UP;
87 pplayer_input->old_fire = UP;
88 pplayer_input->right = UP;
89 pplayer_input->jump = UP;
90 pplayer_input->old_jump = UP;
91 pplayer_input->activate = UP;
95 TuxBodyParts::set_action(std::string action)
98 head->set_action(action);
100 body->set_action(action);
102 arms->set_action(action);
104 feet->set_action(action);
108 TuxBodyParts::one_time_animation()
111 head->start_animation(1);
113 body->start_animation(1);
115 arms->start_animation(1);
117 feet->start_animation(1);
121 TuxBodyParts::draw(DrawingContext& context, const Vector& pos, int layer,
122 Uint32 drawing_effect)
125 head->draw(context, pos, layer-1, drawing_effect);
127 body->draw(context, pos, layer-3, drawing_effect);
129 arms->draw(context, pos, layer, drawing_effect);
131 feet->draw(context, pos, layer-2, drawing_effect);
146 holding_something = false;
148 bbox.set_size(32, 32);
151 got_power = NONE_POWER;
160 fall_mode = ON_GROUND;
165 falling_from_flap = false;
166 enable_hover = false;
169 flapping_velocity = 0;
171 // temporary to help player's choosing a flapping
172 flapping_mode = MAREK_FLAP;
174 // Ricardo's flapping
177 on_ground_flag = false;
182 player_input_init(&input);
184 frame_timer.start(.025, true);
190 Player::key_event(SDLKey key, int state)
192 idle_timer.start(IDLE_TIME, true);
194 if(key == keymap.right)
199 else if(key == keymap.left)
204 else if(key == keymap.up)
209 /* Up key also opens activates stuff */
210 input.activate = state;
213 else if(key == keymap.down)
218 else if(key == keymap.power)
226 else if(key == keymap.jump)
238 Player::level_begin()
240 move(Vector(100, 170));
245 player_input_init(&input);
247 on_ground_flag = false;
255 return player_status;
259 Player::action(float elapsed_time)
261 if(dying && dying_timer.check()) {
266 if (input.fire == UP)
267 holding_something = false;
269 /* --- HANDLE TUX! --- */
270 if(dying == DYING_NOT)
273 movement = physic.get_movement(elapsed_time);
275 if(dying == DYING_NOT)
278 collision_swept_object_map(&old_base, &base);
280 if ((!invincible_timer.started() && !safe_timer.started())
281 && (isspike(base.x, base.y) || isspike(base.x + base.width, base.y)
282 || isspike(base.x, base.y + base.height)
283 || isspike(base.x + base.width, base.y + base.height)))
288 // Don't accelerate Tux if he is running against a wall
289 if (target.x != base.x)
291 physic.set_velocity_x(0);
294 // special exception for cases where we're stuck under tiles after
295 // being ducked. In this case we drift out
296 if(!duck && on_ground() && old_base.x == base.x && old_base.y == base.y
297 && collision_object_map(base))
299 base.x += elapsed_time * WALK_SPEED * (dir ? 1: -1);
300 previous_base = old_base = base;
306 physic.enable_gravity(true);
310 physic.set_velocity_y(0);
311 jumped_in_solid = true;
319 if (physic.get_velocity_y() < 0)
321 base.y = (int)(((int)base.y / 32) * 32);
322 physic.set_velocity_y(0);
325 physic.enable_gravity(false);
326 /* Reset score multiplier (for multi-hits): */
327 if (!invincible_timer.started())
329 if(player_status.score_multiplier > player_status.max_score_multiplier)
331 player_status.max_score_multiplier = player_status.score_multiplier;
335 sprintf(str, _("New max combo: %d"), player_status.max_score_multiplier-1);
336 Sector::current()->add_floating_text(base, str);
338 player_status.score_multiplier = 1;
344 if (isbrick(base.x, base.y) ||
345 isfullbox(base.x, base.y))
347 Sector::current()->trygrabdistro(
348 Vector(base.x, base.y - 32), BOUNCE);
349 Sector::current()->trybumpbadguy(Vector(base.x, base.y - 64));
351 Sector::current()->trybreakbrick(
352 Vector(base.x, base.y), size == SMALL);
354 bumpbrick(base.x, base.y);
355 Sector::current()->tryemptybox(Vector(base.x, base.y), RIGHT);
358 if (isbrick(base.x+ 31, base.y) ||
359 isfullbox(base.x+ 31, base.y))
361 Sector::current()->trygrabdistro(
362 Vector(base.x+ 31, base.y - 32), BOUNCE);
363 Sector::current()->trybumpbadguy(Vector(base.x+ 31, base.y - 64));
366 Sector::current()->trybreakbrick(
367 Vector(base.x+ 31, base.y), size == SMALL);
369 bumpbrick(base.x+ 31, base.y);
370 Sector::current()->tryemptybox(Vector(base.x+ 31, base.y), LEFT);
384 /* Make sure jumping is off. */
392 on_ground_flag = false;
398 return on_ground_flag;
402 Player::handle_horizontal_input()
404 float vx = physic.get_velocity_x();
405 float vy = physic.get_velocity_y();
406 float ax = physic.get_acceleration_x();
407 float ay = physic.get_acceleration_y();
410 if(input.left == DOWN && input.right == UP && (!duck || physic.get_velocity_y() != 0)) {
414 } else if(input.left == UP && input.right == DOWN && (!duck || physic.get_velocity_y() != 0)) {
420 if (input.fire == UP) {
421 ax = dirsign * WALK_ACCELERATION_X;
423 if(vx >= MAX_WALK_XM && dirsign > 0) {
426 } else if(vx <= -MAX_WALK_XM && dirsign < 0) {
431 ax = dirsign * RUN_ACCELERATION_X;
433 if(vx >= MAX_RUN_XM && dirsign > 0) {
436 } else if(vx <= -MAX_RUN_XM && dirsign < 0) {
442 // we can reach WALK_SPEED without any acceleration
443 if(dirsign != 0 && fabs(vx) < WALK_SPEED) {
444 vx = dirsign * WALK_SPEED;
447 // changing directions?
448 if(on_ground() && ((vx < 0 && dirsign >0) || (vx>0 && dirsign<0)))
451 if(fabs(vx)>SKID_XM && !skidding_timer.started())
453 skidding_timer.start(SKID_TIME);
454 SoundManager::get()->play_sound(IDToSound(SND_SKID));
455 // dust some partcles
456 Sector::current()->add_particles(
457 Vector(bbox.p1.x + (dir == RIGHT ? bbox.get_width() : 0),
459 dir == RIGHT ? 270+20 : 90-40, dir == RIGHT ? 270+40 : 90-20,
460 Vector(280,-260), Vector(0,0.030), 3, Color(100,100,100), 3, 800,
471 // we get slower when not pressing any keys
473 if(fabs(vx) < WALK_SPEED) {
477 ax = WALK_ACCELERATION_X * 1.5;
479 ax = WALK_ACCELERATION_X * -1.5;
484 // if we're on ice slow down acceleration or deceleration
485 if (isice(base.x, base.y + base.height))
487 /* the acceleration/deceleration rate on ice is inversely proportional to
488 * the current velocity.
491 // increasing 1 will increase acceleration/deceleration rate
492 // decreasing 1 will decrease acceleration/deceleration rate
493 // must stay above zero, though
494 if (ax != 0) ax *= 1 / fabs(vx);
498 physic.set_velocity(vx, vy);
499 physic.set_acceleration(ax, ay);
503 Player::handle_vertical_input()
507 fall_mode = ON_GROUND;
508 last_ground_y = get_pos().y;
510 if(get_pos().y > last_ground_y)
512 else if(fall_mode == ON_GROUND)
517 if(input.jump == DOWN && can_jump && on_ground())
519 if(duck) { // only jump a little bit when in duck mode {
520 physic.set_velocity_y(300);
522 // jump higher if we are running
523 if (fabs(physic.get_velocity_x()) > MAX_WALK_XM)
524 physic.set_velocity_y(580);
526 physic.set_velocity_y(520);
529 //bbox.move(Vector(0, -1));
534 flaps_nb = 0; // Ricardo's flapping
536 SoundManager::get()->play_sound(IDToSound(SND_JUMP));
538 SoundManager::get()->play_sound(IDToSound(SND_BIGJUMP));
540 // Let go of jump key
541 else if(input.jump == UP)
543 if (!flapping && !duck && !falling_from_flap && !on_ground())
547 if (jumping && physic.get_velocity_y() > 0)
550 physic.set_velocity_y(0);
554 // temporary to help player's choosing a flapping
555 if(flapping_mode == RICARDO_FLAP)
557 // Flapping, Ricardo's version
558 // similar to SM3 Fox
559 if(input.jump == DOWN && input.old_jump == UP && can_flap &&
562 physic.set_velocity_y(350);
563 physic.set_velocity_x(physic.get_velocity_x() * 35);
567 else if(flapping_mode == MAREK_FLAP)
569 // Flapping, Marek's version
570 if (input.jump == DOWN && can_flap)
572 if (!flapping_timer.started())
574 flapping_timer.start(TUX_FLAPPING_TIME);
575 flapping_velocity = physic.get_velocity_x();
577 if (flapping_timer.check())
580 falling_from_flap = true;
584 if (!flapping_timer.check()) {
585 float cv = flapping_velocity * sqrt(
586 TUX_FLAPPING_TIME - flapping_timer.get_timegone()
587 / TUX_FLAPPING_TIME);
589 //Handle change of direction while flapping
590 if (((dir == LEFT) && (cv > 0)) || (dir == RIGHT) && (cv < 0)) {
593 physic.set_velocity_x(cv);
594 physic.set_velocity_y(
595 flapping_timer.get_timegone()/.850);
599 else if(flapping_mode == RYAN_FLAP)
601 // Flapping, Ryan's version
602 if (input.jump == DOWN && can_flap)
604 if (!flapping_timer.started())
606 flapping_timer.start(TUX_FLAPPING_TIME);
608 if (flapping_timer.check())
611 falling_from_flap = true;
615 if (flapping && flapping_timer.get_timegone() <= TUX_FLAPPING_TIME
616 && physic.get_velocity_y() < 0)
618 float gravity = Sector::current()->gravity;
620 float xr = (fabsf(physic.get_velocity_x()) / MAX_RUN_XM);
622 // XXX: magic numbers. should be a percent of gravity
623 // gravity is (by default) -0.1f
624 physic.set_acceleration_y(12 + 1*xr);
627 // To slow down x-vel when flapping (not working)
628 if (fabsf(physic.get_velocity_x()) > MAX_WALK_XM)
630 if (physic.get_velocity_x() < 0)
631 physic.set_acceleration_x(1.0f);
632 else if (physic.get_velocity_x() > 0)
633 physic.set_acceleration_x(-1.0f);
640 physic.set_acceleration_y(0);
645 //(disabled by default, use cheat code "hover" to toggle on/off)
646 //TODO: needs some tweaking, especially when used together with double jump and jumping off badguys
647 if (enable_hover && input.jump == DOWN && !jumping && !butt_jump && physic.get_velocity_y() <= 0)
649 physic.set_velocity_y(-100);
653 /* In case the player has pressed Down while in a certain range of air,
654 enable butt jump action */
655 if (input.down == DOWN && !butt_jump && !duck)
656 if(tiles_on_air(TILES_FOR_BUTTJUMP) && jumping)
660 /* When Down is not held anymore, disable butt jump */
661 if(butt_jump && input.down == UP)
665 if (butt_jump && on_ground() && size == BIG)
669 Sector::current()->add_smoke_cloud(Vector(get_pos().x - 32, get_pos().y));
671 Sector::current()->add_smoke_cloud(
672 Vector(get_pos().x - 32, get_pos().y + 32));
677 // Break bricks beneath Tux
678 if(Sector::current()->trybreakbrick(
679 Vector(base.x + 1, base.y + base.height), false)
680 || Sector::current()->trybreakbrick(
681 Vector(base.x + base.width - 1, base.y + base.height), false))
683 physic.set_velocity_y(2);
689 // Kill nearby badguys
690 std::vector<GameObject*> gameobjects = Sector::current()->gameobjects;
691 for (std::vector<GameObject*>::iterator i = gameobjects.begin();
692 i != gameobjects.end();
695 BadGuy* badguy = dynamic_cast<BadGuy*> (*i);
698 // don't kill when badguys are already dying or in a certain mode
699 if(badguy->dying == DYING_NOT && badguy->mode != BadGuy::BOMB_TICKING &&
700 badguy->mode != BadGuy::BOMB_EXPLODE)
702 if (fabsf(base.x - badguy->base.x) < 96 &&
703 fabsf(base.y - badguy->base.y) < 64)
711 /** jumping is only allowed if we're about to touch ground soon and if the
712 * button has been up in between the last jump
716 if ( (issolid(get_pos().x + bbox.get_width() / 2,
717 get_pos().y + bbox.get_height() + 64) ||
718 issolid(get_pos().x + 1, get_pos().y + bbox.get_height() + 64) ||
719 issolid(get_pos().x + bbox.get_width() - 1,
720 get_pos().y + bbox.get_height() + 64))
723 && input.jump == DOWN
724 && input.old_jump == UP)
730 if(on_ground()) /* Make sure jumping is off. */
734 falling_from_flap = false;
735 if (flapping_timer.started()) {
736 flapping_timer.start(0);
739 physic.set_acceleration_y(0); //for flapping
742 input.old_jump = input.jump;
746 Player::handle_input()
748 /* Handle horizontal movement: */
749 handle_horizontal_input();
753 if (on_ground() && input.jump == UP)
755 handle_vertical_input();
758 if (input.fire == DOWN && input.old_fire == UP && got_power != NONE_POWER)
760 if(Sector::current()->add_bullet(
761 get_pos() + Vector(0, bbox.get_height()/2),
762 physic.get_velocity_x(), dir))
763 shooting_timer.start(SHOOTING_TIME);
764 input.old_fire = DOWN;
767 /* tux animations: */
768 if(frame_timer.check()) {
769 if (input.right == UP && input.left == UP)
776 if ((input.fire == DOWN && (global_frame_counter % 2) == 0) ||
777 (global_frame_counter % 4) == 0)
778 frame_main = (frame_main + 1) % 4;
788 if (input.down == DOWN && size == BIG && !duck
789 && physic.get_velocity_y() == 0 && on_ground())
792 bbox.move(Vector(0, 32));
795 else if(input.down == UP && size == BIG && duck)
797 // try if we can really unduck
798 bbox.move(Vector(0, -32));
803 // when unducking in air we need some space to do so
804 if(on_ground() || !collision_object_map(bbox)) {
807 // undo the ducking changes
808 bbox.move(Vector(0, 32));
816 Player::grow(bool animate)
823 bbox.move(Vector(0, -32));
826 growing_timer.start(GROWING_TIME);
830 Player::grabdistros()
835 Player::draw(DrawingContext& context)
837 TuxBodyParts* tux_body;
840 tux_body = small_tux;
841 else if (got_power == FIRE_POWER)
843 else if (got_power == ICE_POWER)
848 int layer = LAYER_OBJECTS - 1;
850 /* Set Tux sprite action */
851 if (duck && size == BIG)
854 tux_body->set_action("duck-left");
856 tux_body->set_action("duck-right");
858 else if (skidding_timer.started() && !skidding_timer.check())
861 tux_body->set_action("skid-left");
863 tux_body->set_action("skid-right");
865 else if (kick_timer.started() && !kick_timer.check())
868 tux_body->set_action("kick-left");
870 tux_body->set_action("kick-right");
872 else if (butt_jump && size == BIG)
875 tux_body->set_action("buttjump-left");
877 tux_body->set_action("buttjump-right");
879 else if (physic.get_velocity_y() != 0)
882 tux_body->set_action("jump-left");
884 tux_body->set_action("jump-right");
888 if (fabsf(physic.get_velocity_x()) < 1.0f) // standing
891 tux_body->set_action("stand-left");
893 tux_body->set_action("stand-right");
898 tux_body->set_action("walk-left");
900 tux_body->set_action("walk-right");
904 if(idle_timer.check())
909 tux_body->head->set_action("idle-left");
911 tux_body->head->set_action("idle-right");
913 tux_body->head->start_animation(1);
918 // Tux is holding something
919 if ((holding_something && physic.get_velocity_y() == 0) ||
920 (shooting_timer.get_timeleft() > 0 && !shooting_timer.check()))
925 tux_body->arms->set_action("duck+grab-left");
927 tux_body->arms->set_action("duck+grab-right");
932 tux_body->arms->set_action("grab-left");
934 tux_body->arms->set_action("grab-right");
939 if (dying == DYING_SQUISHED) {
940 smalltux_gameover->draw(context, get_pos(), LAYER_FOREGROUNDTILES+1);
941 } else if(growing_timer.get_timeleft() > 0) {
945 context.draw_surface(growingtux_right[GROWING_FRAMES-1 -
946 int((growing_timer.get_timegone() *
947 GROWING_FRAMES) / GROWING_TIME)], get_pos(), layer);
949 context.draw_surface(growingtux_left[GROWING_FRAMES-1 -
950 int((growing_timer.get_timegone() *
951 GROWING_FRAMES) / GROWING_TIME)], get_pos(), layer);
956 context.draw_surface(growingtux_right[
957 int((growing_timer.get_timegone() *
958 GROWING_FRAMES) / GROWING_TIME)], get_pos(), layer);
960 context.draw_surface(growingtux_left[
961 int((growing_timer.get_timegone() *
962 GROWING_FRAMES) / GROWING_TIME)],
966 else if (safe_timer.started() && global_frame_counter%2)
969 tux_body->draw(context, get_pos(), layer);
971 // Draw blinking star overlay
972 if (invincible_timer.started() &&
973 (invincible_timer.get_timeleft() > TUX_INVINCIBLE_TIME_WARNING
974 || global_frame_counter % 3)
977 if (size == SMALL || duck)
978 smalltux_star->draw(context, get_pos(), LAYER_OBJECTS + 2);
980 bigtux_star->draw(context, get_pos(), LAYER_OBJECTS + 2);
984 context.draw_filled_rect(get_pos(),
985 Vector(bbox.get_width(), bbox.get_height()),
986 Color(75,75,75, 150), LAYER_OBJECTS+1);
990 Player::collision(GameObject& other, const CollisionHit& hit)
996 if(other.get_flags() & FLAG_SOLID) {
997 if(hit.normal.y < 0) { // landed on floor?
998 if (physic.get_velocity_y() < 0)
999 physic.set_velocity_y(0);
1000 on_ground_flag = true;
1001 } else if(hit.normal.y > 0) { // bumped against the roof
1002 physic.set_velocity_y(0);
1005 if(hit.normal.x != 0) { // hit on the side?
1006 if(hit.normal.y > 0.6) // limits the slopes we can move up...
1007 physic.set_velocity_x(0);
1013 TriggerBase* trigger = dynamic_cast<TriggerBase*> (&other);
1015 if(input.up == DOWN && input.old_up == UP)
1016 trigger->event(*this, TriggerBase::EVENT_ACTIVATE);
1024 Player::collision(void* p_c_object, int c_object)
1026 //BadGuy* pbad_c = NULL;
1027 //Trampoline* ptramp_c = NULL;
1028 //FlyingPlatform* pplatform_c = NULL;
1033 pbad_c = (BadGuy*) p_c_object;
1035 /* Hurt player if he touches a badguy */
1036 if (!pbad_c->dying && !dying &&
1037 !safe_timer.started() &&
1038 pbad_c->mode != BadGuy::HELD)
1040 if (pbad_c->mode == BadGuy::FLAT && input.fire == DOWN
1041 && !holding_something)
1043 holding_something = true;
1044 pbad_c->mode = BadGuy::HELD;
1047 else if (pbad_c->mode == BadGuy::FLAT)
1049 // Don't get hurt if we're kicking a flat badguy!
1051 else if (pbad_c->mode == BadGuy::KICK)
1053 /* Hurt if you get hit by kicked laptop: */
1054 if (!invincible_timer.started())
1059 pbad_c->kill_me(20);
1061 else if (!pbad_c->frozen_timer.check() && (pbad_c->kind == BAD_MRBOMB
1062 || pbad_c->kind == BAD_JUMPY || pbad_c->kind == BAD_FISH
1063 || pbad_c->kind == BAD_SPIKY))
1064 pbad_c->kill_me(20);
1067 if (!invincible_timer.started())
1073 pbad_c->kill_me(25);
1076 player_status.score_multiplier++;
1081 ptramp_c = (Trampoline*) p_c_object;
1083 // Pick up trampoline
1084 if (ptramp_c->mode != Trampoline::M_HELD && input.fire == DOWN && !holding_something && on_ground())
1086 holding_something = true;
1087 ptramp_c->mode = Trampoline::M_HELD;
1088 ptramp_c->base.y -= 8;
1090 // Set down trampoline
1091 else if (ptramp_c->mode == Trampoline::M_HELD && input.fire != DOWN)
1093 holding_something = false;
1094 ptramp_c->mode = Trampoline::M_NORMAL;
1095 ptramp_c->base.y += 8;
1096 ptramp_c->physic.set_velocity(physic.get_velocity_x(), physic.get_velocity_y());
1099 // ptramp_c->base.x = base.x + base.width+1;
1101 // ptramp_c->base.x = base.x - base.width-1;
1104 // Don't let tux walk through trampoline
1105 else if (ptramp_c->mode != Trampoline::M_HELD && on_ground())
1107 if (physic.get_velocity_x() > 0) // RIGHT
1109 physic.set_velocity_x(0);
1110 base.x = ptramp_c->base.x - base.width;
1112 else if (physic.get_velocity_x() < 0) // LEFT
1114 physic.set_velocity_x(0);
1115 base.x = ptramp_c->base.x + ptramp_c->base.width;
1120 case CO_FLYING_PLATFORM:
1121 pplatform_c = (FlyingPlatform*) p_c_object;
1123 base.y = pplatform_c->base.y - base.height;
1124 physic.set_velocity_x(pplatform_c->get_vel_x());
1126 physic.enable_gravity(false);
1128 fall_mode = ON_GROUND;
1139 Player::make_invincible()
1141 SoundManager::get()->play_sound(IDToSound(SND_HERRING));
1142 invincible_timer.start(TUX_INVINCIBLE_TIME);
1143 Sector::current()->play_music(HERRING_MUSIC);
1148 Player::kill(HurtMode mode)
1153 if(safe_timer.get_timeleft() > 0 || invincible_timer.get_timeleft() > 0)
1156 SoundManager::get()->play_sound(IDToSound(SND_HURT));
1158 physic.set_velocity_x(0);
1160 if (mode == SHRINK && size == BIG)
1162 if (got_power != NONE_POWER)
1164 safe_timer.start(TUX_SAFE_TIME);
1165 got_power = NONE_POWER;
1169 growing_timer.start(GROWING_TIME);
1170 safe_timer.start(TUX_SAFE_TIME + GROWING_TIME);
1172 bbox.set_height(32);
1178 physic.enable_gravity(true);
1179 physic.set_acceleration(0, 0);
1180 physic.set_velocity(0, 700);
1181 --player_status.lives;
1182 dying = DYING_SQUISHED;
1183 dying_timer.start(3.0);
1187 /* Remove Tux's power ups */
1189 Player::remove_powerups()
1191 got_power = NONE_POWER;
1193 bbox.set_height(32);
1197 Player::move(const Vector& vector)
1199 bbox.set_pos(vector);
1203 Player::check_bounds(Camera* camera)
1205 /* Keep tux in bounds: */
1206 if (get_pos().x < 0)
1207 { // Lock Tux to the size of the level, so that he doesn't fall of
1209 bbox.set_pos(Vector(0, get_pos().y));
1212 /* Keep in-bounds, vertically: */
1213 if (get_pos().y > Sector::current()->solids->get_height() * 32)
1219 bool adjust = false;
1220 // can happen if back scrolling is disabled
1221 if(get_pos().x < camera->get_translation().x) {
1222 bbox.set_pos(Vector(camera->get_translation().x, get_pos().y));
1225 if(get_pos().x >= camera->get_translation().x + screen->w - bbox.get_width())
1227 bbox.set_pos(Vector(
1228 camera->get_translation().x + screen->w - bbox.get_width(),
1237 if(collision_object_map(bbox)) {
1246 Player::bounce(BadGuy& badguy)
1248 //Make sure we stopped flapping
1250 falling_from_flap = false;
1253 physic.set_velocity_y(520);
1255 physic.set_velocity_y(200);