fix jump problem
authorhgn <hgodden00@gmail.com>
Thu, 1 Jun 2023 20:21:01 +0000 (21:21 +0100)
committerhgn <hgodden00@gmail.com>
Thu, 1 Jun 2023 20:21:01 +0000 (21:21 +0100)
player_walk.c
player_walk.h
web/guide.html [new file with mode: 0644]

index bacb48c42bb12203fdab132af5beb6eca3495bed..5c52f2d03004a6cc865d1191e91fcb3c5d231cb4 100644 (file)
@@ -317,6 +317,10 @@ VG_STATIC void player__walk_pre_update( player_instance *player )
          }
       }
    }
+   else if( button_down( k_srbind_jump ) && !player->immobile ){
+      w->state.jump_queued = 1;
+      w->state.jump_input_time = vg.time;
+   }
 }
 
 VG_STATIC int player_walk_normal_standable( player_instance *player, v3f n )
@@ -461,14 +465,19 @@ VG_STATIC void player__walk_update( player_instance *player )
       nominal_speed = k_walkspeed;
 
       /* jump */
-      if( button_down( k_srbind_jump ) ){
-         float d = v3_dot( player->basis[1], player->rb.v );
-         v3_muladds( player->rb.v, player->basis[1], -d, player->rb.v );
-         v3_muladds( player->rb.v, player->basis[1], 5.0f, player->rb.v );
-         w->state.activity = k_walk_activity_air;
-         prev_state = k_walk_activity_air;
-         accel_speed = k_walk_air_accel;
-         nominal_speed = k_airspeed;
+      if( w->state.jump_queued ){
+         w->state.jump_queued = 0;
+
+         f32 t = vg.time - w->state.jump_input_time;
+         if( t < PLAYER_JUMP_EPSILON ){
+            float d = v3_dot( player->basis[1], player->rb.v );
+            v3_muladds( player->rb.v, player->basis[1], -d, player->rb.v );
+            v3_muladds( player->rb.v, player->basis[1], 5.0f, player->rb.v );
+            w->state.activity = k_walk_activity_air;
+            prev_state = k_walk_activity_air;
+            accel_speed = k_walk_air_accel;
+            nominal_speed = k_airspeed;
+         }
       }
       else{
          player_friction( player->rb.v );
index 42cd760d67825f71f5fd38afc2a8e24716600a79..3e450bcc26f541182bdb613987f0d242e109caf7 100644 (file)
@@ -4,6 +4,8 @@
 #include "player_api.h"
 #include "rigidbody.h"
 
+#define PLAYER_JUMP_EPSILON 0.1     /* 100ms jump allowance */
+
 struct player_walk{
    rb_capsule collider;
 
@@ -35,6 +37,9 @@ struct player_walk{
 
       struct skeleton_anim *outro_anim;
       double outro_start_time;
+
+      int jump_queued;
+      f64 jump_input_time;
    }
    state,
    state_gate_storage;
diff --git a/web/guide.html b/web/guide.html
new file mode 100644 (file)
index 0000000..4933365
--- /dev/null
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ </head>
+
+ <body>
+  <h1>Workshop Guide - Custom boards</h1>
+  <p>
+   1. Installing the blender addon
+   2. Open the template board .blend
+   3. Configure the export settings
+   4. Create your art in GIMP
+   5. Compile the model
+   6. Test it out
+   7. Upload to the workshop
+  </p>
+ </body>
+</html>