X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=player_walk.c;h=5c52f2d03004a6cc865d1191e91fcb3c5d231cb4;hb=aed3995840d5472275b7bf143efed7c4f9daa358;hp=10d00947a2701a8b67e024c58603511cd8cdfd9a;hpb=342fcbf6fda017bdd38d56ce0fa7c9e59e589f3b;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/player_walk.c b/player_walk.c index 10d0094..5c52f2d 100644 --- a/player_walk.c +++ b/player_walk.c @@ -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 ) { @@ -316,6 +317,10 @@ VG_STATIC void player__walk_pre_update( player_instance *player ) } } } + else if( button_down( k_srbind_jump ) && !player->immobile ){ + w->state.jump_queued = 1; + w->state.jump_input_time = vg.time; + } } VG_STATIC int player_walk_normal_standable( player_instance *player, v3f n ) @@ -361,6 +366,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 +405,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 @@ -451,14 +465,19 @@ VG_STATIC void player__walk_update( player_instance *player ) nominal_speed = k_walkspeed; /* jump */ - if( button_down( k_srbind_jump ) ){ - float d = v3_dot( player->basis[1], player->rb.v ); - v3_muladds( player->rb.v, player->basis[1], -d, player->rb.v ); - v3_muladds( player->rb.v, player->basis[1], 5.0f, player->rb.v ); - w->state.activity = k_walk_activity_air; - prev_state = k_walk_activity_air; - accel_speed = k_walk_air_accel; - nominal_speed = k_airspeed; + if( w->state.jump_queued ){ + w->state.jump_queued = 0; + + f32 t = vg.time - w->state.jump_input_time; + if( t < PLAYER_JUMP_EPSILON ){ + float d = v3_dot( player->basis[1], player->rb.v ); + v3_muladds( player->rb.v, player->basis[1], -d, player->rb.v ); + v3_muladds( player->rb.v, player->basis[1], 5.0f, player->rb.v ); + w->state.activity = k_walk_activity_air; + prev_state = k_walk_activity_air; + accel_speed = k_walk_air_accel; + nominal_speed = k_airspeed; + } } else{ player_friction( player->rb.v );