X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=player.h;h=fa9335cde0b1bd769f92b54b5a43edf5326b4d09;hb=1740c935bfdacc65c5c7e4bb95fba1ada1f7118a;hp=92db1fbca3ddf564550b47614405116719bfa04e;hpb=2ca677a0ec9d00db46a8b97bec30dbea8280a79b;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/player.h b/player.h index 92db1fb..fa9335c 100644 --- a/player.h +++ b/player.h @@ -52,33 +52,34 @@ static float fc_speed = 10.0f; static struct gplayer { /* Physics */ - rigidbody rb, collide_front, collide_back, rb_gate_frame; + rigidbody collide_front, collide_back; - /* TODO: eugh */ - m3x3f gate_vr_frame, gate_vr_pstep_frame; - int on_board_frame, in_air_frame; + struct player_phys + { + rigidbody rb, rb_gate_frame; + float iY, siY; /* Yaw inertia */ + + v3f a, v_last, m, bob, vl; - v3f a, v_last, m, bob, vl; + /* Utility */ + float vswitch, slip, slip_last, + reverse; - /* Utility */ - float vswitch, slip, slip_last, - reverse; + float grab, jump; + int in_air, on_board, jump_charge, jump_dir; - float iY; /* Yaw inertia */ - int in_air, is_dead, on_board; + m3x3f vr,vr_pstep; + } + phys, + phys_gate_frame; - v2f board_xy; - float grab; - float pitch; float pushing, push_time; - float jump; - int jump_charge, jump_dir; - + int is_dead; + v3f land_target; v3f land_target_log[22]; u32 land_target_colours[22]; int land_log_count; - m3x3f vr,vr_pstep; v3f handl_target, handr_target, handl, handr; @@ -100,7 +101,9 @@ static struct gplayer fairdir, fsetup, walk_timer, + fjump, fonboard; + int step_phase; /* player model */ @@ -146,8 +149,6 @@ static struct gplayer } player = { - .on_board = 0, - .collide_front = { .type = k_rb_shape_sphere, .inf.sphere.radius = 0.3f }, .collide_back = { .type = k_rb_shape_sphere, .inf.sphere.radius = 0.3f } }; @@ -158,6 +159,8 @@ player = static float *player_get_pos(void); static void player_kill(void); static float *player_cam_pos(void); +static void player_save_frame(void); +static void player_restore_frame(void); /* * Submodules @@ -189,29 +192,23 @@ static void player_init(void) /* 1 */ static void player_update(void) /* 2 */ { + struct player_phys *phys = &player.phys; + for( int i=0; i0.0f) { - player.rb = player.rb_gate_frame; - player.on_board = player.on_board_frame; - player.in_air = player.in_air_frame; - m3x3_copy( player.gate_vr_frame, player.vr ); - m3x3_copy( player.gate_vr_pstep_frame, player.vr_pstep ); player.is_dead = 0; - player.in_air = 1; + player_restore_frame(); - - if( !player.on_board ) + if( !phys->on_board ) { - player.angles[0] = atan2f( -player.rb.forward[2], - -player.rb.forward[0] ); + player.angles[0] = atan2f( -phys->rb.forward[2], + -phys->rb.forward[0] ); } - m3x3_identity( player.vr ); - player.mdl.shoes[0] = 1; player.mdl.shoes[1] = 1; @@ -220,15 +217,16 @@ static void player_update(void) /* 2 */ if( vg_get_button_down( "switchmode" ) ) { - player.on_board ^= 0x1; + phys->on_board ^= 0x1; } - if( (glfwGetKey( vg_window, GLFW_KEY_O ) || (player.rb.co[1] < 0.0f)) && - !player.is_dead) +#if 0 + if( (glfwGetKey( vg_window, GLFW_KEY_O ) )) { - player_ragdoll_copy_model( player.rb.v ); + player_ragdoll_copy_model( phys->rb.v ); player.is_dead = 1; } +#endif if( player.is_dead ) { @@ -282,13 +280,13 @@ static void draw_player(void) /* 3 */ static float *player_get_pos(void) { - return player.rb.co; + return player.phys.rb.co; } static void player_kill(void) { player.is_dead = 1; - player_ragdoll_copy_model( player.rb.v ); + player_ragdoll_copy_model( player.phys.rb.v ); } static float *player_cam_pos(void)