Dodane regulacja prędkości i płynejsze poruszanie się

This commit is contained in:
2024-11-16 15:22:21 +01:00
parent 88fa5901b6
commit a190e81ba2
7 changed files with 99 additions and 49 deletions

View File

@@ -3,7 +3,6 @@
Bullet::Bullet(float x, float y, sf::Texture &bulletTexture) {
outOfBounds = false;
// bulletTexture.loadFromFile("../assets/img/bullet.png");
bulletSprite.setTexture(bulletTexture);
bulletSprite.setPosition(x, y);
bulletSpeed = -10.0f;
@@ -21,9 +20,12 @@ sf::Sprite &Bullet::getSprite() {
void Bullet::update() {
bulletSprite.move(0.0f, bulletSpeed);
bulletPosition.y += bulletSpeed;
bulletPosition.y += int(bulletSpeed);
if(bulletPosition.y < -100) {
outOfBounds = true;
// std::cout << "Bullet out of bounds\n";
}
}
bool Bullet::getStatus() const {
return outOfBounds;
}