X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=player_animation.h;h=e08991014629b05224ab5babd4754873af2cdc6a;hb=1a46c04c21370ae5f81795f7fe05b1743355668e;hp=88fe6690e8039ace9ae538e159c729a36de6487e;hpb=ec0918b2ef17a71418a57417689fd3042915aeeb;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/player_animation.h b/player_animation.h index 88fe669..e089910 100644 --- a/player_animation.h +++ b/player_animation.h @@ -20,7 +20,8 @@ VG_STATIC void player_animate_offboard(void) player.ffly = vg_lerpf( player.ffly, fly, rate*vg.time_delta ); player.frun = vg_lerpf( player.frun, - vg_get_axis("walk/push")*0.5f+0.5f, + player.walk * + (1.0f + player.input_walk->button.value*0.5f), 2.0f*vg.time_delta ); } @@ -160,7 +161,7 @@ VG_STATIC void player_animate(void) { float dirz = phys->reverse > 0.0f? 0.0f: 1.0f, dirx = phys->slip < 0.0f? 0.0f: 1.0f, - fly = phys->in_air? 1.0f: 0.0f; + fly = (phys->in_air|phys->grind)? 1.0f: 0.0f; player.fdirz = vg_lerpf( player.fdirz, dirz, 2.4f*vg.time_delta ); player.fdirx = vg_lerpf( player.fdirx, dirx, 0.6f*vg.time_delta ); @@ -224,7 +225,7 @@ VG_STATIC void player_animate(void) mdl_keyframe air_pose[32]; { - float target = -vg_get_axis("lookh"); + float target = -player.input_js1h->axis.value; player.fairdir = vg_lerpf( player.fairdir, target, 2.4f*vg.time_delta ); float air_frame = (player.fairdir*0.5f+0.5f) * (15.0f/30.0f); @@ -335,15 +336,21 @@ VG_STATIC void player_animate_camera(void) /* Look angles */ v3_lerp( phys->vl, phys->rb.v, 0.05f, phys->vl ); + player.fgrind = vg_lerpf( player.fgrind, phys->grind, vg.time_delta ); + float yaw = atan2f( phys->vl[0], -phys->vl[2] ), - pitch = atan2f( -phys->vl[1], - sqrtf( - phys->vl[0]*phys->vl[0] + phys->vl[2]*phys->vl[2] - )) * 0.7f; + pitch = atan2f + ( + -phys->vl[1], + sqrtf + ( + phys->vl[0]*phys->vl[0] + phys->vl[2]*phys->vl[2] + ) + ) + * 0.7f + vg_lerpf( 0.30f, 0.90f, player.fgrind ); player.angles[0] = yaw; - player.angles[1] = vg_lerpf( player.angles[1], pitch + 0.30f, - player.fonboard ); + player.angles[1] = vg_lerpf( player.angles[1], pitch, player.fonboard ); /* Camera shake */ static v2f shake_damp = {0.0f,0.0f}; @@ -360,11 +367,13 @@ VG_STATIC void player_animate_camera(void) else { float speed = vg.time_delta * k_look_speed; +#if 0 player.angles[0] += vg_get_axis( "lookh" ) * speed; player.angles[1] += vg_get_axis( "lookv" ) * speed; player.angles[1] = vg_clampf( player.angles[1], -k_pitch_limit, k_pitch_limit ); +#endif float s = sinf(player.angles[0]) * 0.2f, c = -cosf(player.angles[0]) * 0.2f; @@ -380,7 +389,7 @@ VG_STATIC void player_animate_camera(void) m4x3_mulv( mtx, player.mdl.cam_pos, cam_pos ); v3_add( cam_pos, forward_dir, player.camera_pos ); - v3_lerp( phys->vl, phys->rb.v, 0.3f, phys->vl ); + v3_lerp( phys->vl, phys->rb.v, 18.0f*vg.time_delta, phys->vl ); } }