player can only adjust movement when on the ground
This commit is contained in:
parent
8efbcee7f3
commit
75e5feecf2
|
@ -10,8 +10,6 @@
|
||||||
static Vector _directional = ZeroVector;
|
static Vector _directional = ZeroVector;
|
||||||
static Spritesheet* spr_player_standing = NULL;
|
static Spritesheet* spr_player_standing = NULL;
|
||||||
|
|
||||||
static const int _ground_face = 7;
|
|
||||||
|
|
||||||
static
|
static
|
||||||
void player_input_h(int val) {
|
void player_input_h(int val) {
|
||||||
_directional.x = val * 10.f;
|
_directional.x = val * 10.f;
|
||||||
|
@ -58,7 +56,7 @@ void player_start(Player* self) {
|
||||||
|
|
||||||
void player_update(Player* self, float dt) {
|
void player_update(Player* self, float dt) {
|
||||||
Vector velocity = rigidbody_get_velocity(self->rigidbody);
|
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) {
|
if(_directional.y < 0 && self->is_grounded) {
|
||||||
_directional.y = 0;
|
_directional.y = 0;
|
||||||
velocity.y = -20.f;
|
velocity.y = -20.f;
|
||||||
|
|
Loading…
Reference in a new issue