#include "../headers/Enemy.h" #include "../headers/Bullet.h" Enemy::Enemy(int x, int y, std::string path) : Actor(x, y, path) { hp = 1; // Przeciwnik ma 1 punkt życia firerate = 1000; // Strzela co 1 sekundę moving_speed = 2.0f; // Prędkość ruchu przeciwnika } void Enemy::shoot() { if (shootClock.getElapsedTime().asMilliseconds() >= firerate) { bullets.emplace_back(position.x, position.y + 20, bulletTextureLeft); // Strzał w dół shootClock.restart(); } } void Enemy::move(float deltaX, float deltaY) { actorSprite.move(deltaX, deltaY); position.x += static_cast(deltaX); position.y += static_cast(deltaY); } void Enemy::moveLeft() { move(-moving_speed, 0.0f); } void Enemy::moveRight() { move(moving_speed, 0.0f); } void Enemy::moveUp() { move(0.0f, -moving_speed); } void Enemy::moveDown() { move(0.0f, moving_speed); } bool Enemy::isAlive() const { return alive; } void Enemy::takeDamage() { if (--hp <= 0) { alive = false; } }