X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fplayer.cpp;h=cf945e4fc87cd5783d56908a756d3d86bad3be05;hb=ee6972038331a3c26a2a6a0bdb2baca25475b1d2;hp=edbdce81b48d823cbe3a4eccbfc1ed75ea35bef1;hpb=1d4f04476ae2c9e1530e48bb8881955d4a9d7238;p=supertux.git diff --git a/src/player.cpp b/src/player.cpp index edbdce81b..cf945e4fc 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -73,7 +73,7 @@ PlayerKeymap::PlayerKeymap() keymap.right = SDLK_RIGHT; keymap.power = SDLK_LCTRL; - keymap.jump = SDLK_LALT; + keymap.jump = SDLK_SPACE; } void player_input_init(player_input_type* pplayer_input) @@ -91,29 +91,16 @@ void player_input_init(player_input_type* pplayer_input) } void -TuxBodyParts::set_action(std::string action) +TuxBodyParts::set_action(std::string action, int loops) { if(head != NULL) - head->set_action(action); + head->set_action(action, loops); if(body != NULL) - body->set_action(action); + body->set_action(action, loops); if(arms != NULL) - arms->set_action(action); + arms->set_action(action, loops); if(feet != NULL) - feet->set_action(action); -} - -void -TuxBodyParts::one_time_animation() -{ - if(head != NULL) - head->start_animation(1); - if(body != NULL) - body->start_animation(1); - if(arms != NULL) - arms->start_animation(1); - if(feet != NULL) - feet->start_animation(1); + feet->set_action(action, loops); } void @@ -728,7 +715,7 @@ Player::draw(DrawingContext& context) else tux_body = big_tux; - int layer = LAYER_OBJECTS - 1; + int layer = LAYER_OBJECTS + 10; /* Set Tux sprite action */ if (duck && size == BIG) @@ -789,11 +776,9 @@ Player::draw(DrawingContext& context) if(size == BIG) { if(dir == LEFT) - tux_body->head->set_action("idle-left"); + tux_body->head->set_action("idle-left", 1); else // dir == RIGHT - tux_body->head->set_action("idle-right"); - - tux_body->head->start_animation(1); + tux_body->head->set_action("idle-right", 1); } } @@ -846,7 +831,7 @@ Player::draw(DrawingContext& context) get_pos(), layer); } } - else if (safe_timer.started() && global_frame_counter%2) + else if (safe_timer.started() && size_t(global_time*40)%2) ; // don't draw Tux else tux_body->draw(context, get_pos(), layer); @@ -854,19 +839,19 @@ Player::draw(DrawingContext& context) // Draw blinking star overlay if (invincible_timer.started() && (invincible_timer.get_timeleft() > TUX_INVINCIBLE_TIME_WARNING - || global_frame_counter % 3) + || size_t(global_time*20)%2) && !dying) { if (size == SMALL || duck) - smalltux_star->draw(context, get_pos(), LAYER_OBJECTS + 2); + smalltux_star->draw(context, get_pos(), layer + 5); else - bigtux_star->draw(context, get_pos(), LAYER_OBJECTS + 2); + bigtux_star->draw(context, get_pos(), layer + 5); } if (debug_mode) context.draw_filled_rect(get_pos(), Vector(bbox.get_width(), bbox.get_height()), - Color(75,75,75, 150), LAYER_OBJECTS+1); + Color(75,75,75, 150), LAYER_OBJECTS+20); } HitResponse @@ -882,12 +867,11 @@ Player::collision(GameObject& other, const CollisionHit& hit) physic.set_velocity_y(0); on_ground_flag = true; } else if(hit.normal.y > 0) { // bumped against the roof - physic.set_velocity_y(0); + physic.set_velocity_y(.1); } - if(hit.normal.x != 0) { // hit on the side? - if(hit.normal.y > 0.6) // limits the slopes we can move up... - physic.set_velocity_x(0); + if(fabsf(hit.normal.x) > .9) { // hit on the side? + physic.set_velocity_x(0); } return CONTINUE; @@ -948,6 +932,7 @@ Player::kill(HurtMode mode) --player_status.lives; dying = DYING_SQUISHED; dying_timer.start(3.0); + flags |= FLAG_NO_COLLDET; } } @@ -1010,7 +995,7 @@ Player::check_bounds(Camera* camera) } void -Player::bounce(BadGuy& badguy) +Player::bounce(BadGuy& ) { //Make sure we stopped flapping flapping = false;