Naprawiono laser, przerobiono na wskaźniki. Do refactoringu i poprawy sprite'a
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
#include "../headers/Plansza.h"
|
||||
|
||||
|
||||
Wiazkowiec::Wiazkowiec(int x, int y, const sf::Texture& texture) : Actor(x, y, texture), beam(0, 0, 50.f, 50.f, sf::Color::Red) {
|
||||
Wiazkowiec::Wiazkowiec(int x, int y, const sf::Texture& texture) : Actor(x, y, texture), beam(new Beam(0, 0, 50.f, 50.f)) {
|
||||
actorSprite.setTexture(texture);
|
||||
hp = 2; // 2 punkty życia
|
||||
firerate = 5000; // Strzela co 10
|
||||
@@ -27,29 +27,29 @@ void Wiazkowiec::spawnBeam() {
|
||||
case DirectionW::Up:
|
||||
beamHeight = position.y;
|
||||
beamY -= beamHeight;
|
||||
beam = Beam(beamX, beamY, beamWidth, beamHeight, sf::Color::Red);
|
||||
beam = new Beam(beamX, beamY, beamWidth, beamHeight);
|
||||
break;
|
||||
case DirectionW::Down:
|
||||
beamHeight = planszaHeight - position.y;
|
||||
beam = Beam(beamX, beamY, beamWidth, beamHeight, sf::Color::Red);
|
||||
beam = new Beam(beamX, beamY, beamWidth, beamHeight);
|
||||
break;
|
||||
case DirectionW::Left:
|
||||
beamHeight = 50.f;
|
||||
beamWidth = position.x;
|
||||
beamX -= beamWidth;
|
||||
beamY = position.y + (actorSprite.getGlobalBounds().height / 2) - 25.f;
|
||||
beam = Beam(beamX, beamY, beamWidth, beamHeight, sf::Color::Red);
|
||||
beam = new Beam(beamX, beamY, beamWidth, beamHeight);
|
||||
break;
|
||||
case DirectionW::Right:
|
||||
beamHeight = 50.f;
|
||||
beamWidth = 800 - position.x;
|
||||
beamY = position.y + (actorSprite.getGlobalBounds().height / 2) - 25.f;
|
||||
beam = Beam(beamX, beamY, beamWidth, beamHeight, sf::Color::Red);
|
||||
beam = new Beam(beamX, beamY, beamWidth, beamHeight);
|
||||
break;
|
||||
}
|
||||
|
||||
beam = Beam(beamX, beamY, beamWidth, beamHeight, sf::Color::Red);
|
||||
beam.setVisible(true);
|
||||
// beam = Beam(beamX, beamY, beamWidth, beamHeight, sf::Color::Red);
|
||||
beam->setVisible(true);
|
||||
|
||||
shooting = true;
|
||||
shootingClock.restart();
|
||||
@@ -133,7 +133,7 @@ void Wiazkowiec::update() {
|
||||
if (shooting) {
|
||||
// Kontrola zakończenia strzału
|
||||
if (shootingClock.getElapsedTime().asSeconds() >= beamDuration) {
|
||||
beam.setVisible(false);
|
||||
beam->setVisible(false);
|
||||
shooting = false;
|
||||
setRandomDirection(); // Zmień kierunek po strzale
|
||||
}
|
||||
@@ -164,8 +164,8 @@ void Wiazkowiec::update() {
|
||||
|
||||
// Ustawianie widoczności wiązki podczas renderowania
|
||||
void Wiazkowiec::render(sf::RenderWindow& window) {
|
||||
if (beam.isVisible()) {
|
||||
beam.render(window);
|
||||
if (beam->isVisible()) {
|
||||
beam->render(window);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,6 +184,6 @@ bool Wiazkowiec::isShooting() const {
|
||||
return shooting;
|
||||
}
|
||||
|
||||
const Beam& Wiazkowiec::getBeam() const {
|
||||
const Beam* Wiazkowiec::getBeam() const {
|
||||
return beam;
|
||||
}
|
||||
Reference in New Issue
Block a user