diff --git a/src/main/java/it/unibo/bombardero/core/impl/BasicBombarderoGameManager.java b/src/main/java/it/unibo/bombardero/core/impl/BasicBombarderoGameManager.java index 0a7530ab..7b3f6ba6 100644 --- a/src/main/java/it/unibo/bombardero/core/impl/BasicBombarderoGameManager.java +++ b/src/main/java/it/unibo/bombardero/core/impl/BasicBombarderoGameManager.java @@ -88,16 +88,16 @@ public void updateGame(final long elapsed) { ce.checkCharacterCollision(player, this.getGameMap()); ce.checkFlameAndPowerUpCollision(player, this.getGameMap()); } - if (!boombs.isEmpty()) { - boombs.entrySet().forEach(entry -> entry.getKey().update()); - placeBombExplosion(); - } if (!flames.isEmpty()) { flames.forEach(f -> f.update(elapsed)); flames.stream().filter(f -> f.isExpired()) .forEach(f -> map.removeFlame(f.getPos())); flames.removeIf(f -> f.isExpired()); } + if (!boombs.isEmpty()) { + boombs.entrySet().forEach(entry -> entry.getKey().update()); + placeBombExplosion(); + } enemies.forEach(enemy -> { if (enemy.isAlive()) { enemy.update(this, elapsed); @@ -112,11 +112,10 @@ public void updateGame(final long elapsed) { } if (!flames.isEmpty()) { flames.forEach(f -> f.update(elapsed)); - List.copyOf(flames) - .stream() + flames.stream() .filter(f -> f.isExpired()) - .peek(f -> flames.remove(f)) .forEach(f -> map.removeFlame(f.getPos())); + flames.removeIf(f -> f.isExpired()); } }