Riduci il ritardo di rendering da 50 a 10 ms, modifica il numero di ratti generati da 50 a 5 e aggiorna la tolleranza di sovrapposizione in base alla dimensione della cella
This commit is contained in:
+3
-3
@@ -12,9 +12,9 @@ class GameWindow:
|
|||||||
self.width = width * cell_size
|
self.width = width * cell_size
|
||||||
self.height = height * cell_size
|
self.height = height * cell_size
|
||||||
print(f"Screen size: {self.width}x{self.height}")
|
print(f"Screen size: {self.width}x{self.height}")
|
||||||
self.delay = 50
|
self.delay = 10
|
||||||
sdl2.ext.init()
|
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.window.show()
|
||||||
self.renderer = sdl2.ext.Renderer(self.window, flags=sdl2.SDL_RENDERER_ACCELERATED)
|
self.renderer = sdl2.ext.Renderer(self.window, flags=sdl2.SDL_RENDERER_ACCELERATED)
|
||||||
self.factory = sdl2.ext.SpriteFactory(renderer=self.renderer)
|
self.factory = sdl2.ext.SpriteFactory(renderer=self.renderer)
|
||||||
@@ -85,4 +85,4 @@ class GameWindow:
|
|||||||
self.running = False
|
self.running = False
|
||||||
# Disegna qui gli sprite
|
# Disegna qui gli sprite
|
||||||
self.renderer.present()
|
self.renderer.present()
|
||||||
# time.sleep(self.delay / 1000)
|
sdl2.SDL_Delay(self.delay)
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ class MiceMaze:
|
|||||||
self.units = {}
|
self.units = {}
|
||||||
self.unit_positions = {}
|
self.unit_positions = {}
|
||||||
self.unit_positions_before = {}
|
self.unit_positions_before = {}
|
||||||
for _ in range(50):
|
for _ in range(5):
|
||||||
self.new_rat()
|
self.new_rat()
|
||||||
|
|
||||||
def new_rat(self, position=None):
|
def new_rat(self, position=None):
|
||||||
|
|||||||
Binary file not shown.
+2
-1
@@ -7,7 +7,7 @@ AGE_THRESHOLD = 200
|
|||||||
SPEED_REDUCTION = 0.5
|
SPEED_REDUCTION = 0.5
|
||||||
PREGNANCY_DURATION = 500
|
PREGNANCY_DURATION = 500
|
||||||
BABY_INTERVAL = 50
|
BABY_INTERVAL = 50
|
||||||
OVERLAP_TOLERANCE = 20
|
|
||||||
|
|
||||||
class Rat(Unit):
|
class Rat(Unit):
|
||||||
def __init__(self, game, position=(0,0), id=None):
|
def __init__(self, game, position=(0,0), id=None):
|
||||||
@@ -67,6 +67,7 @@ class Rat(Unit):
|
|||||||
self.direction = self.calculate_rat_direction()
|
self.direction = self.calculate_rat_direction()
|
||||||
|
|
||||||
def collisions(self):
|
def collisions(self):
|
||||||
|
OVERLAP_TOLERANCE = self.game.cell_size // 4
|
||||||
if self.age < AGE_THRESHOLD:
|
if self.age < AGE_THRESHOLD:
|
||||||
return
|
return
|
||||||
units = []
|
units = []
|
||||||
|
|||||||
Reference in New Issue
Block a user