diff --git a/.env b/.env index ebf65aa..6fc2b7d 100644 --- a/.env +++ b/.env @@ -1,2 +1,2 @@ SDL_VIDEODRIVER=x11 -#RESOLUTION=1920x1080 \ No newline at end of file +RESOLUTION=1920x1080 \ No newline at end of file diff --git a/rats.py b/rats.py index c50815a..fa8ba03 100644 --- a/rats.py +++ b/rats.py @@ -32,6 +32,13 @@ class MiceMaze(controls.KeyBindings): for _ in range(5): 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): if position is None: position = self.choose_start() @@ -69,7 +76,7 @@ class MiceMaze(controls.KeyBindings): return True - if len(self.units) >= 150: + if self.count_rats() > 200: self.stop_sound() self.play_sound("WEWIN.WAV") self.game_end = (True, False) @@ -107,7 +114,7 @@ class MiceMaze(controls.KeyBindings): unit.move() unit.collisions() 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.engine.new_cycle(50, self.update_maze) diff --git a/scores.txt b/scores.txt index 098fd85..f1cd5fb 100644 --- a/scores.txt +++ b/scores.txt @@ -7,3 +7,5 @@ 2024-12-23 01:32:09.317053 - 25 2024-12-23 01:34:24.777185 - 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 diff --git a/units/bomb.py b/units/bomb.py index 87458c2..c9b31d5 100644 --- a/units/bomb.py +++ b/units/bomb.py @@ -59,7 +59,10 @@ class Timer(Bomb): if not unit: unit = self self.game.play_sound("BOMB.WAV") - self.game.units.pop(unit.id) + try: + self.game.units.pop(unit.id) + except: + print(f"Unit {unit.id} already dead") self.game.spawn_unit(Explosion, unit.position) for direction in ["N", "S", "E", "W"]: x, y = unit.position