Niby strzela, ale bez kolizji
This commit is contained in:
@@ -159,7 +159,7 @@ void Plansza::update() {
|
||||
}
|
||||
// Ruch i renderowanie przeciwników
|
||||
for (auto it = enemies.begin(); it != enemies.end();) {
|
||||
it->moveDown(); // Przeciwnicy poruszają się w dół
|
||||
it->update(); // Aktualizacja kierunku i ruchu przeciwnika
|
||||
it->shoot();
|
||||
|
||||
// Rysowanie przeciwników
|
||||
@@ -173,6 +173,28 @@ void Plansza::update() {
|
||||
}
|
||||
}
|
||||
|
||||
for (auto& enemy : enemies) { // Lista przeciwników w grze
|
||||
enemy.shoot();
|
||||
enemy.updateBullets();
|
||||
for (auto& bullet : enemy.getBullets()) {
|
||||
bullet.update();
|
||||
window->draw(bullet.getSprite());
|
||||
}
|
||||
}
|
||||
|
||||
// Usuwanie pocisków, które są poza ekranem
|
||||
for (auto enemyIt = enemies.begin(); enemyIt != enemies.end(); ) {
|
||||
for (auto bulletIt = enemyIt->getBullets().begin(); bulletIt != enemyIt->getBullets().end();) {
|
||||
if (bulletIt->isOutOfBounds()) {
|
||||
bulletIt = enemyIt->getBullets().erase(bulletIt); // Usuwamy pocisk, który wyszedł poza ekran
|
||||
} else {
|
||||
++bulletIt;
|
||||
}
|
||||
}
|
||||
++enemyIt;
|
||||
}
|
||||
|
||||
|
||||
// Kolizje między pociskami gracza a przeciwnikami
|
||||
for (auto enemyIt = enemies.begin(); enemyIt != enemies.end();) {
|
||||
bool hit = false;
|
||||
|
||||
Reference in New Issue
Block a user