This repository has been archived on 2025-06-06. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
LotoStatek/sources/Actor.cpp
Andrii Solianyk 2341c2fa6d New Projectiles class
Refactor of Bullet class
Different method of shooting.
2024-12-01 17:44:25 +01:00

42 lines
1023 B
C++

#include "../headers/Actor.h"
Actor::Actor(int x, int y, std::string path) {
loadTexture(path);
position.x = x;
position.y = y;
actorSprite.setOrigin(actorSprite.getLocalBounds().width / 2, actorSprite.getLocalBounds().height / 2); // wycentrowanie sprite
actorSprite.setPosition(float(x), float(y));
}
void Actor::loadTexture(std::string path) {
actorTexture.loadFromFile(path);
actorSprite.setTexture(actorTexture);
bulletTextureLeft.loadFromFile("../assets/img/bullet_left.png");
bulletTextureRight.loadFromFile("../assets/img/Rocket_111.png");
}
sf::Sprite &Actor::getSprite() {
return actorSprite;
}
Position Actor::getPosition() {
return {position.x, position.y};
}
std::vector<Bullet> &Actor::getBullets() {
return bullets;
}
void Actor::updateBullets() {
for (auto& bullet : bullets) {
if(bullet.isOutOfBounds()) {
bullets.erase(bullets.begin());
}
}
}
void Actor::setMovingSpeed(float speed) {
moving_speed = speed;
}