Enemigo rojo cambia color tras disparo

This commit is contained in:
luisgulo 2026-10-04 15:22:48 +02:00
parent 0830bc5d46
commit b25d67788e
2 changed files with 11 additions and 3 deletions

View File

@ -414,13 +414,21 @@ class Game:
self.entities.append(Enemy(5.0, y, destructible=False)) self.entities.append(Enemy(5.0, y, destructible=False))
def handle_collisions(self): def handle_collisions(self):
# Muerte por contacto con enemigo # Muerte por contacto de un enemigo con el Jugador O con el VORTEX
for entity in self.entities: for entity in self.entities:
if isinstance(entity, Enemy): if isinstance(entity, Enemy):
if ( # Colisión con el Jugador
touch_player = (
abs(entity.gx - self.player.gx) < 0.5 abs(entity.gx - self.player.gx) < 0.5
and abs(entity.gy - self.player.gy) < 0.5 and abs(entity.gy - self.player.gy) < 0.5
): )
# Colisión con el VORTEX
touch_vortex = (
abs(entity.gx - self.vortex.gx) < 0.6
and abs(entity.gy - self.vortex.gy) < 0.6
)
if touch_player or touch_vortex:
self.lives -= 1 self.lives -= 1
if self.lives > 0: if self.lives > 0:
self.reset_level() self.reset_level()

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB