#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}; } 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; }