add late flips
authorhgn <hgodden00@gmail.com>
Sun, 10 Dec 2023 15:14:50 +0000 (15:14 +0000)
committerhgn <hgodden00@gmail.com>
Sun, 10 Dec 2023 15:14:50 +0000 (15:14 +0000)
audio.h
player_skate.c
sound_src/lf0.ogg [new file with mode: 0644]
sound_src/lf1.ogg [new file with mode: 0644]
sound_src/lf2.ogg [new file with mode: 0644]
sound_src/lf3.ogg [new file with mode: 0644]

diff --git a/audio.h b/audio.h
index 5e29a96c08fc6503981dc104f07b4e433e1933db..0d025c8195e75ef7159dcf5fb7f7371b97c87092 100644 (file)
--- a/audio.h
+++ b/audio.h
@@ -30,6 +30,14 @@ audio_clip audio_taps[] =
    { .path="sound/tap3.ogg" }
 };
 
+audio_clip audio_flips[] =
+{
+   { .path="sound/lf0.ogg" },
+   { .path="sound/lf1.ogg" },
+   { .path="sound/lf2.ogg" },
+   { .path="sound/lf3.ogg" },
+};
+
 audio_clip audio_hits[] =
 {
    { .path="sound/hit0.ogg" },
@@ -143,6 +151,7 @@ static void audio_init(void)
 {
    audio_clip_loadn( audio_board, vg_list_size(audio_board), NULL );
    audio_clip_loadn( audio_taps, vg_list_size(audio_taps), NULL );
+   audio_clip_loadn( audio_flips, vg_list_size(audio_flips), NULL );
    audio_clip_loadn( audio_hits, vg_list_size(audio_hits), NULL );
    audio_clip_loadn( audio_ambience, vg_list_size(audio_ambience), NULL );
    audio_clip_loadn( &audio_splash, 1, NULL );
index 1ad7231609e2f0dcc2b5abd1a2a94d9e03ce63b8..c70d1f39b9ea4f4b0fbe91322ff7ea731670a4fd 100644 (file)
@@ -715,7 +715,7 @@ static void skate_apply_trick_model(void){
       if( v3_length2( state->trick_vel ) < 0.0001f )
          return;
 
-      int carry_on = player_skate_trick_input();
+      int carry_on = state->trick_type == player_skate_trick_input();
 
       /* we assume velocities share a common divisor, in which case the 
        * interval is the minimum value (if not zero) */
@@ -729,24 +729,29 @@ static void skate_apply_trick_model(void){
       }
 
       float interval = 1.0f / min_rate,
-            current  = floorf( state->trick_time / interval ),
-            next_end = (current+1.0f) * interval;
+            current  = floorf( state->trick_time ),
+            next_end = current+1.0f;
 
 
       /* integrate trick velocities */
       v3_muladds( state->trick_euler, state->trick_vel, k_rb_delta,
                   state->trick_euler );
 
-      if( !carry_on && (state->trick_time + k_rb_delta >= next_end) ){
+      if( !carry_on && (state->trick_time + k_rb_delta/interval >= next_end) ){
          state->trick_time = 0.0f;
          state->trick_euler[0] = roundf( state->trick_euler[0] );
          state->trick_euler[1] = roundf( state->trick_euler[1] );
          state->trick_euler[2] = roundf( state->trick_euler[2] );
          v3_copy( state->trick_vel, state->trick_residualv );
          v3_zero( state->trick_vel );
-      }
 
-      state->trick_time += k_rb_delta;
+         audio_lock();
+         audio_oneshot_3d( &audio_flips[vg_randu32()%4], 
+               localplayer.rb.co, 40.0f, 1.0f );
+         audio_unlock();
+      }
+      else 
+         state->trick_time += k_rb_delta / interval;
    }
    else{
       if( (v3_length2(state->trick_vel) >= 0.0001f ) &&
@@ -1098,9 +1103,15 @@ static void player__skate_pre_update(void){
    if( state->activity <= k_skate_activity_air_to_grind ){
       enum trick_type trick = k_trick_type_none;
       if( (trick = player_skate_trick_input()) ){
-         if( (vg.time - state->jump_time) < 0.1f ){
+         if( state->trick_time == 0.0f ){
+            audio_lock();
+            audio_oneshot_3d( &audio_flips[vg_randu32()%4], 
+                  localplayer.rb.co, 40.0f, 1.0f );
+            audio_unlock();
+         }
+
+         if( state->trick_time < 0.1f ){
             v3_zero( state->trick_vel );
-            state->trick_time = 0.0f;
 
             if( trick == k_trick_type_kickflip ){
                state->trick_vel[0] = 3.0f;
@@ -2629,7 +2640,8 @@ static void player__skate_im_gui(void){
                            state->trick_vel[0],
                            state->trick_vel[1],
                            state->trick_vel[2] );
-   player__debugtext( 1, "tricke: %.2f %.2f %.2f", 
+   player__debugtext( 1, "tricke: %.2fs %.2f %.2f %.2f", 
+                           state->trick_time,
                            state->trick_euler[0],
                            state->trick_euler[1],
                            state->trick_euler[2] );
@@ -2805,10 +2817,14 @@ static void player__skate_animate(void){
    animator->subslap = vg_lerpf( animator->subslap, slapm, 
                                  vg.time_delta*10.0f );
 
+#if 0
    f32 l = ((state->activity < k_skate_activity_ground) &&
              v3_length2(state->trick_vel) > 0.1f )? 1: 0;
    animator->trick_foot = vg_lerpf( animator->trick_foot, l, 
                                     8.4f*vg.time_delta );
+#endif
+
+   animator->trick_foot = vg_exp_impulse( state->trick_time, 5.0f );
 
    /* grab */
    v2f grab_input;
@@ -3052,15 +3068,18 @@ static void player__skate_pose( void *_animator, player_pose *pose ){
    kf_board->co[1]  += animator->slap * animator->subslap;
    kf_hip->co[1] += animator->slap * 0.25f;
 
+   /* kickflip and shuvit are in the wrong order for some reason */
    if( animator->trick_type == k_trick_type_kickflip ){
-      kf_foot_l->co[0] += animator->trick_foot * 0.2f;
+      kf_foot_l->co[0] += animator->trick_foot * 0.15f;
+      kf_foot_r->co[0] -= animator->trick_foot * 0.15f;
       kf_foot_l->co[1] -= animator->trick_foot * 0.18f;
+      kf_foot_r->co[1] -= animator->trick_foot * 0.18f;
    }
    else if( animator->trick_type == k_trick_type_shuvit ){
-      kf_foot_l->co[0] += animator->trick_foot * 0.1f;
-      kf_foot_r->co[0] -= animator->trick_foot * 0.15f;
+      kf_foot_l->co[0] += animator->trick_foot * 0.2f;
       kf_foot_l->co[1] -= animator->trick_foot * 0.18f;
-      kf_foot_r->co[1] -= animator->trick_foot * 0.18f;
+      kf_foot_r->co[0] -= animator->trick_foot * 0.1f;
+      kf_foot_r->co[1] += animator->trick_foot * 0.09f;
    }
    else if( animator->trick_type == k_trick_type_treflip ){
       kf_foot_l->co[0] += animator->trick_foot * 0.2f;
diff --git a/sound_src/lf0.ogg b/sound_src/lf0.ogg
new file mode 100644 (file)
index 0000000..e291439
Binary files /dev/null and b/sound_src/lf0.ogg differ
diff --git a/sound_src/lf1.ogg b/sound_src/lf1.ogg
new file mode 100644 (file)
index 0000000..d0ea026
Binary files /dev/null and b/sound_src/lf1.ogg differ
diff --git a/sound_src/lf2.ogg b/sound_src/lf2.ogg
new file mode 100644 (file)
index 0000000..03d3562
Binary files /dev/null and b/sound_src/lf2.ogg differ
diff --git a/sound_src/lf3.ogg b/sound_src/lf3.ogg
new file mode 100644 (file)
index 0000000..00f6e48
Binary files /dev/null and b/sound_src/lf3.ogg differ