#include "../headers/Beam.h" #include Beam::Beam(float x, float y, float width, float height, const sf::Color& color) : visible(false) { beamShape.setPosition(x, y); beamShape.setSize({width, height}); beamShape.setFillColor(color); if (!beamTexture.loadFromFile("../assets/img/wiazka/wiazka.png")) { std::cerr << "Błąd! Nie można załadować tekstury wiazka.png" << std::endl; } beamSprite.setTexture(beamTexture); if (beamTexture.getSize().x > 0 && beamTexture.getSize().y > 0) { float scaleX = width / beamTexture.getSize().x; float scaleY = height / beamTexture.getSize().y; beamSprite.setScale(scaleX, scaleY); beamSprite.setPosition(x, y); } else { std::cerr << "Błąd: Tekstura wiązki nie została poprawnie załadowana." << std::endl; } } void Beam::draw(sf::RenderWindow& window) { window.draw(beamSprite); } void Beam::update() { } void Beam::render(sf::RenderWindow& window) { window.draw(beamSprite); } sf::FloatRect Beam::getBounds() const { return beamShape.getGlobalBounds(); } bool Beam::isVisible() const { return visible; } void Beam::setVisible(bool visible) { this->visible = visible; }