Skip to content

Commit

Permalink
Completed airflower powerup abilities.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
LMH0013 committed Nov 15, 2014
1 parent 4869b1d commit af6086c
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 5 deletions.
1 change: 1 addition & 0 deletions WHATSNEW.txt
Expand Up @@ -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)
--------------------------------
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 48 additions & 2 deletions data/images/tiles.strf
Expand Up @@ -14,6 +14,52 @@
;; - the meaning of the values in (attributes ...) can be seen in
;; 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
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -4237,5 +4283,5 @@
)
(image "tiles/halloween/black.png")
)
;; next-id: 3161
;; next-id: 3163
)
33 changes: 32 additions & 1 deletion src/object/player.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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),
Expand All @@ -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(),
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 4 additions & 0 deletions src/object/player.hpp
Expand Up @@ -274,6 +274,8 @@ class Player : public MovingObject,
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 */
Expand Down Expand Up @@ -302,6 +304,8 @@ class Player : public MovingObject,
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;
Expand Down
4 changes: 2 additions & 2 deletions src/supertux/player_status.hpp
Expand Up @@ -56,8 +56,8 @@ class PlayerStatus
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; /**<determines maximum number of seconds player can float in air */
int max_earth_time; /**< determines maximum number of seconds player can turn to stone */

private:
int displayed_coins;
Expand Down
6 changes: 6 additions & 0 deletions src/worldmap/tux.cpp
Expand Up @@ -70,6 +70,12 @@ Tux::draw(DrawingContext& context)
case ICE_BONUS:
sprite->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;
Expand Down

0 comments on commit af6086c

Please sign in to comment.