A little code refactor

+ new bullet texture added
This commit is contained in:
2024-11-16 16:01:01 +01:00
parent a190e81ba2
commit fcabc0534a
6 changed files with 19 additions and 24 deletions

View File

@@ -1,5 +1,6 @@
#include "../headers/Actor.h"
// TODO: Naprawić krzywy sprite statku
Actor::Actor(int x, int y, std::string path) {
loadTexture(path);
position.x = x;
@@ -11,25 +12,20 @@ void Actor::loadTexture(std::string path) {
actorTexture.loadFromFile(path);
actorSprite.setTexture(actorTexture);
bulletTexture.loadFromFile("../assets/img/bullet.png");
bulletTextureLeft.loadFromFile("../assets/img/bullet.png");
bulletTextureRight.loadFromFile("../assets/img/bullet_right.png");
}
sf::Sprite &Actor::getSprite() {
return actorSprite;
}
void Actor::move(float deltaX, float deltaY) {}
void Actor::moveLeft() {}
void Actor::moveRight() {}
Position Actor::getPosition() {
return {position.x, position.y};
}
void Actor::shoot() {
bullets.emplace_back(float(position.x) + actorSprite.getGlobalBounds().width / 2-62, position.y, bulletTexture);
bullets.emplace_back(float(position.x) + actorSprite.getGlobalBounds().width / 2-62, position.y, bulletTextureLeft);
}
std::vector<Bullet> &Actor::getBullets() {