Do poprawy centrowanie lasera i strzelanie w lewo i w prawo
This commit is contained in:
@@ -2,50 +2,16 @@
|
||||
|
||||
#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);
|
||||
Beam::Beam(int x, int y, const sf::Texture& texture) {
|
||||
if (texture.getSize().x > 0 && texture.getSize().y > 0) {
|
||||
beamSprite.setPosition(x, y);
|
||||
} else {
|
||||
std::cerr << "Błąd: Tekstura wiązki nie została poprawnie załadowana." << std::endl;
|
||||
}
|
||||
|
||||
beamSprite.setTexture(texture);
|
||||
}
|
||||
|
||||
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;
|
||||
sf::Sprite Beam::getSprite() {
|
||||
return beamSprite;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user