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/Bullet.cpp

23 lines
589 B
C++

#include "../headers/Bullet.h"
Bullet::Bullet(float x, float y, sf::Texture &texture) : Projectile(x, y, texture) {
// Ładowanie dźwięku wystrzału
if (!shootBuffer.loadFromFile("../assets/sounds/shoot.ogg")) {
// Obsługa błędu
}
shootSound.setBuffer(shootBuffer);
playShootSound(); // Odtwarzanie dźwięku wystrzału przy utworzeniu pocisku
}
void Bullet::update() {
sprite.move(0.0f, speed);
position.y += int(speed);
if (position.y < -100) {
outOfBounds = true;
}
}
void Bullet::playShootSound() {
shootSound.play();
}