This commit is contained in:
2024-12-20 19:39:18 +01:00
parent 76203a8b29
commit 0a5a26208a
2 changed files with 6 additions and 7 deletions

View File

@@ -1,8 +1,8 @@
#include "../headers/Wiazkowiec.h"
#include "../headers/Plansza.h"
#include "../headers/RandomNumberGenerator.h"
#include <iostream>
#include <random>
#include "../headers/Plansza.h"
Wiazkowiec::Wiazkowiec(int x, int y, const sf::Texture &texture) : Actor(x, y, texture),
@@ -49,7 +49,6 @@ void Wiazkowiec::spawnBeam() {
break;
}
// beam = Beam(beamX, beamY, beamWidth, beamHeight, sf::Color::Red);
beam->setVisible(true);
shooting = true;
@@ -67,7 +66,7 @@ void Wiazkowiec::shoot() {
void Wiazkowiec::setRandomDirection() {
// Losowanie kierunku: 0 = Up, 1 = Down, 2 = Left, 3 = Right
switch (std::rand() % 4) {
switch (RandomNumberGenerator::getRandomNumber(0, 3)) {
case 0:
direction = DirectionW::Up;
break;
@@ -85,7 +84,7 @@ void Wiazkowiec::setRandomDirection() {
}
}
void Wiazkowiec::updateDirection() {
void Wiazkowiec::checkIfBeamShootOutOfBounds() {
auto spriteBounds = actorSprite.getGlobalBounds(); // Pobierz rozmiar i pozycję sprite'a
// Kontrola górnej i dolnej krawędzi
@@ -140,7 +139,7 @@ void Wiazkowiec::update() {
setRandomDirection(); // Zmień kierunek po strzale
}
} else {
updateDirection();
checkIfBeamShootOutOfBounds();
switch (direction) {
case DirectionW::Up: