X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=player.h;h=25054e03f38db5040af9c9437364e99d9a4adc71;hb=5ecf9cca8b5b9bf876d7e7c7fde03d5b187bb42b;hp=e4c0fced5366a51cbfa083bd514d53e030705629;hpb=86dbcd5796ed674ca9433cce1ace8bef322cd121;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/player.h b/player.h index e4c0fce..25054e0 100644 --- a/player.h +++ b/player.h @@ -1,10 +1,5 @@ /* - * Copyright 2021-2022 (C) Mount0 Software, Harry Godden - All Rights Reserved - * ----------------------------------------------------------------------------- - * - * Player head module - * - * ----------------------------------------------------------------------------- + * Copyright (C) 2021-2022 Mt.ZERO Software, Harry Godden - All Rights Reserved */ #ifndef PLAYER_H @@ -17,8 +12,8 @@ #include "bvh.h" static float - k_walkspeed = 7.0f, /* no longer used */ - k_runspeed = 14.0f, + k_walkspeed = 20.0f, /* no longer used */ + k_runspeed = 20.0f, k_board_radius = 0.3f, k_board_length = 0.45f, k_board_allowance = 0.04f, @@ -36,7 +31,7 @@ static float k_jump_force = 5.0f, k_pitch_limit = 1.5f, k_look_speed = 2.0f, - k_walk_accel = 5.0f, + k_walk_accel = 150.0f, k_walk_friction = 8.0f; static int freecam = 0; @@ -65,7 +60,8 @@ static struct gplayer float vswitch, slip, slip_last, reverse; - float grab, jump; + float grab, jump, pushing, push_time; + double start_push; int in_air, on_board, jump_charge, jump_dir; m3x3f vr,vr_pstep; @@ -73,7 +69,6 @@ static struct gplayer phys, phys_gate_frame; - float pushing, push_time; int is_dead; v3f land_target; @@ -177,28 +172,67 @@ static void player_restore_frame(void); * ----------------------------------------------------------------------------- */ -static void player_register(void) /* 0 */ -{ - player_model_register(); -} - static void player_init(void) /* 1 */ { - player_model_init(); - + rb_init( &player.phys.rb ); rb_init( &player.collide_front ); rb_init( &player.collide_back ); + + vg_convar_push( (struct vg_convar){ + .name = "walk_speed", + .data = &k_walkspeed, + .data_type = k_convar_dtype_f32, + .opt_f32 = { .clamp = 0 }, + .persistent = 1 + }); + + vg_convar_push( (struct vg_convar){ + .name = "run_speed", + .data = &k_runspeed, + .data_type = k_convar_dtype_f32, + .opt_f32 = { .clamp = 0 }, + .persistent = 1 + }); + + vg_convar_push( (struct vg_convar){ + .name = "walk_accel", + .data = &k_walk_accel, + .data_type = k_convar_dtype_f32, + .opt_f32 = { .clamp = 0 }, + .persistent = 1 + }); + + vg_convar_push( (struct vg_convar){ + .name = "fc", + .data = &freecam, + .data_type = k_convar_dtype_i32, + .opt_i32 = { .min=0, .max=1, .clamp=1 }, + .persistent = 1 + }); + + vg_convar_push( (struct vg_convar){ + .name = "fcs", + .data = &fc_speed, + .data_type = k_convar_dtype_f32, + .opt_f32 = { .clamp = 0 }, + .persistent = 1 + }); + + vg_function_push( (struct vg_cmd){ + .name = "reset", + .function = reset_player + }); + + /* other systems */ + vg_loader_highwater( player_model_init, player_model_free, NULL ); } -static void player_update(void) /* 2 */ +/* Deal with input etc */ +static void player_update_pre(void) { struct player_phys *phys = &player.phys; - for( int i=0; i0.0f) + if( vg_get_button_down( "reset" ) ) { player.is_dead = 0; player_restore_frame(); @@ -218,18 +252,41 @@ static void player_update(void) /* 2 */ if( vg_get_button_down( "switchmode" ) ) { phys->on_board ^= 0x1; + + if( phys->on_board ) + { + v3_muladds( phys->rb.v, phys->rb.forward, 0.2f, phys->rb.v ); + } } +} - if( (glfwGetKey( vg_window, GLFW_KEY_O ) || (phys->rb.co[1] < 0.0f)) && - !player.is_dead) +static void player_update_fixed(void) /* 2 */ +{ + struct player_phys *phys = &player.phys; + + if( player.is_dead ) + { + player_ragdoll_iter(); + } + else { - player_ragdoll_copy_model( phys->rb.v ); - player.is_dead = 1; + player_do_motion(); } + player_audio(); /* FUTURE: can probably move this to post() + BUT, it uses deltas from fixed step physics, + AND this *might* be what we want for realtime + audio, anyway. */ +} + +static void player_update_post(void) +{ + for( int i=0; i