projects
/
carveJwlIkooP6JGAAIwe30JlM.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
add jumping
[carveJwlIkooP6JGAAIwe30JlM.git]
/
player_physics.h
diff --git
a/player_physics.h
b/player_physics.h
index 7594f13a50efe078ec2dc439fe5e4b124d9b1bde..b3cd9d5832699d675a617c2e3e679212a3bf3f1a 100644
(file)
--- a/
player_physics.h
+++ b/
player_physics.h
@@
-352,6
+352,17
@@
static void player_walk_physics(void)
}
phys->in_air = len==0?1:0;
}
phys->in_air = len==0?1:0;
+
+ if( !phys->in_air )
+ {
+ float const DOWNFORCE = -k_walk_downforce*VG_TIMESTEP_FIXED;
+ v3_muladds( phys->rb.v, (v3f){0.0f,-1.0f,0.0f}, DOWNFORCE, phys->rb.v );
+
+ if( vg_get_button("jump") )
+ {
+ phys->rb.v[1] = 5.0f;
+ }
+ }
v3_zero( phys->rb.w );
q_axis_angle( phys->rb.q, (v3f){0.0f,1.0f,0.0f}, -player.angles[0] );
v3_zero( phys->rb.w );
q_axis_angle( phys->rb.q, (v3f){0.0f,1.0f,0.0f}, -player.angles[0] );
@@
-374,7
+385,10
@@
static void player_walk_physics(void)
new_vel = vg_minf( zvel + amt, speed ),
diff = new_vel - vg_minf( zvel, speed );
new_vel = vg_minf( zvel + amt, speed ),
diff = new_vel - vg_minf( zvel, speed );
- v3_muladds( phys->rb.v, forward_dir, diff, phys->rb.v );
+ if( !phys->in_air )
+ {
+ v3_muladds( phys->rb.v, forward_dir, diff, phys->rb.v );
+ }
/* TODO move */
float walk_norm = 30.0f/(float)player.mdl.anim_walk->length,
/* TODO move */
float walk_norm = 30.0f/(float)player.mdl.anim_walk->length,
@@
-387,9
+401,12
@@
static void player_walk_physics(void)
{
player.walk_timer = 0.0f;
}
{
player.walk_timer = 0.0f;
}
-
- phys->rb.v[0] *= 1.0f - (VG_TIMESTEP_FIXED * k_walk_friction);
- phys->rb.v[2] *= 1.0f - (VG_TIMESTEP_FIXED * k_walk_friction);
+
+ if( !phys->in_air )
+ {
+ phys->rb.v[0] *= 1.0f - (VG_TIMESTEP_FIXED * k_walk_friction);
+ phys->rb.v[2] *= 1.0f - (VG_TIMESTEP_FIXED * k_walk_friction);
+ }
}
/*
}
/*