feat: tracking facing direction
This commit is contained in:
parent
b82c0a5765
commit
20c5d9dfe1
|
@ -1,12 +1,15 @@
|
|||
#include "PlayerStates.h"
|
||||
#include "Player.h"
|
||||
#include "physics_world.h"
|
||||
#include "debug.h"
|
||||
|
||||
static inline
|
||||
void InternalSpriteFlipWithMovement(Player* self) {
|
||||
if(self->moveInput.x > 0.f)
|
||||
sprite_flip_horizontal(self->sprite, 0);
|
||||
self->facing = 1;
|
||||
if(self->moveInput.x < -0.1f)
|
||||
sprite_flip_horizontal(self->sprite, 1);
|
||||
self->facing = -1;
|
||||
sprite_flip_horizontal(self->sprite, self->facing != 1);
|
||||
}
|
||||
|
||||
void PlayerAnimationExit(Player* self) {}
|
||||
|
@ -51,6 +54,11 @@ void PlayerJabA_Enter(Player* self) {
|
|||
PlayerAttackEnter(self);
|
||||
self->currentAnimation = self->jab_a;
|
||||
animation_sprite_play_from(self->currentAnimation, 0.f);
|
||||
|
||||
Collider* found = physics_world_box_query(vaddf(self->transform.position, MakeVector(self->facing * (0.2f + 0.05f), 0.f)),
|
||||
MakeVector(0.05f, 0.06f), PHYSICS_LAYER_DEFAULT, self->rigidbody);
|
||||
if(found != NULL)
|
||||
LOG_INFO("Query returned %p", found);
|
||||
}
|
||||
|
||||
const State* PlayerJabA_Update(Player* self, float deltaTime) {
|
||||
|
|
Loading…
Reference in a new issue