Enhance blood stain mechanics: add dynamic blood surface generation and integrate blood stains into game rendering
This commit is contained in:
+30
-8
@@ -22,15 +22,37 @@ class Graphics():
|
||||
|
||||
def draw_maze(self):
|
||||
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.render_engine.create_texture(texture_tiles)
|
||||
print("Generating background texture")
|
||||
self.regenerate_background()
|
||||
self.render_engine.draw_background(self.background_texture)
|
||||
|
||||
def regenerate_background(self):
|
||||
"""Generate or regenerate the background texture with all permanent elements"""
|
||||
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))
|
||||
|
||||
# Add blood stains if any exist
|
||||
if hasattr(self, 'blood_stains'):
|
||||
for position, blood_surface in self.blood_stains.items():
|
||||
texture_tiles.append((blood_surface, position[0]*self.cell_size, position[1]*self.cell_size))
|
||||
|
||||
self.background_texture = self.render_engine.create_texture(texture_tiles)
|
||||
|
||||
def add_blood_stain(self, position):
|
||||
"""Add a blood stain to the background at the specified position"""
|
||||
if not hasattr(self, 'blood_stains'):
|
||||
self.blood_stains = {}
|
||||
|
||||
# Generate blood surface
|
||||
blood_surface = self.render_engine.generate_blood_surface()
|
||||
self.blood_stains[position] = blood_surface
|
||||
|
||||
# Regenerate background to include the new blood stain
|
||||
self.regenerate_background()
|
||||
|
||||
def scroll_cursor(self, x=0, y=0):
|
||||
if self.pointer[0] + x > self.map.width or self.pointer[1] + y > self.map.height:
|
||||
|
||||
Reference in New Issue
Block a user