on your marks, get set, bake
[carveJwlIkooP6JGAAIwe30JlM.git] / player_walk.c
index 10d00947a2701a8b67e024c58603511cd8cdfd9a..bacb48c42bb12203fdab132af5beb6eca3495bed 100644 (file)
@@ -3,6 +3,7 @@
 
 #include "player.h"
 #include "input.h"
+#include "audio.h"
 
 VG_STATIC void player_walk_drop_in_vector( player_instance *player, v3f vec )
 {
@@ -361,6 +362,16 @@ VG_STATIC void player__walk_update( player_instance *player )
    struct player_walk *w = &player->_walk;
    v3_copy( player->rb.co, w->state.prev_pos );
 
+   world_instance *world = world_current_instance();
+
+   if( world->water.enabled ){
+      if( player->rb.co[1]+0.4f < world->water.height ){
+         audio_oneshot_3d( &audio_splash, player->rb.co, 40.0f, 1.0f );
+         player__dead_transition( player );
+         return;
+      }
+   }
+
    enum walk_activity prev_state = w->state.activity;
 
    if( player->immobile )
@@ -390,7 +401,6 @@ VG_STATIC void player__walk_update( player_instance *player )
    joystick_state( k_srjoystick_steer, steer );
 
    w->move_speed = v2_length( steer );
-   world_instance *world = world_current_instance();
 
    /* 
     * Collision detection