From 2539892b7192fc0237c805d92ca91b8c2b86132f Mon Sep 17 00:00:00 2001 From: Kuba Date: Tue, 14 Jan 2025 15:38:02 +0100 Subject: [PATCH] Boss nie wylazi --- sources/Boss.cpp | 12 ++++-------- sources/Plansza.cpp | 7 +++++-- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/sources/Boss.cpp b/sources/Boss.cpp index a6a5416..817de5b 100644 --- a/sources/Boss.cpp +++ b/sources/Boss.cpp @@ -160,9 +160,9 @@ void Boss::setRandomDirection() { direction = static_cast(randomValue); } while ( (direction == BossDirection::Left && position.x <= 0) || - (direction == BossDirection::Right && position.x >= planszaWidth) || + (direction == BossDirection::Right && position.x >= 600) || (direction == BossDirection::Up && position.y <= 0) || - (direction == BossDirection::Down && position.y >= planszaHeight) + (direction == BossDirection::Down && position.y >= 800) ); if (previousDirection == direction) { std::cerr << "Boss kept the same direction: " << static_cast(direction) << std::endl; @@ -173,18 +173,14 @@ void Boss::setRandomDirection() { void Boss::handleBounds() { if (position.x < 0) { - position.x = 0; direction = BossDirection::Right; - } else if (position.x > planszaWidth - actorSprite.getGlobalBounds().width) { - position.x = planszaWidth - actorSprite.getGlobalBounds().width; + } else if (position.x > 600 - actorSprite.getGlobalBounds().width) { direction = BossDirection::Left; } if (position.y < 0) { - position.y = 0; direction = BossDirection::Down; - } else if (position.y > planszaHeight - actorSprite.getGlobalBounds().height) { - position.y = planszaHeight - actorSprite.getGlobalBounds().height; + } else if (position.y > 800 - actorSprite.getGlobalBounds().height) { direction = BossDirection::Up; } } diff --git a/sources/Plansza.cpp b/sources/Plansza.cpp index bdb3452..22e102a 100644 --- a/sources/Plansza.cpp +++ b/sources/Plansza.cpp @@ -118,7 +118,7 @@ void Plansza::update() { spawn_hearts(); spawn_power_up(); // spawn_enemy(); - spawn_advanced_enemy(); + // spawn_advanced_enemy(); // spawn_wiazkowiec(); // spawn_bomber(); // spawn_kamikadze(); @@ -414,6 +414,9 @@ void Plansza::update() { } } + + + if (boss->isShooting() && boss->getBeam() != nullptr) { if (ship->getSprite().getGlobalBounds().intersects(boss->getBeam()->getSprite().getGlobalBounds())) { ship->takeDamage(); // Gracz otrzymuje obrażenia @@ -858,7 +861,7 @@ void Plansza::spawn_advanced_enemy() { } void Plansza::spawn_bomber() { - if (BomberSpawnClock.getElapsedTime().asSeconds() >= 30) { // Spawn co 10 sekund + if (BomberSpawnClock.getElapsedTime().asSeconds() >= 5) { // Spawn co 10 sekund int spawnX = RandomNumberGenerator::getRandomNumber(50, size.width - 50); Bomber bomber(spawnX, -50, BomberEnemyTexture, BombaTexture); bomber.setPlanszaHeight(size.height, size.width); // Przekazanie wysokości i szerokości okna