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;
fairdir,
fsetup,
walk_timer,
+ fjump,
fonboard;
+
int step_phase;
/* player model */
}
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 }
};
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
static void player_update(void) /* 2 */
{
+ struct player_phys *phys = &player.phys;
+
for( int i=0; i<player.land_log_count; i++ )
vg_line_cross( player.land_target_log[i],
player.land_target_colours[i], 0.25f);
if( vg_get_axis("grabl")>0.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;
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 )
{
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)