#include "../headers/Actor.h" #include Actor::Actor(int x, int y, const sf::Texture& texture) { actorSprite.setTexture(texture); position.x = x; position.y = y; actorSprite.setOrigin(actorSprite.getLocalBounds().width / 2, actorSprite.getLocalBounds().height / 2); // wycentrowanie sprite actorSprite.setPosition(float(x), float(y)); } sf::Sprite &Actor::getSprite() { if (!actorSprite.getTexture()) { std::cerr << "actorSprite has no texture set!" << std::endl; } return actorSprite; } Position Actor::getPosition() { return {position.x, position.y}; } unsigned int Actor::getHP() { return hp; } void Actor::dealDamage() { if(damageDealClock.getElapsedTime().asSeconds() > 1.5) { if(hp > 0) { hp--; } damageDealClock.restart(); } } void Actor::healUP() { if(hp < 3){ hp++; } } std::vector &Actor::getBullets() { return bullets; } void Actor::updateBullets() { for (auto it = bullets.begin(); it != bullets.end(); ) { if (it->isOutOfBounds()) { it = bullets.erase(it); // Usuwa element i zwraca iterator na następny element } else { ++it; // Przechodzi do następnego elementu } } //std::cout << "Liczba pociskow: " << bullets.size() << std::endl; } void Actor::setMovingSpeed(float speed) { moving_speed = speed; }