Working on enemies and attack

This commit is contained in:
Vladislav Khorev committed 2026-04-15 10:00:16 +03:00
1 parent 493eb5a5d7
commit 984d7489d5
7 files changed
+855630 -24

No files matched your search

+12
View File
@@ -4,6 +4,8 @@
namespace ZL {
const float ATTACK_COOLDOWN_TIME = 3.0f;
void Character::loadAnimation(AnimationState state, const std::string& filename, const std::string& zipFile) {
auto& data = animations[state];
data.model.LoadFromFile(filename, zipFile);
@@ -83,6 +85,16 @@ void Character::update(int64_t deltaMs) {
resetAnim = true;
}
if (canAttack && attack == 0 && attack_cooldown < 0.f && currentState == AnimationState::ACTION_IDLE)
{
attack = 1;
attack_cooldown = ATTACK_COOLDOWN_TIME;
}
if (canAttack && attack_cooldown >= 0.f)
{
attack_cooldown = attack_cooldown - deltaMs / 1000.f;
}
if (attack == 1 && currentState == AnimationState::ACTION_IDLE)
{
currentState = AnimationState::ACTION_ATTACK;