diff --git a/engine/sdl2.py b/engine/sdl2.py index cabdf80..8e3d150 100644 --- a/engine/sdl2.py +++ b/engine/sdl2.py @@ -12,9 +12,9 @@ class GameWindow: self.width = width * cell_size self.height = height * cell_size print(f"Screen size: {self.width}x{self.height}") - self.delay = 50 + self.delay = 10 sdl2.ext.init() - self.window = sdl2.ext.Window(title=title, size=(self.width, self.height), flags=sdl2.SDL_WINDOW_FULLSCREEN) + self.window = sdl2.ext.Window(title=title, size=(self.width, self.height),)# flags=sdl2.SDL_WINDOW_FULLSCREEN) self.window.show() self.renderer = sdl2.ext.Renderer(self.window, flags=sdl2.SDL_RENDERER_ACCELERATED) self.factory = sdl2.ext.SpriteFactory(renderer=self.renderer) @@ -85,4 +85,4 @@ class GameWindow: self.running = False # Disegna qui gli sprite self.renderer.present() -# time.sleep(self.delay / 1000) + sdl2.SDL_Delay(self.delay) diff --git a/rats.py b/rats.py index eb72f6e..1b8e3a5 100644 --- a/rats.py +++ b/rats.py @@ -17,7 +17,7 @@ class MiceMaze: self.units = {} self.unit_positions = {} self.unit_positions_before = {} - for _ in range(50): + for _ in range(5): self.new_rat() def new_rat(self, position=None): diff --git a/units/__pycache__/rat.cpython-313.pyc b/units/__pycache__/rat.cpython-313.pyc index d202cc5..d749aa5 100644 Binary files a/units/__pycache__/rat.cpython-313.pyc and b/units/__pycache__/rat.cpython-313.pyc differ diff --git a/units/rat.py b/units/rat.py index 8729553..8eeff9e 100644 --- a/units/rat.py +++ b/units/rat.py @@ -7,7 +7,7 @@ AGE_THRESHOLD = 200 SPEED_REDUCTION = 0.5 PREGNANCY_DURATION = 500 BABY_INTERVAL = 50 -OVERLAP_TOLERANCE = 20 + class Rat(Unit): def __init__(self, game, position=(0,0), id=None): @@ -67,6 +67,7 @@ class Rat(Unit): self.direction = self.calculate_rat_direction() def collisions(self): + OVERLAP_TOLERANCE = self.game.cell_size // 4 if self.age < AGE_THRESHOLD: return units = []