From: LMH Date: Thu, 27 Nov 2014 03:18:20 +0000 (-1000) Subject: Minimal code for earthflower active ability. X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=e621c95d8cbb782c7febc17c5422a307d2a41f7d;p=supertux.git Minimal code for earthflower active ability. To activate stone form, press DOWN while holding the ACTION key. Player does not take damage while in stone form, and ability can be use offensively to crush enemies- including those that cannot be squished. Still needs timers set up to limit the ability, and a ton of sprite work. --- diff --git a/src/badguy/badguy.cpp b/src/badguy/badguy.cpp index 8b85567ab..609b3522c 100644 --- a/src/badguy/badguy.cpp +++ b/src/badguy/badguy.cpp @@ -272,11 +272,20 @@ BadGuy::collision(GameObject& other, const CollisionHit& hit) // hit from above? if (player->get_bbox().p2.y < (bbox.p1.y + 16)) { + if(player->is_stone()) { + kill_fall(); + return FORCE_MOVE; + } if(collision_squished(*player)) { return FORCE_MOVE; } } + if(player->is_stone()) { + collision_solid(hit); + return FORCE_MOVE; + } + return collision_player(*player, hit); } diff --git a/src/object/player.cpp b/src/object/player.cpp index 376cdcf91..5c390d5f5 100644 --- a/src/object/player.cpp +++ b/src/object/player.cpp @@ -743,8 +743,8 @@ Player::handle_vertical_input() } } } - /*ability_timer.started() ? gliding = true : ability_timer.start(player_status->max_air_time);*/ - //} + + // Let go of jump key else if(!controller->hold(Controller::JUMP)) { if (!backflipping && jumping && physic.get_velocity_y() < 0) { @@ -819,14 +819,14 @@ Player::handle_input() } /* Handle horizontal movement: */ - if (!backflipping) handle_horizontal_input(); + if (!backflipping && !stone) handle_horizontal_input(); /* Jump/jumping? */ if (on_ground()) can_jump = true; /* Handle vertical movement: */ - handle_vertical_input(); + if (!stone) handle_vertical_input(); /* Shoot! */ if (controller->pressed(Controller::ACTION) && (player_status->bonus == FIRE_BONUS || player_status->bonus == ICE_BONUS)) { @@ -844,8 +844,23 @@ 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; + stone = true; + } + } + + if (stone) + apply_friction(); + + /* Revert from Stone */ + if (stone && !controller->hold(Controller::ACTION)) + stone = false; + /* Duck or Standup! */ - if (controller->hold(Controller::DOWN)) { + if (controller->hold(Controller::DOWN) && !stone) { do_duck(); } else { do_standup(); @@ -1352,6 +1367,8 @@ Player::collision(GameObject& other, const CollisionHit& hit) if(badguy != NULL) { if(safe_timer.started() || invincible_timer.started()) return FORCE_MOVE; + if(stone) + return ABORT_MOVE; return CONTINUE; } @@ -1374,7 +1391,7 @@ Player::kill(bool completely) if(dying || deactivated || is_winning() ) return; - if(!completely && (safe_timer.started() || invincible_timer.started())) + if(!completely && (safe_timer.started() || invincible_timer.started() || stone)) return; growing = false; diff --git a/src/object/player.hpp b/src/object/player.hpp index 3de1abddc..2a5b9773d 100644 --- a/src/object/player.hpp +++ b/src/object/player.hpp @@ -180,6 +180,8 @@ public: bool is_dead() const { return dead; } bool is_big(); + bool is_stone() + { return stone; } void set_visible(bool visible); bool get_visible();