Boss nie wylazi

This commit is contained in:
2025-01-14 15:38:02 +01:00
parent 8b8bfc9aed
commit 2539892b71
2 changed files with 9 additions and 10 deletions

View File

@@ -160,9 +160,9 @@ void Boss::setRandomDirection() {
direction = static_cast<BossDirection>(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<int>(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;
}
}