better physics
[carveJwlIkooP6JGAAIwe30JlM.git] / player_audio.h
index 33a050a7d523457711f290c818bfcb4f71e2b3db..727080cea20c36bc5cf93d996d2aa94436cdeeaa 100644 (file)
@@ -10,7 +10,7 @@
 /* 
  * Audio
  */
-static void player_audio(void)
+VG_STATIC void player_audio(void)
 {
    struct player_phys *phys = &player.phys;
 
@@ -25,15 +25,23 @@ static void player_audio(void)
 
 
    audio_lock();
-   
+
    double revert_delta = vg.time - last_revert;
-   if( phys->on_board && (!_air && l2) && (fabsf(phys->slip) > 0.5f) && 
-         (revert_delta > 0.7) )
+   if( phys->on_board && (!_air && l2) && (revert_delta > 0.7) &&
+       (player.air_time > 0.5f) )
    {
       audio_player_set_position( &audio_player_extra, phys->rb.co );
       audio_player_set_flags( &audio_player_extra, AUDIO_FLAG_SPACIAL_3D );
       audio_player_set_vol( &audio_player_extra, 2.0f );
-      audio_player_playclip( &audio_player_extra, &audio_lands[rand()%5] );
+
+      if( (fabsf(phys->slip) > 0.75f) )
+      {
+         audio_player_playclip( &audio_player_extra, &audio_lands[rand()%2+3] );
+      }
+      else
+      {
+         audio_player_playclip( &audio_player_extra, &audio_lands[rand()%3] );
+      }
 
       last_revert = vg.time;
    }
@@ -95,7 +103,8 @@ static void player_audio(void)
          }
          else if( sprite_type == k_audio_sprite_type_water )
          {
-            audio_player_playclip( avail, &audio_water[rand()%6] );
+            if( world.water.enabled )
+               audio_player_playclip( avail, &audio_water[rand()%6] );
          }
       }
    }
@@ -118,8 +127,28 @@ static void player_audio(void)
          audio_player_set_flags( &audio_player_extra, AUDIO_FLAG_SPACIAL_3D );
          audio_player_set_position( &audio_player_extra, phys->rb.co );
          audio_player_set_vol( &audio_player_extra, 6.0f );
-         audio_player_playclip( &audio_player_extra, 
-                                          &audio_footsteps[rand()%4] );
+
+         if( player.surface_prop == k_surface_prop_concrete )
+         {
+            audio_player_playclip( 
+              &audio_player_extra, 
+              &audio_footsteps[rand()%vg_list_size(audio_footsteps)] 
+            );
+         }
+         else if( player.surface_prop == k_surface_prop_grass )
+         {
+            audio_player_playclip( 
+              &audio_player_extra, 
+              &audio_footsteps_grass[rand()%vg_list_size(audio_footsteps_grass)]
+            );
+         }
+         else if( player.surface_prop == k_surface_prop_wood )
+         {
+            audio_player_playclip( 
+              &audio_player_extra, 
+              &audio_footsteps_wood[rand()%vg_list_size(audio_footsteps_wood)]
+            );
+         }
       }
 
       player.step_phase = walk_phase;
@@ -147,6 +176,12 @@ static void player_audio(void)
    world_audio_update( cam, ears );
 #endif
    audio_unlock();
+
+   if( player.phys.in_air )
+      player.air_time += vg.time_delta;
+   else
+      player.air_time = 0.0f;
+   
 }
 
 #endif /* PLAYER_AUDIO_H */