the pain is gone
[carveJwlIkooP6JGAAIwe30JlM.git] / player_walk.c
index d8fe3d1fc86868af333c1155b1acc538d8435dc7..1845906e2fe01263dbddebf14bed07c860d232f0 100644 (file)
@@ -2,6 +2,7 @@
 #define PLAYER_WALK_C
 
 #include "player.h"
+#include "input.h"
 
 VG_STATIC void player_walk_drop_in_vector( player_instance *player, v3f vec )
 {
@@ -276,7 +277,7 @@ VG_STATIC void player__walk_pre_update( player_instance *player )
          return;
       }
    }
-   else if( vg_input_button_down( player->input_use ) && !player->immobile ){
+   else if( button_down( k_srbind_use ) && !player->immobile ){
       if( v3_dist2( player->rb.co, gzoomer.obj.rb.co ) <= 4.0f*4.0f ){
          player->subsystem = k_player_subsystem_drive;
       }
@@ -375,20 +376,16 @@ VG_STATIC void player__walk_update( player_instance *player )
 
    float yaw = player->angles[0];
 
-   v3f forward_dir = { sinf(yaw),          0.0f, -cosf(yaw) };
-   v3f right_dir   = { -forward_dir[2],    0.0f,  forward_dir[0] };
+   v3f forward_dir = { -sinf(yaw),         0.0f,  cosf(yaw) };
+   v3f right_dir   = {  forward_dir[2],    0.0f, -forward_dir[0] };
 
    m3x3_mulv( player->basis, forward_dir, forward_dir );
    m3x3_mulv( player->basis, right_dir,   right_dir );
 
+   v2f steer;
+   joystick_state( k_srjoystick_steer, steer );
 
-   v2f walk = { player->input_walkh->axis.value,
-                player->input_walkv->axis.value };
-
-   if( v2_length2(walk) > 0.001f )
-      v2_normalize_clamp( walk );
-
-   w->move_speed = v2_length( walk );
+   w->move_speed = v2_length( steer );
    world_instance *world = get_active_world();
 
    /* 
@@ -430,8 +427,9 @@ VG_STATIC void player__walk_update( player_instance *player )
     */
    float accel_speed = 0.0f, nominal_speed = 0.0f;
    v3f movedir;
-   v3_muls( right_dir,  walk[0], movedir );
-   v3_muladds( movedir, forward_dir, walk[1], movedir );
+
+   v3_muls( right_dir, steer[0], movedir );
+   v3_muladds( movedir, forward_dir, steer[1], movedir );
 
    if( w->state.activity == k_walk_activity_ground ){
       v3_normalize( surface_avg );
@@ -439,7 +437,7 @@ VG_STATIC void player__walk_update( player_instance *player )
       v3f tx, ty;
       rb_tangent_basis( surface_avg, tx, ty );
 
-      if( v2_length2(walk) > 0.001f ){
+      if( v2_length2(steer) > 0.001f ){
          /* clip movement to the surface */
          float d = v3_dot(surface_avg,movedir);
          v3_muladds( movedir, surface_avg, -d, movedir );
@@ -449,7 +447,7 @@ VG_STATIC void player__walk_update( player_instance *player )
       nominal_speed = k_walkspeed;
 
       /* jump */
-      if( player->input_jump->button.value ){
+      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 );
@@ -467,7 +465,7 @@ VG_STATIC void player__walk_update( player_instance *player )
       nominal_speed = k_airspeed;
    }
 
-   if( v2_length2(walk) > 0.001f ){
+   if( v2_length2( steer ) > 0.001f ){
       player_accelerate( player->rb.v, movedir, nominal_speed, accel_speed );
       v3_normalize( movedir );
    }
@@ -688,10 +686,7 @@ VG_STATIC void player__walk_animate( player_instance *player,
          rate = 9.0f;
 
       w->blend_fly = vg_lerpf( w->blend_fly, fly, rate*vg.time_delta );
-      w->blend_run = vg_lerpf( w->blend_run,
-                               w->move_speed *
-                               (1.0f + player->input_walk->button.value*0.5f),
-                               2.0f*vg.time_delta );
+      w->blend_run = vg_lerpf( w->blend_run, w->move_speed, 2.0f*vg.time_delta);
    }
 
    player_pose apose, bpose;