Aggiungi la funzione count_rats per contare i ratti e aggiorna la logica di gioco; modifica la risoluzione nel file .env e gestisci eccezioni nel metodo pop di Timer
This commit is contained in:
@@ -1,2 +1,2 @@
|
|||||||
SDL_VIDEODRIVER=x11
|
SDL_VIDEODRIVER=x11
|
||||||
#RESOLUTION=1920x1080
|
RESOLUTION=1920x1080
|
||||||
@@ -32,6 +32,13 @@ class MiceMaze(controls.KeyBindings):
|
|||||||
for _ in range(5):
|
for _ in range(5):
|
||||||
self.new_rat()
|
self.new_rat()
|
||||||
|
|
||||||
|
def count_rats(self):
|
||||||
|
count = 0
|
||||||
|
for unit in self.units.values():
|
||||||
|
if isinstance(unit, rat.Rat):
|
||||||
|
count += 1
|
||||||
|
return count
|
||||||
|
|
||||||
def new_rat(self, position=None):
|
def new_rat(self, position=None):
|
||||||
if position is None:
|
if position is None:
|
||||||
position = self.choose_start()
|
position = self.choose_start()
|
||||||
@@ -69,7 +76,7 @@ class MiceMaze(controls.KeyBindings):
|
|||||||
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
if len(self.units) >= 150:
|
if self.count_rats() > 200:
|
||||||
self.stop_sound()
|
self.stop_sound()
|
||||||
self.play_sound("WEWIN.WAV")
|
self.play_sound("WEWIN.WAV")
|
||||||
self.game_end = (True, False)
|
self.game_end = (True, False)
|
||||||
@@ -107,7 +114,7 @@ class MiceMaze(controls.KeyBindings):
|
|||||||
unit.move()
|
unit.move()
|
||||||
unit.collisions()
|
unit.collisions()
|
||||||
unit.draw()
|
unit.draw()
|
||||||
self.engine.update_status(f"Mice: {len(self.units)} - Points: {self.points}")
|
self.engine.update_status(f"Mice: {self.count_rats()} - Points: {self.points}")
|
||||||
self.scroll()
|
self.scroll()
|
||||||
self.engine.new_cycle(50, self.update_maze)
|
self.engine.new_cycle(50, self.update_maze)
|
||||||
|
|
||||||
|
|||||||
@@ -7,3 +7,5 @@
|
|||||||
2024-12-23 01:32:09.317053 - 25
|
2024-12-23 01:32:09.317053 - 25
|
||||||
2024-12-23 01:34:24.777185 - 25
|
2024-12-23 01:34:24.777185 - 25
|
||||||
2024-12-23 01:37:35.727860 - 25
|
2024-12-23 01:37:35.727860 - 25
|
||||||
|
2024-12-23 17:12:37.473315 - 80
|
||||||
|
2024-12-23 17:15:08.337754 - 50
|
||||||
|
|||||||
@@ -59,7 +59,10 @@ class Timer(Bomb):
|
|||||||
if not unit:
|
if not unit:
|
||||||
unit = self
|
unit = self
|
||||||
self.game.play_sound("BOMB.WAV")
|
self.game.play_sound("BOMB.WAV")
|
||||||
|
try:
|
||||||
self.game.units.pop(unit.id)
|
self.game.units.pop(unit.id)
|
||||||
|
except:
|
||||||
|
print(f"Unit {unit.id} already dead")
|
||||||
self.game.spawn_unit(Explosion, unit.position)
|
self.game.spawn_unit(Explosion, unit.position)
|
||||||
for direction in ["N", "S", "E", "W"]:
|
for direction in ["N", "S", "E", "W"]:
|
||||||
x, y = unit.position
|
x, y = unit.position
|
||||||
|
|||||||
Reference in New Issue
Block a user