Aggiungi supporto per la creazione e il disegno di texture di sfondo nel gioco
This commit is contained in:
@@ -31,6 +31,8 @@ class MiceMaze(controls.KeyBindings):
|
||||
self.sounds = {}
|
||||
for _ in range(5):
|
||||
self.new_rat()
|
||||
self.background_texture = None
|
||||
|
||||
|
||||
def count_rats(self):
|
||||
count = 0
|
||||
@@ -62,11 +64,17 @@ class MiceMaze(controls.KeyBindings):
|
||||
return random.choice(self._valid_positions)
|
||||
|
||||
def draw_maze(self):
|
||||
for y, row in enumerate(self.map.matrix):
|
||||
for x, cell in enumerate(row):
|
||||
variant = x*y % 4
|
||||
tile = self.grasses[variant] if cell else self.tunnel
|
||||
self.engine.draw_image(x * self.cell_size, y * self.cell_size, tile, tag="maze")
|
||||
if self.background_texture is None:
|
||||
|
||||
texture_tiles = []
|
||||
for y, row in enumerate(self.map.matrix):
|
||||
for x, cell in enumerate(row):
|
||||
variant = x*y % 4
|
||||
tile = self.grasses[variant] if cell else self.tunnel
|
||||
texture_tiles.append((tile, x*self.cell_size, y*self.cell_size))
|
||||
self.background_texture = self.engine.create_texture(texture_tiles)
|
||||
self.engine.draw_background(self.background_texture)
|
||||
|
||||
def game_over(self):
|
||||
if self.game_end[0]:
|
||||
if not self.game_end[1]:
|
||||
@@ -150,8 +158,8 @@ class MiceMaze(controls.KeyBindings):
|
||||
del self.sounds[key]
|
||||
|
||||
def graphics_load(self):
|
||||
self.tunnel = self.engine.load_image("Rat/BMP_TUNNEL.png")
|
||||
self.grasses = [self.engine.load_image(f"Rat/BMP_1_GRASS_{i+1}.png") for i in range(4)]
|
||||
self.tunnel = self.engine.load_image("Rat/BMP_TUNNEL.png", surface=True)
|
||||
self.grasses = [self.engine.load_image(f"Rat/BMP_1_GRASS_{i+1}.png", surface=True) for i in range(4)]
|
||||
self.rat_assets = {}
|
||||
self.bomb_assets = {}
|
||||
for sex in ["MALE", "FEMALE", "BABY"]:
|
||||
|
||||
Reference in New Issue
Block a user