- added jumping from badguys (hold jump pressed while jumping on one)
authorIngo Ruhnke <grumbel@gmx.de>
Mon, 14 Jun 2004 18:34:25 +0000 (18:34 +0000)
committerIngo Ruhnke <grumbel@gmx.de>
Mon, 14 Jun 2004 18:34:25 +0000 (18:34 +0000)
SVN-Revision: 1486

src/badguy.cpp
src/badguy.h
src/player.cpp
src/player.h

index 100ad81..daff4ad 100644 (file)
@@ -1026,16 +1026,9 @@ BadGuy::bump()
 }
 
 void
-BadGuy::make_player_jump(Player* player)
-{
-  player->physic.set_velocity_y(2);
-  player->base.y = base.y - player->base.height - 2;
-}
-
-void
 BadGuy::squish_me(Player* player)
 {
-  make_player_jump(player);
+  player->bounce();
     
   Sector::current()->add_score(Vector(base.x, base.y),
                               50 * player_status.score_multiplier);
@@ -1057,7 +1050,7 @@ BadGuy::squish(Player* player)
     // mrbomb transforms into a bomb now
     explode(false);
     
-    make_player_jump(player);
+    player->bounce();
     Sector::current()->add_score(Vector(base.x, base.y),
                                 50 * player_status.score_multiplier);
     sound_manager->play_sound(sounds[SND_SQUISH], get_pos());
@@ -1091,7 +1084,7 @@ BadGuy::squish(Player* player)
         set_sprite(img_mriceblock_flat_left, img_mriceblock_flat_right);
       }
 
-    make_player_jump(player);
+    player->bounce();
 
     player_status.score_multiplier++;
 
@@ -1108,7 +1101,7 @@ BadGuy::squish(Player* player)
     if(physic.get_velocity_y() >= 0)
       return;
       
-    make_player_jump(player);
+    player->bounce();
              
     Sector::current()->add_score(Vector(base.x, base.y),
                                 25 * player_status.score_multiplier);
@@ -1139,7 +1132,7 @@ BadGuy::squish(Player* player)
       physic.set_velocity_x(physic.get_velocity_x() * 2.0f);
       // XXX magic number: 66 is BGM_BIG height
 
-      make_player_jump(player);
+      player->bounce();
       base.y += 66 - base.height;
              
       Sector::current()->add_score(Vector(base.x, base.y),
index 6b1566a..b9c2d12 100644 (file)
@@ -160,9 +160,6 @@ private:
    * ground */
   void fall();
 
-  /** let the player jump a bit (used when you hit a badguy) */
-  void make_player_jump(Player* player);
-
   /** Turn enemy into a bomb. To explode right way pass true */
   void explode(bool right_away);
 
index 806ca89..e43bd63 100644 (file)
@@ -1006,3 +1006,18 @@ Player::check_bounds(Camera* camera)
   }
 }
 
+void
+Player::bounce()
+{
+  if (input.up)
+    physic.set_velocity_y(5.2);
+  else
+    physic.set_velocity_y(2);
+
+  // FIXME: moving tux up looks ugly, but without it tux might collide
+  // FIXME: with enemies, which he has just jump onto (iceblock)
+  //base.y = base.y - base.height - 2;
+}
+
+/* EOF */
+
index dedc6b1..6805b78 100644 (file)
@@ -180,6 +180,11 @@ public:
   bool tiles_on_air(int tiles);
   void grow(bool animate);
   void move(const Vector& vector);
+
+  /** let the player jump a bit or more if jump button is hold down
+      (used when you hit a badguy) */
+  void bounce();
+
   bool is_dead() const
   { return dead; }