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

52 lines
1.2 KiB
C++

#include "../headers/Beam.h"
#include <iostream>
Beam::Beam(float x, float y, float width, float height)
: 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;
}