[Tuxracer-checkins] CVS: tuxracer/src phys_sim.c,1.11,1.12 racing.c,1.13,1.14 tux.c,1.6,1.7 tux.h,1.
Status: Beta
Brought to you by:
jfpatry
From: Eric H. <eh...@us...> - 2000-08-28 00:53:11
|
Update of /cvsroot/tuxracer/tuxracer/src In directory slayer.i.sourceforge.net:/tmp/cvs-serv24936 Modified Files: phys_sim.c racing.c tux.c tux.h tuxracer.h Log Message: - animation for jumping - "flying" with jump button Index: phys_sim.c =================================================================== RCS file: /cvsroot/tuxracer/tuxracer/src/phys_sim.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -r1.11 -r1.12 *** phys_sim.c 2000/08/27 20:16:42 1.11 --- phys_sim.c 2000/08/28 00:53:07 1.12 *************** *** 177,184 **** #define MAX_PADDLING_SPEED 15 #define JUMP_FORCE_DURATION 0.20 - #define JUMP_MAX_START_HEIGHT 0.10 - /* Magnitude of force before damage is incurred (N) */ #define DAMAGE_RESISTANCE ( 4.0 * TUX_MASS * EARTH_GRAV ) --- 177,183 ---- #define MAX_PADDLING_SPEED 15 + /* Time over which constant jump force is applied */ #define JUMP_FORCE_DURATION 0.20 /* Magnitude of force before damage is incurred (N) */ #define DAMAGE_RESISTANCE ( 4.0 * TUX_MASS * EARTH_GRAV ) *************** *** 1104,1123 **** - /* Only allow jumping to start if close to ground */ - if ( ( plyr->control.jumping ) && - ( plyr->control.jump_charging ) ) { - if ( uncorr_pos.y > surf_y + JUMP_MAX_START_HEIGHT ) { - plyr->control.jumping = False; - } - plyr->control.jump_charging = False; - } - /* Apply jump force in up direction for JUMP_FORCE_DURATION */ if ( ( plyr->control.jumping ) && ( g_game.time - plyr->control.jump_start_time < JUMP_FORCE_DURATION ) ) { ! jump_f = make_vector( 0, 100 + pow(2, plyr->control.jump_amt)*300, 0 ); } else { jump_f = make_vector( 0, 0, 0 ); plyr->control.jumping = False; } --- 1103,1118 ---- /* Apply jump force in up direction for JUMP_FORCE_DURATION */ if ( ( plyr->control.jumping ) && ( g_game.time - plyr->control.jump_start_time < JUMP_FORCE_DURATION ) ) { ! if ( plyr->control.flying ) { ! jump_f = make_vector( 0, 50, 0 ); ! } else { ! jump_f = make_vector( 0, 100 + pow(2, plyr->control.jump_amt)*300, 0 ); ! } } else { jump_f = make_vector( 0, 0, 0 ); plyr->control.jumping = False; + plyr->control.flying = False; } *************** *** 1497,1500 **** --- 1492,1496 ---- scalar_t paddling_factor; vector_t local_force; + scalar_t jump_factor; if ( dtime > 2. * EPS ) { *************** *** 1531,1536 **** plyr->net_force ); adjust_tux_joints( plyr->control.turn_fact, plyr->control.is_braking, ! paddling_factor, speed, local_force ); } --- 1527,1539 ---- plyr->net_force ); + if (plyr->control.jumping) { + jump_factor = (g_game.time - plyr->control.jump_start_time) / + JUMP_FORCE_DURATION; + } else { + jump_factor = 0.0; + } + adjust_tux_joints( plyr->control.turn_fact, plyr->control.is_braking, ! paddling_factor, speed, local_force, jump_factor ); } Index: racing.c =================================================================== RCS file: /cvsroot/tuxracer/tuxracer/src/racing.c,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -r1.13 -r1.14 *** racing.c 2000/08/27 20:16:42 1.13 --- racing.c 2000/08/28 00:53:07 1.14 *************** *** 46,49 **** --- 46,52 ---- #define ROLL_DECAY_TIME_CONSTANT 0.2 + /* If too high off the ground, tux flaps instead of jumping */ + #define JUMP_MAX_START_HEIGHT 0.10 + static bool_t right_turn; static bool_t left_turn; *************** *** 52,55 **** --- 55,60 ---- static bool_t roll_modifier; static bool_t paddling; + static bool_t charging; + static bool_t jumping; void racing_init() *************** *** 84,89 **** --- 89,96 ---- left_roll = right_roll = False; roll_modifier = False; + charging = jumping = False; plyr->control.is_paddling = False; plyr->control.jumping = False; + plyr->control.flying = False; plyr->control.jump_charging = False; *************** *** 176,179 **** --- 183,217 ---- } + /* + * Jumping + */ + if ( plyr->pos.y > find_y_coord(plyr->pos.x, plyr->pos.z) + + JUMP_MAX_START_HEIGHT ) { + if ( charging ) { + if ( !plyr->control.flying ) { + plyr->control.jump_start_time = g_game.time; + plyr->control.jumping = True; + plyr->control.flying = True; + } + } + jumping = False; + plyr->control.jump_charging = False; + } else { + if ( charging ) { + if ( !plyr->control.jump_charging ) { + plyr->control.jump_charging = True; + plyr->control.jump_charge_start_time = g_game.time; + } + } + if ( jumping ) { + jumping = False; + plyr->control.jump_start_time = g_game.time; + plyr->control.jump_charging = False; + plyr->control.flying = False; + plyr->control.jumping = True; + calc_jump_amt(); + } + } + update_player_pos( plyr, time_step ); *************** *** 315,328 **** START_KEYBOARD_CB( jump_cb ) { ! if ( !plyr->control.jump_charging ) { ! plyr->control.jump_charging = True; ! plyr->control.jump_charge_start_time = g_game.time; ! } ! ! if ( release ) { ! plyr->control.jump_start_time = g_game.time; ! plyr->control.jumping = True; ! calc_jump_amt(); ! } } END_KEYBOARD_CB --- 353,358 ---- START_KEYBOARD_CB( jump_cb ) { ! charging = !release; ! jumping = release; } END_KEYBOARD_CB Index: tux.c =================================================================== RCS file: /cvsroot/tuxracer/tuxracer/src/tux.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** tux.c 2000/04/02 21:42:02 1.6 --- tux.c 2000/08/28 00:53:07 1.7 *************** *** 47,51 **** void adjust_tux_joints( scalar_t turnFact, bool_t isBraking, scalar_t paddling_factor, scalar_t speed, ! vector_t net_force ) { scalar_t turning_angle[2] = {0., 0.}; --- 47,51 ---- void adjust_tux_joints( scalar_t turnFact, bool_t isBraking, scalar_t paddling_factor, scalar_t speed, ! vector_t net_force, scalar_t jump_factor ) { scalar_t turning_angle[2] = {0., 0.}; *************** *** 57,60 **** --- 57,61 ---- scalar_t force_angle = 0.; /* amount that legs move because of force */ scalar_t turn_leg_angle = 0.; /* amount legs move when turning */ + scalar_t jump_angle = 0.; /* move arms */ *************** *** 74,86 **** turning_angle[1] = max(turnFact,0.0) * MAX_ARM_ANGLE; /* Adjust arms for turning */ rotate_scene_node( tuxLeftShoulderJoint, 'z', belly_corr_fact * -min( braking_angle + paddling_angle + turning_angle[0], ! MAX_ARM_ANGLE ) ); rotate_scene_node( tuxRightShoulderJoint, 'z', belly_corr_fact * ! -min( braking_angle + paddling_angle + turning_angle[1], ! MAX_ARM_ANGLE ) ); --- 75,89 ---- turning_angle[1] = max(turnFact,0.0) * MAX_ARM_ANGLE; + jump_angle = MAX_ARM_ANGLE * (0.5 + 0.5*sin(M_PI*jump_factor*4-M_PI/2)); + /* Adjust arms for turning */ rotate_scene_node( tuxLeftShoulderJoint, 'z', belly_corr_fact * -min( braking_angle + paddling_angle + turning_angle[0], ! MAX_ARM_ANGLE ) + jump_angle ); rotate_scene_node( tuxRightShoulderJoint, 'z', belly_corr_fact * ! -min( braking_angle + paddling_angle + turning_angle[1], ! MAX_ARM_ANGLE ) + jump_angle ); Index: tux.h =================================================================== RCS file: /cvsroot/tuxracer/tuxracer/src/tux.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** tux.h 2000/04/02 21:42:02 1.5 --- tux.h 2000/08/28 00:53:07 1.6 *************** *** 28,32 **** void adjust_tux_joints( scalar_t turnFact, bool_t isBraking, scalar_t paddling_factor, scalar_t speed, ! vector_t net_force ); void load_tux(); void draw_tux(); --- 28,32 ---- void adjust_tux_joints( scalar_t turnFact, bool_t isBraking, scalar_t paddling_factor, scalar_t speed, ! vector_t net_force, scalar_t jump_factor ); void load_tux(); void draw_tux(); Index: tuxracer.h =================================================================== RCS file: /cvsroot/tuxracer/tuxracer/src/tuxracer.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -r1.10 -r1.11 *** tuxracer.h 2000/08/27 20:16:42 1.10 --- tuxracer.h 2000/08/28 00:53:07 1.11 *************** *** 157,160 **** --- 157,161 ---- scalar_t paddle_time; /* time player started paddling */ bool_t jumping; + bool_t flying; bool_t jump_charging; scalar_t jump_amt; |