X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=player.c;h=e000c513b5f140c4cc5e7167c2b148f8cf526aec;hb=aed3995840d5472275b7bf143efed7c4f9daa358;hp=e2052029635dc3cc40cd8a7ab036fd0461043d54;hpb=872ad3e040f22df357929d3778a955ae8c4ac52b;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/player.c b/player.c index e205202..e000c51 100644 --- a/player.c +++ b/player.c @@ -4,6 +4,9 @@ #include "player.h" #include "camera.h" #include "player_model.h" +#include "input.h" +#include "world.h" +#include "audio.h" VG_STATIC int localplayer_cmd_respawn( int argc, const char *argv[] ) { @@ -32,11 +35,17 @@ VG_STATIC void player_init(void) } vg_console_reg_cmd( "respawn", localplayer_cmd_respawn, NULL ); + VG_VAR_F32( k_cam_damp ); + VG_VAR_F32( k_cam_spring ); + VG_VAR_F32( k_cam_punch ); + VG_VAR_F32( k_cam_shake_strength ); + VG_VAR_F32( k_cam_shake_trackspeed ); } PLAYER_API void player__debugtext( int size, const char *fmt, ... ) { +#if 0 char buffer[ 1024 ]; va_list args; @@ -46,6 +55,7 @@ void player__debugtext( int size, const char *fmt, ... ) ui_text( vg_uictx.cursor, buffer, size, k_text_align_right ); vg_uictx.cursor[1] += 14*size; +#endif } /* @@ -58,72 +68,6 @@ void player__create( player_instance *inst ) assert( only_once == 0 ); only_once ++; - inst->input_js1h = vg_create_named_input( "steer-h", k_input_type_axis ); - inst->input_js1v = vg_create_named_input( "steer-v", k_input_type_axis ); - inst->input_grab = vg_create_named_input( "grab", k_input_type_axis_norm); - inst->input_js2h = vg_create_named_input( "grab-h", k_input_type_axis ); - inst->input_js2v = vg_create_named_input( "grab-v", k_input_type_axis ); - inst->input_jump = vg_create_named_input( "jump", k_input_type_button ); - inst->input_push = vg_create_named_input( "push", k_input_type_button ); - inst->input_walk = vg_create_named_input( "walk", k_input_type_button ); - inst->input_walkh= vg_create_named_input( "walk-h", k_input_type_axis ); - inst->input_walkv= vg_create_named_input( "walk-v", k_input_type_axis ); - inst->input_use = vg_create_named_input( "use", k_input_type_button ); - inst->input_reset= vg_create_named_input( "reset", k_input_type_button ); - inst->input_camera=vg_create_named_input( "camera", k_input_type_button ); - inst->input_trick0=vg_create_named_input( "trick0", k_input_type_button ); - inst->input_trick1=vg_create_named_input( "trick1", k_input_type_button ); - inst->input_trick2=vg_create_named_input( "trick2", k_input_type_button ); - - const char *default_cfg[] = - { - "bind steer-h gp-ls-h", - "bind -steer-h a", - "bind +steer-h d", - - "bind steer-v gp-ls-v", - "bind -steer-v w", - "bind +steer-v s", - - "bind grab gp-rt", - "bind +grab shift", - "bind grab-h gp-rs-h", - "bind grab-v gp-rs-v", - - "bind jump space", - "bind jump gp-a", - - "bind trick0 mouse1", - "bind trick0 gp-a", - "bind trick1 mouse2", - "bind trick1 gp-b", - "bind trick2 gp-x", /* keyboard: m0 + m1 */ - - "bind push gp-b", - "bind push w", - - "bind walk shift", - "bind walk gp-ls", - - "bind walk-h gp-ls-h", - "bind walk-v -gp-ls-v", - "bind +walk-h d", - "bind -walk-h a", - "bind +walk-v w", - "bind -walk-v s", - - "bind reset gp-lb", - "bind reset r", - - "bind use gp-y", - "bind use e", - "bind camera c", - "bind camera gp-rb" - }; - - for( int i=0; irb.co ); v3_zero( inst->rb.w ); v3_zero( inst->rb.v ); @@ -192,10 +136,10 @@ void player__pre_update( player_instance *player ) return; } - if( vg_input_button_down( player->input_reset ) && !player->immobile ){ - double delta = world_global.time - world_global.last_use; + if( button_down( k_srbind_reset ) && !player->immobile ){ + f64 delta = world_static.time - world_static.last_use; - if( (delta <= RESET_MAX_TIME) && (world_global.last_use != 0.0) ){ + if( (delta <= RESET_MAX_TIME) && (world_static.last_use != 0.0) ){ player->rewinding = 1; player->rewind_sound_wait = 1; player->rewind_time = (double)player->rewind_length - 0.0001; @@ -236,7 +180,7 @@ void player__pre_update( player_instance *player ) } } - if( vg_input_button_down( player->input_camera ) && !player->immobile ){ + if( button_down( k_srbind_camera ) && !player->immobile ){ if( player->camera_mode == k_cam_firstperson ) player->camera_mode = k_cam_thirdperson; else @@ -282,11 +226,11 @@ void player__post_update( player_instance *player ) PLAYER_API void player__pass_gate( player_instance *player, ent_gate *gate ) { - world_routes_fracture( get_active_world(), gate, + world_routes_fracture( world_current_instance(), gate, player->rb.co, player->rb.v ); player->gate_waiting = gate; - world_routes_activate_entry_gate( get_active_world(), gate ); + world_routes_activate_entry_gate( world_current_instance(), gate ); m4x3_mulv( gate->transport, player->tpv_lpf, player->tpv_lpf ); m3x3_mulv( gate->transport, player->cam_velocity_smooth, @@ -313,9 +257,9 @@ void player__pass_gate( player_instance *player, ent_gate *gate ) player_save_rewind_frame( player ); if( gate->type == k_gate_type_nonlocel ) - world_global.active_world = gate->target; + world_static.active_world = gate->target; - world_global.in_volume = 0; + world_volumes.inside = 0; audio_lock(); audio_oneshot( &audio_gate_pass, 1.0f, 0.0f ); @@ -358,6 +302,7 @@ VG_STATIC void gate_rotate_angles( ent_gate *gate, v3f angles, v3f d ) PLAYER_API void player__im_gui( player_instance *player ) { +#if 0 vg_uictx.cursor[0] = vg.window_x - 200; vg_uictx.cursor[1] = 0; vg_uictx.cursor[2] = 200; @@ -375,6 +320,7 @@ PLAYER_API void player__im_gui( player_instance *player ) b[2].co[1] = vg_uictx.cursor[1]; b[3].co[1] = vg_uictx.cursor[1]; +#endif } VG_STATIC void global_skateshop_exit(void); @@ -394,6 +340,11 @@ PLAYER_API void player__spawn( player_instance *player, player->subsystem = k_player_subsystem_walk; player->immobile = 0; player->gate_waiting = NULL; + player->rewind_length = 0; + player->rewind_accum = 0.0f; + player->rewind_gate = NULL; + player->rewinding = 0; + world_static.last_use = 0.0; global_skateshop_exit(); @@ -407,4 +358,13 @@ PLAYER_API void player__kill( player_instance *player ) } +/* implementation */ +#include "player_common.c" +#include "player_walk.c" +#include "player_skate.c" +#include "player_dead.c" +#include "player_drive.c" +#include "player_render.c" +#include "player_ragdoll.c" + #endif /* PLAYER_C */