player can only adjust movement when on the ground

This commit is contained in:
Sara 2023-10-25 14:11:43 +02:00
parent 8efbcee7f3
commit 75e5feecf2

View file

@ -10,8 +10,6 @@
static Vector _directional = ZeroVector;
static Spritesheet* spr_player_standing = NULL;
static const int _ground_face = 7;
static
void player_input_h(int val) {
_directional.x = val * 10.f;
@ -58,7 +56,7 @@ void player_start(Player* self) {
void player_update(Player* self, float dt) {
Vector velocity = rigidbody_get_velocity(self->rigidbody);
Vector velocity_target = {_directional.x, velocity.y};
Vector velocity_target = {self->is_grounded ? _directional.x : velocity.x, velocity.y};
if(_directional.y < 0 && self->is_grounded) {
_directional.y = 0;
velocity.y = -20.f;