Getting rid of nasty tabs
[supertux.git] / src / object / player.cpp
index e4bbced..63770ef 100644 (file)
@@ -60,7 +60,7 @@ static const float SHOOTING_TIME = .150f;
 static const float IDLE_TIME = 2.5f;
 
 /** acceleration in horizontal direction when walking
- * (all acceleratiosn are in  pixel/s^2) */
+ * (all accelerations are in  pixel/s^2) */
 static const float WALK_ACCELERATION_X = 300;
 /** acceleration in horizontal direction when running */ 
 static const float RUN_ACCELERATION_X = 400;
@@ -111,9 +111,8 @@ Player::Player(PlayerStatus* _player_status, const std::string& name)
   sound_manager->preload("sounds/hurt.wav");
   sound_manager->preload("sounds/skid.wav");
   sound_manager->preload("sounds/flip.wav");
-  sound_manager->preload("sounds/invincible.wav");
+  sound_manager->preload("sounds/invincible_start.ogg");
   sound_manager->preload("sounds/splash.ogg");
-  sound_manager->preload("sounds/shoot.wav");
 
   init();
 }
@@ -139,7 +138,8 @@ Player::init()
   dead = false;
 
   dying = false;
-  peeking = AUTO;
+  peekingX = AUTO;
+  peekingY = AUTO;
   last_ground_y = 0;
   fall_mode = ON_GROUND;
   jumping = false;
@@ -345,12 +345,12 @@ Player::update(float elapsed_time)
       Vector paccel = Vector(0, 0);
       // draw bright sparkle when there is lots of time left, dark sparkle when invincibility is about to end
       if (invincible_timer.get_timeleft() > TUX_INVINCIBLE_TIME_WARNING) {
-       // make every other a longer sparkle to make trail a bit fuzzy
-       if (size_t(game_time*20)%2) {
-         Sector::current()->add_object(new SpriteParticle("images/objects/particles/sparkle.sprite", "small", ppos, ANCHOR_MIDDLE, pspeed, paccel, LAYER_OBJECTS+1+5));
-       } else {
-         Sector::current()->add_object(new SpriteParticle("images/objects/particles/sparkle.sprite", "medium", ppos, ANCHOR_MIDDLE, pspeed, paccel, LAYER_OBJECTS+1+5));
-       }
+        // make every other a longer sparkle to make trail a bit fuzzy
+        if (size_t(game_time*20)%2) {
+          Sector::current()->add_object(new SpriteParticle("images/objects/particles/sparkle.sprite", "small", ppos, ANCHOR_MIDDLE, pspeed, paccel, LAYER_OBJECTS+1+5));
+        } else {
+          Sector::current()->add_object(new SpriteParticle("images/objects/particles/sparkle.sprite", "medium", ppos, ANCHOR_MIDDLE, pspeed, paccel, LAYER_OBJECTS+1+5));
+        }
       } else {
         Sector::current()->add_object(new SpriteParticle("images/objects/particles/sparkle.sprite", "dark", ppos, ANCHOR_MIDDLE, pspeed, paccel, LAYER_OBJECTS+1+5));
       }
@@ -651,28 +651,29 @@ Player::handle_input()
 
   /* Peeking */
   if( controller->released( Controller::PEEK_LEFT ) ) {
-    peeking = AUTO;
+    peekingX = AUTO;
   }
   if( controller->released( Controller::PEEK_RIGHT ) ) {
-    peeking = AUTO;
+    peekingX = AUTO;
   }
-  if( controller->released( Controller::UP ) ) {
-    peeking = AUTO;
+  if( controller->released( Controller::PEEK_UP ) ) {
+    peekingY = AUTO;
   }
-  if( controller->released( Controller::DOWN ) ) {
-    peeking = AUTO;
+  if( controller->released( Controller::PEEK_DOWN ) ) {
+    peekingY = AUTO;
   }
   if( controller->pressed( Controller::PEEK_LEFT ) ) {
-    peeking = LEFT;
+    peekingX = LEFT;
   }
   if( controller->pressed( Controller::PEEK_RIGHT ) ) {
-    peeking = RIGHT;
+    peekingX = RIGHT;
   }
-  if( controller->pressed( Controller::UP ) ) {
-    peeking = UP;
-  }
-  if( controller->pressed( Controller::DOWN ) ) {
-    peeking = DOWN;
+  if(!backflipping && !jumping && on_ground()) {
+    if( controller->pressed( Controller::PEEK_UP ) ) {
+      peekingY = UP;
+    } else if( controller->pressed( Controller::PEEK_DOWN ) ) {
+      peekingY = DOWN;
+    }
   }
 
   /* Handle horizontal movement: */
@@ -1114,7 +1115,7 @@ Player::collision(GameObject& other, const CollisionHit& hit)
 void
 Player::make_invincible()
 {
-  sound_manager->play("sounds/invincible.wav");
+  sound_manager->play("sounds/invincible_start.ogg");
   invincible_timer.start(TUX_INVINCIBLE_TIME);
   Sector::current()->play_music(HERRING_MUSIC);
 }