X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fplayer.cpp;h=a049774fc1a79fb78168487a970641ff918e6b59;hb=3369ed08e4b7126af560dc5f9c3442fc76b43ab4;hp=655911dd32d83ae678683d5182d5ad6d77ae8368;hpb=aea1b715f22599f5e202693cb93a0852704d6422;p=supertux.git diff --git a/src/player.cpp b/src/player.cpp index 655911dd3..a049774fc 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -39,16 +39,19 @@ #define TILES_FOR_BUTTJUMP 3 // animation times (in ms): #define SHOOTING_TIME 320 +#define STOMP_TIME 250 // others stuff: #define AUTOSCROLL_DEAD_INTERVAL 300 +// growing animation +Surface* growingtux_left[GROWING_FRAMES]; +Surface* growingtux_right[GROWING_FRAMES]; + Surface* tux_life; Sprite* smalltux_gameover; Sprite* smalltux_star; Sprite* largetux_star; -Sprite* growingtux_left; -Sprite* growingtux_right; PlayerSprite smalltux; PlayerSprite largetux; @@ -116,7 +119,7 @@ Player::init() frame_main = 0; frame_ = 0; - + player_input_init(&input); invincible_timer.init(true); @@ -494,7 +497,7 @@ Player::handle_vertical_input() /* In case the player has pressed Down while in a certain range of air, enable butt jump action */ - if (input.down == DOWN && !butt_jump) + if (input.down == DOWN && !butt_jump && !duck) if(tiles_on_air(TILES_FOR_BUTTJUMP) && jumping) butt_jump = true; @@ -505,6 +508,7 @@ Player::handle_vertical_input() // Do butt jump if (butt_jump && on_ground() && size == BIG) { + stomp_timer.start(STOMP_TIME); butt_jump = false; // Break bricks beneath Tux @@ -526,8 +530,9 @@ Player::handle_vertical_input() BadGuy* badguy = dynamic_cast (*i); if(badguy) { - if (fabsf(base.x - badguy->base.x) < 300 && - fabsf(base.y - badguy->base.y) < 300 && + + if (fabsf(base.x - badguy->base.x) < 150 && + fabsf(base.y - badguy->base.y) < 60 && (issolid(badguy->base.x + 1, badguy->base.y + badguy->base.height) || issolid(badguy->base.x + badguy->base.width - 1, badguy->base.y + badguy->base.height))) badguy->kill_me(25); @@ -633,7 +638,7 @@ Player::grow(bool animate) base.y -= 32; if(animate) - growing_timer.start((int)((growingtux_left->get_frames() / growingtux_left->get_fps()) * 1000)); + growing_timer.start(GROWING_TIME); old_base = previous_base = base; } @@ -694,16 +699,16 @@ Player::draw(DrawingContext& context) { if (dying == DYING_SQUISHED) { - smalltux_gameover->draw(context, pos, LAYER_OBJECTS); + smalltux_gameover->draw(context, pos, LAYER_OBJECTS+1); } else { if(growing_timer.check()) { if (dir == RIGHT) - growingtux_right->draw(context, pos, layer); + context.draw_surface(growingtux_right[(growing_timer.get_gone() * GROWING_FRAMES) / GROWING_TIME], pos, layer); else - growingtux_left->draw(context, pos, layer); + context.draw_surface(growingtux_left[(growing_timer.get_gone() * GROWING_FRAMES) / GROWING_TIME], pos, layer); } else if (duck && size != SMALL) { @@ -761,6 +766,13 @@ Player::draw(DrawingContext& context) else sprite->grab_left->draw(context, pos, LAYER_OBJECTS + 1); } + + // Draw stomp clouds when doing a butt jump + if (stomp_timer.check()) + if (duck) + sprite->stomp->draw(context, Vector(base.x - 32, base.y), LAYER_OBJECTS + 1); + else + sprite->stomp->draw(context, Vector(base.x - 32, base.y + 32), LAYER_OBJECTS + 1); // Draw blinking star overlay if (invincible_timer.started() &&