From: LMH Date: Sat, 29 Nov 2014 02:27:44 +0000 (-1000) Subject: Finished up code for basic functionality of earthflower powerup. X-Git-Url: https://git.octo.it/?p=supertux.git;a=commitdiff_plain;h=01855433649374b48523f5eb7e6cf204391c36ca Finished up code for basic functionality of earthflower powerup. --- diff --git a/data/images/creatures/tux/earth/light/stand.png b/data/images/creatures/tux/earth/light/stand.png new file mode 100644 index 000000000..9f2e8779c Binary files /dev/null and b/data/images/creatures/tux/earth/light/stand.png differ diff --git a/data/images/creatures/tux/earth/stand.png b/data/images/creatures/tux/earth/stand.png new file mode 100644 index 000000000..0d7083f28 Binary files /dev/null and b/data/images/creatures/tux/earth/stand.png differ diff --git a/data/images/creatures/tux/light.sprite b/data/images/creatures/tux/light.sprite new file mode 100644 index 000000000..6e83f1eab --- /dev/null +++ b/data/images/creatures/tux/light.sprite @@ -0,0 +1,105 @@ +(supertux-sprite + +; Earth Tux + + (action + (name "earth-walk-right") + (hitbox 412 154 32 64) + (images "earth/light/stand.png")) + + (action + (name "earth-walk-left") + (hitbox 412 154 32 64) + (mirror-action "earth-walk-right")) + + (action + (name "earth-stand-right") + (hitbox 412 154 32 64) + (images "earth/light/stand.png")) + + (action + (name "earth-stand-left") + (hitbox 412 154 32 64) + (mirror-action "earth-stand-right")) + + (action + (name "earth-jump-right") + (hitbox 412 154 32 64) + (images "earth/light/stand.png")) + + (action + (name "earth-jump-left") + (hitbox 412 154 32 64) + (mirror-action "earth-jump-right")) + + (action + (name "earth-skid-right") + (hitbox 412 154 32 64) + (images "earth/light/stand.png")) + + (action + (name "earth-skid-left") + (hitbox 412 154 32 64) + (mirror-action "earth-skid-right")) + + (action + (name "earth-kick-right") + (hitbox 412 154 32 64) + (images "earth/light/stand.png")) + + (action + (name "earth-kick-left") + (hitbox 412 154 32 64) + (mirror-action "earth-kick-right")) + + (action + (name "earth-idle-right") + (hitbox 412 154 32 64) + (images "earth/light/stand.png")) + + (action + (name "earth-idle-left") + (hitbox 412 154 32 64) + (mirror-action "earth-idle-right")) + + (action + (name "earth-climbing-right") + (hitbox 412 154 32 64) + (images "earth/light/stand.png")) + + (action + (name "earth-climbing-left") + (hitbox 412 154 32 64) + (mirror-action "earth-climbing-right")) + + (action + (name "earth-duck-right") + (hitbox 412 154 32 64) + (images "earth/light/stand.png")) + + (action + (name "earth-duck-left") + (hitbox 412 154 32 64) + (mirror-action "earth-duck-right")) + + (action + (name "earth-backflip-right") + (hitbox 412 154 32 64) + (images "earth/light/stand.png")) + + (action + (name "earth-backflip-left") + (hitbox 412 154 32 64) + (mirror-action "earth-backflip-right")) + + (action + (name "earth-buttjump-right") + (hitbox 412 154 32 64) + (images "earth/light/stand.png")) + + (action + (name "earth-buttjump-left") + (hitbox 412 154 32 64) + (mirror-action "earth-buttjump-right")) + +) diff --git a/data/images/creatures/tux/powerups.sprite b/data/images/creatures/tux/powerups.sprite new file mode 100644 index 000000000..5ca1c4778 --- /dev/null +++ b/data/images/creatures/tux/powerups.sprite @@ -0,0 +1,105 @@ +(supertux-sprite + +; Earth Tux + + (action + (name "earth-walk-right") + (hitbox 16 14 32 64) + (images "earth/hardhat/stand.png")) + + (action + (name "earth-walk-left") + (hitbox 16 14 32 64) + (mirror-action "earth-walk-right")) + + (action + (name "earth-stand-right") + (hitbox 16 14 32 64) + (images "earth/hardhat/stand.png")) + + (action + (name "earth-stand-left") + (hitbox 16 14 32 64) + (mirror-action "earth-stand-right")) + + (action + (name "earth-jump-right") + (hitbox 16 14 32 64) + (images "earth/hardhat/stand.png")) + + (action + (name "earth-jump-left") + (hitbox 16 14 32 64) + (mirror-action "earth-jump-right")) + + (action + (name "earth-skid-right") + (hitbox 16 14 32 64) + (images "earth/hardhat/stand.png")) + + (action + (name "earth-skid-left") + (hitbox 16 14 32 64) + (mirror-action "earth-skid-right")) + + (action + (name "earth-kick-right") + (hitbox 16 14 32 64) + (images "earth/hardhat/stand.png")) + + (action + (name "earth-kick-left") + (hitbox 16 14 32 64) + (mirror-action "earth-kick-right")) + + (action + (name "earth-idle-right") + (hitbox 16 14 32 64) + (images "earth/hardhat/stand.png")) + + (action + (name "earth-idle-left") + (hitbox 16 14 32 64) + (mirror-action "earth-idle-right")) + + (action + (name "earth-climbing-right") + (hitbox 16 14 32 64) + (images "earth/hardhat/stand.png")) + + (action + (name "earth-climbing-left") + (hitbox 16 14 32 64) + (mirror-action "earth-climbing-right")) + + (action + (name "earth-duck-right") + (hitbox 16 14 32 64) + (images "earth/hardhat/stand.png")) + + (action + (name "earth-duck-left") + (hitbox 16 14 32 64) + (mirror-action "earth-duck-right")) + + (action + (name "earth-backflip-right") + (hitbox 16 14 32 64) + (images "earth/hardhat/stand.png")) + + (action + (name "earth-backflip-left") + (hitbox 16 14 32 64) + (mirror-action "earth-backflip-right")) + + (action + (name "earth-buttjump-right") + (hitbox 16 14 32 64) + (images "earth/hardhat/stand.png")) + + (action + (name "earth-buttjump-left") + (hitbox 16 14 32 64) + (mirror-action "earth-buttjump-right")) + +) diff --git a/data/images/creatures/tux/tux.sprite b/data/images/creatures/tux/tux.sprite index 0f154ba56..742e71edf 100644 --- a/data/images/creatures/tux/tux.sprite +++ b/data/images/creatures/tux/tux.sprite @@ -485,4 +485,236 @@ (hitbox 16 14 32 64) (mirror-action "ice-buttjump-right")) +; Earth Tux + + (action + (name "earth-walk-right") + (fps 15.0) + (hitbox 16 14 32 64) + (images "big/walk-0.png" + "big/walk-1.png" + "big/walk-2.png" + "big/walk-3.png" + "big/walk-4.png" + "big/walk-5.png")) + + (action + (name "earth-walk-left") + (fps 15.0) + (hitbox 16 14 32 64) + (mirror-action "earth-walk-right")) + + (action + (name "earth-stand-right") + (fps 15.0) + (hitbox 16 14 32 64) + (images "big/stand-0.png")) + + (action + (name "earth-stand-left") + (fps 15.0) + (hitbox 16 14 32 64) + (mirror-action "earth-stand-right")) + + (action + (name "earth-jump-right") + (fps 15.0) + (hitbox 16 14 32 64) + (images "big/jump-0.png")) + + (action + (name "earth-jump-left") + (fps 15.0) + (hitbox 16 14 32 64) + (mirror-action "earth-jump-right")) + + (action + (name "earth-skid-right") + (hitbox 16 14 32 64) + (images "big/skid-0.png")) + + (action + (name "earth-skid-left") + (hitbox 16 14 32 64) + (mirror-action "earth-skid-right")) + + (action + (name "earth-kick-right") + (hitbox 16 14 32 64) + (images "big/kick-0.png")) + + (action + (name "earth-kick-left") + (hitbox 16 14 32 64) + (mirror-action "earth-kick-right")) + + (action + (name "earth-idle-right") + (fps 5.0) + (hitbox 16 14 32 64) + (images "big/idle-0.png" + "big/idle-1.png" + "big/idle-0.png")) + + (action + (name "earth-idle-left") + (hitbox 16 14 32 64) + (mirror-action "earth-idle-right")) + + (action + (name "earth-climbing-right") + (hitbox 16 14 32 64) + (images "big/ladder-0.png" + "big/ladder-1.png" + "big/ladder-2.png" + "big/ladder-3.png" + "big/ladder-2.png" + "big/ladder-1.png")) + + (action + (name "earth-climbing-left") + (hitbox 16 14 32 64) + (mirror-action "earth-climbing-right")) + + (action + (name "earth-duck-right") + (hitbox 16 45 32 32) + (images "big/duck-0.png")) + + (action + (name "earth-duck-left") + (hitbox 16 45 32 32) + (mirror-action "earth-duck-right")) + + (action + (name "earth-backflip-right") + (hitbox 16 37 32 32) + (images "big/backflip.png")) + + (action + (name "earth-backflip-left") + (hitbox 16 37 32 32) + (fps 18.0) + (mirror-action "earth-backflip-right")) + + (action + (name "earth-buttjump-right") + (hitbox 16 14 32 64) + (images "big/buttjump-0.png")) + + (action + (name "earth-buttjump-left") + (hitbox 16 14 32 64) + (mirror-action "earth-buttjump-right")) + +; Stone Tux + + (action + (name "earth-walk-right-stone") + (fps 15.0) + (hitbox 16 14 32 64) + (images "earth/stand.png")) + + (action + (name "earth-walk-left-stone") + (fps 15.0) + (hitbox 16 14 32 64) + (mirror-action "earth-walk-right-stone")) + + (action + (name "earth-stand-right-stone") + (fps 15.0) + (hitbox 16 14 32 64) + (images "earth/stand.png")) + + (action + (name "earth-stand-left-stone") + (fps 15.0) + (hitbox 16 14 32 64) + (mirror-action "earth-stand-right-stone")) + + (action + (name "earth-jump-right-stone") + (fps 15.0) + (hitbox 16 14 32 64) + (images "earth/stand.png")) + + (action + (name "earth-jump-left-stone") + (fps 15.0) + (hitbox 16 14 32 64) + (mirror-action "earth-jump-right-stone")) + + (action + (name "earth-skid-right-stone") + (hitbox 16 14 32 64) + (images "earth/stand.png")) + + (action + (name "earth-skid-left-stone") + (hitbox 16 14 32 64) + (mirror-action "earth-skid-right-stone")) + + (action + (name "earth-kick-right-stone") + (hitbox 16 14 32 64) + (images "earth/stand.png")) + + (action + (name "earth-kick-left-stone") + (hitbox 16 14 32 64) + (mirror-action "earth-kick-right-stone")) + + (action + (name "earth-idle-right-stone") + (fps 5.0) + (hitbox 16 14 32 64) + (images "earth/stand.png")) + + (action + (name "earth-idle-left-stone") + (hitbox 16 14 32 64) + (mirror-action "earth-idle-right-stone")) + + (action + (name "earth-climbing-right-stone") + (hitbox 16 14 32 64) + (images "earth/stand.png")) + + (action + (name "earth-climbing-left-stone") + (hitbox 16 14 32 64) + (mirror-action "earth-climbing-right-stone")) + + (action + (name "earth-duck-right-stone") + (hitbox 16 45 32 32) + (images "earth/stand.png")) + + (action + (name "earth-duck-left-stone") + (hitbox 16 45 32 32) + (mirror-action "earth-duck-right-stone")) + + (action + (name "earth-backflip-right-stone") + (hitbox 16 37 32 32) + (images "earth/stand.png")) + + (action + (name "earth-backflip-left-stone") + (hitbox 16 37 32 32) + (fps 18.0) + (mirror-action "earth-backflip-right-stone")) + + (action + (name "earth-buttjump-right-stone") + (hitbox 16 14 32 64) + (images "earth/stand.png")) + + (action + (name "earth-buttjump-left-stone") + (hitbox 16 14 32 64) + (mirror-action "earth-buttjump-right-stone")) + ) diff --git a/data/images/objects/particles/airtux-hat.sprite b/data/images/objects/particles/airtux-hat.sprite new file mode 100644 index 000000000..772fc3e7f --- /dev/null +++ b/data/images/objects/particles/airtux-hat.sprite @@ -0,0 +1,14 @@ +(supertux-sprite + (action + (name "right") + (fps 1) + (images + "icetux-cap.png" + ) + ) + (action + (name "left") + (fps 1) + (mirror-action "right") + ) +) diff --git a/data/images/objects/particles/earthtux-hardhat.png b/data/images/objects/particles/earthtux-hardhat.png new file mode 100644 index 000000000..fc20b1dbe Binary files /dev/null and b/data/images/objects/particles/earthtux-hardhat.png differ diff --git a/data/images/objects/particles/earthtux-hardhat.sprite b/data/images/objects/particles/earthtux-hardhat.sprite new file mode 100644 index 000000000..0d3a75954 --- /dev/null +++ b/data/images/objects/particles/earthtux-hardhat.sprite @@ -0,0 +1,12 @@ +(supertux-sprite + (action + (name "right") + (fps 1) + (images "earthtux-hardhat.png") + ) + (action + (name "left") + (fps 1) + (mirror-action "right") + ) +) diff --git a/src/object/player.cpp b/src/object/player.cpp index 5c390d5f5..ef5b489da 100644 --- a/src/object/player.cpp +++ b/src/object/player.cpp @@ -43,6 +43,7 @@ namespace { static const float BUTTJUMP_MIN_VELOCITY_Y = 400.0f; static const float SHOOTING_TIME = .150f; static const float GLIDE_TIME_PER_FLOWER = 0.5f; +static const float STONE_TIME_PER_FLOWER = 2.0f; /** number of idle stages, including standing */ static const unsigned int IDLE_STAGE_COUNT = 5; @@ -124,7 +125,7 @@ Player::Player(PlayerStatus* _player_status, const std::string& name_) : backflip_direction(), peekingX(), peekingY(), - glide_time(), + ability_time(), stone(), swimming(), speedlimit(), @@ -132,7 +133,8 @@ Player::Player(PlayerStatus* _player_status, const std::string& name_) : jump_early_apex(), on_ice(), ice_this_frame(), - lightsprite(SpriteManager::current()->create("images/objects/lightmap_light/lightmap_light-tiny.sprite")), + lightsprite(SpriteManager::current()->create("images/creatures/tux/light.sprite")), + powersprite(SpriteManager::current()->create("images/creatures/tux/powerups.sprite")), dir(), old_dir(), last_ground_y(), @@ -223,7 +225,7 @@ Player::init() backflip_direction = 0; sprite->set_angle(0.0f); visible = true; - glide_time = 0; + ability_time = 0; stone = false; swimming = false; on_ice = false; @@ -412,7 +414,7 @@ Player::update(float elapsed_time) do_standup(); } if (player_status->bonus == AIR_BONUS) - glide_time = player_status->max_air_time * GLIDE_TIME_PER_FLOWER; + ability_time = player_status->max_air_time * GLIDE_TIME_PER_FLOWER; } // calculate movement for this frame @@ -730,12 +732,12 @@ Player::handle_vertical_input() } // airflower glide only when holding jump key } else if (controller->hold(Controller::JUMP) && player_status->bonus == AIR_BONUS && physic.get_velocity_y() > MAX_GLIDE_YM) { - if (glide_time > 0 && !ability_timer.started()) - ability_timer.start(glide_time); + if (ability_time > 0 && !ability_timer.started()) + ability_timer.start(ability_time); else if (ability_timer.started()) { // glide stops after some duration or if buttjump is initiated if ((ability_timer.get_timeleft() <= 0.05f) || controller->hold(Controller::DOWN)) { - glide_time = 0; + ability_time = 0; ability_timer.stop(); } else { physic.set_velocity_y(MAX_GLIDE_YM); @@ -752,7 +754,7 @@ Player::handle_vertical_input() early_jump_apex(); } if (player_status->bonus == AIR_BONUS && ability_timer.started()){ - glide_time = ability_timer.get_timeleft(); + ability_time = ability_timer.get_timeleft(); ability_timer.stop(); } } @@ -845,10 +847,11 @@ Player::handle_input() } /* Turn to Stone */ - if (controller->pressed(Controller::DOWN) && player_status->bonus == EARTH_BONUS) { - if (controller->hold(Controller::ACTION)) { - jump_early_apex = false; + if (controller->pressed(Controller::DOWN) && player_status->bonus == EARTH_BONUS && !cooldown_timer.started()) { + if (controller->hold(Controller::ACTION) && !ability_timer.started()) { + ability_timer.start(player_status->max_earth_time * STONE_TIME_PER_FLOWER); stone = true; + physic.set_gravity_modifier(1.0f); // Undo jump_early_apex } } @@ -856,8 +859,20 @@ Player::handle_input() apply_friction(); /* Revert from Stone */ - if (stone && !controller->hold(Controller::ACTION)) + if (stone && (!controller->hold(Controller::ACTION) || ability_timer.get_timeleft() <= 0.5f)) { + cooldown_timer.start(ability_timer.get_timegone()/2.0f); //The longer stone form is used, the longer until it can be used again + ability_timer.stop(); stone = false; + for (int i = 0; i < 8; i++) + { + Vector ppos = Vector(get_bbox().get_left() + 8 + 16*((int)i/4), get_bbox().get_top() + 16*(i%4)); + float grey = graphicsRandom.randf(.4f, .8f); + Color pcolor = Color(grey, grey, grey); + Sector::current()->add_object(std::make_shared(ppos, -60, 240, 42, 81, Vector(0, 500), + 8, pcolor, 4 + graphicsRandom.randf(-0.4, 0.4), + 0.8 + graphicsRandom.randf(0, 0.4), LAYER_OBJECTS+2)); + } + } /* Duck or Standup! */ if (controller->hold(Controller::DOWN) && !stone) { @@ -1088,7 +1103,7 @@ Player::set_bonus(BonusType type, bool animate) Vector pspeed = Vector(((dir==LEFT) ? +100 : -100), -300); Vector paccel = Vector(0, 1000); std::string action = (dir==LEFT)?"left":"right"; - Sector::current()->add_object(std::make_shared("images/objects/particles/icetux-cap.sprite", action, ppos, ANCHOR_TOP, pspeed, paccel, LAYER_OBJECTS-1)); + Sector::current()->add_object(std::make_shared("images/objects/particles/airtux-hat.sprite", action, ppos, ANCHOR_TOP, pspeed, paccel, LAYER_OBJECTS-1)); if (climbing) stop_climbing(*climbing); } if ((player_status->bonus == EARTH_BONUS) && (animate)) { @@ -1097,7 +1112,7 @@ Player::set_bonus(BonusType type, bool animate) Vector pspeed = Vector(((dir==LEFT) ? +100 : -100), -300); Vector paccel = Vector(0, 1000); std::string action = (dir==LEFT)?"left":"right"; - Sector::current()->add_object(std::make_shared("images/objects/particles/firetux-helmet.sprite", action, ppos, ANCHOR_TOP, pspeed, paccel, LAYER_OBJECTS-1)); + Sector::current()->add_object(std::make_shared("images/objects/particles/earthtux-hardhat.sprite", action, ppos, ANCHOR_TOP, pspeed, paccel, LAYER_OBJECTS-1)); if (climbing) stop_climbing(*climbing); } player_status->max_fire_bullets = 0; @@ -1162,7 +1177,7 @@ Player::draw(DrawingContext& context) else if (player_status->bonus == AIR_BONUS) sa_prefix = "ice"; else if (player_status->bonus == EARTH_BONUS) - sa_prefix = "fire"; + sa_prefix = "earth"; else sa_prefix = "small"; @@ -1181,6 +1196,9 @@ Player::draw(DrawingContext& context) // do_duck() will take care of cancelling growing manually // update() will take care of cancelling when growing completed } + else if (stone) { + sprite->set_action(sprite->get_action()+"-stone"); + } else if (climbing) { sprite->set_action(sa_prefix+"-climbing"+sa_postfix); } @@ -1234,6 +1252,12 @@ Player::draw(DrawingContext& context) } } + /* Set Tux powerup sprite action */ + if (player_status->bonus == EARTH_BONUS) { + powersprite->set_action(sprite->get_action()); + lightsprite->set_action(sprite->get_action()); + } + /* // Tux is holding something if ((grabbed_object != 0 && physic.get_velocity_y() == 0) || @@ -1247,16 +1271,29 @@ Player::draw(DrawingContext& context) /* Draw Tux */ if (safe_timer.started() && size_t(game_time*40)%2) ; // don't draw Tux - else { - sprite->draw(context, get_pos(), LAYER_OBJECTS + 1); - // draw light with earthflower bonus - if (player_status->bonus == EARTH_BONUS){ - context.push_target(); - context.set_target(DrawingContext::LIGHTMAP); - lightsprite->draw(context, get_pos() + Vector(dir==LEFT ? 0 : 32, 0), 0); - context.pop_target(); + else if (player_status->bonus == EARTH_BONUS){ // draw special effects with earthflower bonus + // shake at end of maximum stone duration + Vector shake_delta = (stone && ability_timer.get_timeleft() < 1.0f) ? Vector(graphicsRandom.rand(-3,3), 0) : Vector(0,0); + sprite->draw(context, get_pos() + shake_delta, LAYER_OBJECTS + 1); + // draw hardhat + powersprite->draw(context, get_pos(), LAYER_OBJECTS + 1); + // light + context.push_target(); + context.set_target(DrawingContext::LIGHTMAP); + lightsprite->draw(context, get_pos()/* + Vector(dir==LEFT ? 0 : 32, 0)*/, 0); + context.pop_target(); + // give an indicator that stone form cannot be used for a while + if (cooldown_timer.started() && graphicsRandom.rand(0, 4) == 0) { + float px = graphicsRandom.randf(bbox.p1.x, bbox.p2.x); + float py = bbox.p2.y+8; + Vector ppos = Vector(px, py); + Sector::current()->add_object(std::make_shared( + "images/objects/particles/sparkle.sprite", "dark", + ppos, ANCHOR_MIDDLE, Vector(0, 0), Vector(0, 0), LAYER_OBJECTS+1+5)); } } + else + sprite->draw(context, get_pos(), LAYER_OBJECTS + 1); } @@ -1538,7 +1575,7 @@ Player::bounce(BadGuy& ) physic.set_velocity_y(controller->hold(Controller::JUMP) ? -520 : -300); else { physic.set_velocity_y(controller->hold(Controller::JUMP) ? -580 : -340); - glide_time = player_status->max_air_time * GLIDE_TIME_PER_FLOWER; + ability_time = player_status->max_air_time * GLIDE_TIME_PER_FLOWER; } } diff --git a/src/object/player.hpp b/src/object/player.hpp index 2a5b9773d..4d178aa0c 100644 --- a/src/object/player.hpp +++ b/src/object/player.hpp @@ -276,7 +276,7 @@ private: int backflip_direction; Direction peekingX; Direction peekingY; - float glide_time; + float ability_time; bool stone; bool swimming; float speedlimit; @@ -285,6 +285,7 @@ private: bool on_ice; bool ice_this_frame; SpritePtr lightsprite; + SpritePtr powersprite; public: Direction dir;