From: LMH Date: Sat, 15 Nov 2014 20:34:59 +0000 (-1000) Subject: Completed airflower powerup abilities. X-Git-Url: https://git.octo.it/?p=supertux.git;a=commitdiff_plain;h=af6086c5e53fd3b38921ff584abe3b621a2aa9f3 Completed airflower powerup abilities. Airflower is meant to be a powerup geared to speed runs and sky levels. It makes Tux light on his feet, with a passive ability of faster max run speed and greater attainable jump height. In addition, airflower has an active ability which allows Tux to glide for a short period of time after jumping. The duration that Tux can glide increases with additional airflower powerups. To glide, the user only needs to hold the jump key while falling. Every time the player jumps they may glide for a set amount of time which is reset upon Tux touching the ground. Tux sprites still need to be done, and it may be worth considering replacing the backflip with a launching jump when Tux has this powerup. Of course tweaks to the values used will also likely be needed. --- diff --git a/WHATSNEW.txt b/WHATSNEW.txt index a742979a6..2e6006130 100644 --- a/WHATSNEW.txt +++ b/WHATSNEW.txt @@ -14,6 +14,7 @@ move to SDL2 menus reworked addon manager improved new tilemap- halloween +new powerups: air- and earth-flower Supertux Release 0.3.4 (2013-07) -------------------------------- diff --git a/data/images/objects/bonus_block/bonus-air_flower.png b/data/images/objects/bonus_block/bonus-air_flower.png new file mode 100644 index 000000000..abc8ac192 Binary files /dev/null and b/data/images/objects/bonus_block/bonus-air_flower.png differ diff --git a/data/images/objects/bonus_block/bonus-earth_flower.png b/data/images/objects/bonus_block/bonus-earth_flower.png new file mode 100644 index 000000000..c94d8d8a1 Binary files /dev/null and b/data/images/objects/bonus_block/bonus-earth_flower.png differ diff --git a/data/images/tiles.strf b/data/images/tiles.strf index 0297d2b9a..2fe32c159 100644 --- a/data/images/tiles.strf +++ b/data/images/tiles.strf @@ -15,6 +15,52 @@ ;; src/tile.cpp, unisolid is 3 not 2 (supertux-tiles (tile + (id 3162) + (images + "objects/bonus_block/full-0.png" + "objects/bonus_block/full-1.png" + "objects/bonus_block/full-2.png" + "objects/bonus_block/full-3.png" + "objects/bonus_block/full-4.png" + "objects/bonus_block/full-3.png" + "objects/bonus_block/full-2.png" + "objects/bonus_block/full-1.png" + "objects/bonus_block/full-0.png" + "objects/bonus_block/full-0.png" + "objects/bonus_block/full-0.png" + ) + (solid #t) + (fullbox #t) + (next-tile 84) + (editor-images "objects/bonus_block/bonus-earth_flower.png") + (data 14) + (fps 15) + ) + + (tile + (id 3161) + (images + "objects/bonus_block/full-0.png" + "objects/bonus_block/full-1.png" + "objects/bonus_block/full-2.png" + "objects/bonus_block/full-3.png" + "objects/bonus_block/full-4.png" + "objects/bonus_block/full-3.png" + "objects/bonus_block/full-2.png" + "objects/bonus_block/full-1.png" + "objects/bonus_block/full-0.png" + "objects/bonus_block/full-0.png" + "objects/bonus_block/full-0.png" + ) + (solid #t) + (fullbox #t) + (next-tile 84) + (editor-images "objects/bonus_block/bonus-air_flower.png") + (data 13) + (fps 15) + ) + + (tile (id 3037) (images "objects/bonus_block/full-0.png" @@ -667,7 +713,7 @@ ) (tilegroup (name "Block") - (tiles 27 28 29 47 48 50 49 211 77 51 52 212 78 62 61 213 3159 44 83 2947 2948 84 102 140 103 104 105 3160 112 128 3037 2943 2944 2945 2946 1311 2153) + (tiles 27 28 29 47 48 50 49 211 77 51 52 212 78 62 61 213 3159 44 83 2947 2948 84 103 128 102 140 3161 3162 104 105 3160 112 3037 2943 2944 2945 2946 1311 2153) ) (tilegroup (name "Background") @@ -4237,5 +4283,5 @@ ) (image "tiles/halloween/black.png") ) -;; next-id: 3161 +;; next-id: 3163 ) diff --git a/src/object/player.cpp b/src/object/player.cpp index e1316d25b..25b6cef75 100644 --- a/src/object/player.cpp +++ b/src/object/player.cpp @@ -42,6 +42,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; /** number of idle stages, including standing */ static const unsigned int IDLE_STAGE_COUNT = 5; @@ -78,6 +79,8 @@ static const float BONUS_RUN_XM = 80; static const float MAX_CLIMB_XM = 96; /** maximum vertical climb velocity */ static const float MAX_CLIMB_YM = 128; +/** maximum vertical glide velocity */ +static const float MAX_GLIDE_YM = 128; /** instant velocity when tux starts to walk */ static const float WALK_SPEED = 100; @@ -121,6 +124,8 @@ Player::Player(PlayerStatus* _player_status, const std::string& name_) : backflip_direction(), peekingX(), peekingY(), + glide_time(), + stone(), swimming(), speedlimit(), scripting_controller_old(0), @@ -144,6 +149,8 @@ Player::Player(PlayerStatus* _player_status, const std::string& name_) : safe_timer(), kick_timer(), shooting_timer(), + ability_timer(), + cooldown_timer(), dying_timer(), growing(), backflip_timer(), @@ -217,6 +224,8 @@ Player::init() backflip_direction = 0; sprite->set_angle(0.0f); visible = true; + glide_time = 0; + stone = false; swimming = false; on_ice = false; ice_this_frame = false; @@ -403,6 +412,8 @@ Player::update(float elapsed_time) if (deactivated) do_standup(); } + if (player_status->bonus == AIR_BONUS) + glide_time = player_status->max_air_time * GLIDE_TIME_PER_FLOWER; } // calculate movement for this frame @@ -718,13 +729,33 @@ Player::handle_vertical_input() else do_jump((fabs(physic.get_velocity_x()) > MAX_WALK_XM) ? -580 : -520); } - } + // 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); + else if (ability_timer.started()) { + log_debug << ability_timer.get_timeleft() << std::endl; + if (ability_timer.get_timeleft() <= 0.05f) { + glide_time = 0; + ability_timer.stop(); + } else { + physic.set_velocity_y(MAX_GLIDE_YM); + physic.set_acceleration_y(0); + } + } + } + /*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) { jumping = false; early_jump_apex(); } + if (player_status->bonus == AIR_BONUS && ability_timer.started()){ + glide_time = ability_timer.get_timeleft(); + ability_timer.stop(); + } } if(jump_early_apex && physic.get_velocity_y() >= 0) { diff --git a/src/object/player.hpp b/src/object/player.hpp index 2e72b523a..4205f9f7a 100644 --- a/src/object/player.hpp +++ b/src/object/player.hpp @@ -274,6 +274,8 @@ private: int backflip_direction; Direction peekingX; Direction peekingY; + float glide_time; + bool stone; bool swimming; float speedlimit; Controller* scripting_controller_old; /**< Saves the old controller while the scripting_controller is used */ @@ -302,6 +304,8 @@ public: Timer safe_timer; Timer kick_timer; Timer shooting_timer; // used to show the arm when Tux is shooting + Timer ability_timer; // maximum lengh of time that special abilities can last + Timer cooldown_timer; // minimum time period between successive uses of a special ability Timer dying_timer; bool growing; Timer backflip_timer; diff --git a/src/supertux/player_status.hpp b/src/supertux/player_status.hpp index 6db8d8381..35adf967a 100644 --- a/src/supertux/player_status.hpp +++ b/src/supertux/player_status.hpp @@ -56,8 +56,8 @@ public: BonusType bonus; int max_fire_bullets; /**< maximum number of fire bullets in play */ int max_ice_bullets; /**< maximum number of ice bullets in play */ - int max_air_time; /**< maximum number of seconds player can float in air */ - int max_earth_time; /**< maximum number of seconds player can turn to stone */ + int max_air_time; /**set_action(moving ? "ice-walking" : "ice-stop"); break; + case AIR_BONUS: + sprite->set_action(moving ? "ice-walking" : "ice-stop"); + break; + case EARTH_BONUS: + sprite->set_action(moving ? "fire-walking" : "fire-stop"); + break; case NO_BONUS: sprite->set_action(moving ? "small-walking" : "small-stop"); break;