5 przeciwnikow, jakos to dziala
This commit is contained in:
@@ -1,20 +1,40 @@
|
||||
#include "../headers/Beam.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
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() {
|
||||
// Wiązka może mieć logikę do czasu, jeśli potrzebne
|
||||
}
|
||||
|
||||
void Beam::render(sf::RenderWindow& window) {
|
||||
if (visible) {
|
||||
window.draw(beamShape);
|
||||
}
|
||||
window.draw(beamSprite);
|
||||
}
|
||||
|
||||
sf::FloatRect Beam::getBounds() const {
|
||||
|
||||
Reference in New Issue
Block a user