Splash sound on entering water
authorWolfgang Becker <uafr@gmx.de>
Tue, 18 Jul 2006 19:37:09 +0000 (19:37 +0000)
committerWolfgang Becker <uafr@gmx.de>
Tue, 18 Jul 2006 19:37:09 +0000 (19:37 +0000)
SVN-Revision: 4046

data/sounds/splash.ogg [new file with mode: 0644]
src/object/player.cpp
src/object/player.hpp

diff --git a/data/sounds/splash.ogg b/data/sounds/splash.ogg
new file mode 100644 (file)
index 0000000..60c2492
Binary files /dev/null and b/data/sounds/splash.ogg differ
index bfdd201..d0ee806 100644 (file)
@@ -79,6 +79,9 @@ TuxBodyParts* big_tux = 0;
 TuxBodyParts* fire_tux = 0;
 TuxBodyParts* ice_tux = 0;
 
+namespace{
+  bool no_water = true;
+}
 void
 TuxBodyParts::set_action(std::string action, int loops)
 {
@@ -119,6 +122,8 @@ Player::Player(PlayerStatus* _player_status)
   sound_manager->preload("sounds/skid.wav");
   sound_manager->preload("sounds/flip.wav");
   sound_manager->preload("sounds/invincible.wav");
+  sound_manager->preload("sounds/splash.ogg");
+
 
   init();
 }
@@ -154,6 +159,7 @@ Player::init()
   backflipping = false;
   backflip_direction = 0;
   visible = true;
+  swimming = false;
   
   on_ground_flag = false;
   grabbed_object = NULL;
@@ -199,6 +205,11 @@ Player::adjust_height(float new_height)
 void
 Player::update(float elapsed_time)
 {
+  if( no_water ){
+    swimming = false;
+  }
+  no_water = true;
+  
   if(dying && dying_timer.check()) {
     dead = true;
     return;
@@ -902,6 +913,20 @@ Player::collision_tile(uint32_t tile_attributes)
 {
   if(tile_attributes & Tile::HURTS)
     kill(false);
+    
+  if( swimming ){ 
+    if( tile_attributes & Tile::WATER ){
+      no_water = false;
+    } else {
+      swimming = false;
+    }
+  } else {
+    if( tile_attributes & Tile::WATER ){
+      swimming = true;
+      no_water = false;
+      sound_manager->play( "sounds/splash.ogg" );
+    }
+  }
 }
 
 void
index bab2bc5..885d41e 100644 (file)
@@ -96,6 +96,7 @@ private:
   bool backflipping;
   int  backflip_direction;
   Direction peeking;
+  bool swimming;
   
 public:
   Direction dir;