Completed airflower powerup abilities.
authorLMH <lmh.0013@gmail.com>
Sat, 15 Nov 2014 20:34:59 +0000 (10:34 -1000)
committerLMH <lmh.0013@gmail.com>
Sat, 15 Nov 2014 21:21:35 +0000 (11:21 -1000)
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.

WHATSNEW.txt
data/images/objects/bonus_block/bonus-air_flower.png [new file with mode: 0644]
data/images/objects/bonus_block/bonus-earth_flower.png [new file with mode: 0644]
data/images/tiles.strf
src/object/player.cpp
src/object/player.hpp
src/supertux/player_status.hpp
src/worldmap/tux.cpp

index a742979..2e60061 100644 (file)
@@ -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 (file)
index 0000000..abc8ac1
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 (file)
index 0000000..c94d8d8
Binary files /dev/null and b/data/images/objects/bonus_block/bonus-earth_flower.png differ
index 0297d2b..2fe32c1 100644 (file)
 ;;    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"
   )
   (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")
     )
     (image "tiles/halloween/black.png")
   )
-;; next-id: 3161
+;; next-id: 3163
 )
index e1316d2..25b6cef 100644 (file)
@@ -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) {
index 2e72b52..4205f9f 100644 (file)
@@ -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;
index 6db8d83..35adf96 100644 (file)
@@ -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; /**<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;
index 561be82..d54c650 100644 (file)
@@ -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;