41 lines
1.1 KiB
C
41 lines
1.1 KiB
C
#include "EnemyStates.h"
|
|
#include "Enemy.h"
|
|
#include "animation_sprite.h"
|
|
#include "program.h"
|
|
|
|
void EnemyState_Exit(Enemy* self) {}
|
|
|
|
void EnemyIdle_Enter(Enemy* self) {
|
|
self->currentAnimation = self->idleAnim;
|
|
animation_sprite_play_from(self->currentAnimation, 0.f);
|
|
}
|
|
|
|
const State* EnemyIdle_Update(Enemy* self, float deltaTime) {
|
|
// state transitions
|
|
if(self->stun_time >= game_time())
|
|
return EnemyHurt();
|
|
return EnemyIdle();
|
|
}
|
|
|
|
void EnemyWalk_Enter(Enemy* self) {
|
|
self->currentAnimation = self->walkAnim;
|
|
animation_sprite_play_from(self->currentAnimation, 0.f);
|
|
}
|
|
|
|
const State* EnemyWalk_Update(Enemy* self, float deltaTime) {
|
|
return EnemyWalk();
|
|
}
|
|
|
|
void EnemyHurt_Enter(Enemy* self) {
|
|
self->currentAnimation = self->hurtAnim;
|
|
animation_sprite_play_from(self->currentAnimation, 0.f);
|
|
}
|
|
|
|
const State* EnemyHurt_Update(Enemy* self, float deltaTime) {
|
|
const float time = animation_sprite_get_time(self->currentAnimation);
|
|
// state transitions
|
|
if(self->stun_time < game_time())
|
|
return EnemyIdle();
|
|
return EnemyHurt();
|
|
}
|