New Projectiles class

Refactor of Bullet class
Different method of shooting.
This commit is contained in:
2024-12-01 17:44:25 +01:00
parent 2f6c98f4be
commit 2341c2fa6d
11 changed files with 127 additions and 62 deletions

23
sources/Projectile.cpp Normal file
View File

@@ -0,0 +1,23 @@
#include "../headers/Projectile.h"
Projectile::Projectile(float x, float y, sf::Texture &texture) {
position.x = x;
position.y = y;
outOfBounds = false;
sprite.setTexture(texture);
sprite.setOrigin(sprite.getLocalBounds().width/2, sprite.getLocalBounds().height/2);
sprite.setPosition(x, y);
speed = -10.0f;
}
sf::Sprite &Projectile::getSprite() {
return sprite;
}
void Projectile::setSpeed(float speed) {
this->speed = speed;
}
bool Projectile::isOutOfBounds() const {
return outOfBounds;
}