Add semi-transparent tunnel cover overlay for internal passages

- Add sdl2.create_overlay_texture() and draw_overlay_texture(alpha) for
  transparent full-map overlays built from sub-tile surface blits.
- Add Graphics.regenerate_tunnel_cover() which builds an overlay of
  4 random grass sub-tiles (20x20) for every internal tunnel cell,
  defined as a tunnel cell surrounded by occupied cells (wall or
  tunnel) on all four sides. Cells with at least one open side are
  handled by cave_foreground and skipped here.
- Draw the tunnel cover in the game loop after top-layer units/effects
  but before cave_foreground and points, at 95% opacity (alpha=242)
  so the unit and effect passing underneath is just barely visible.
This commit is contained in:
2026-06-16 22:41:11 +02:00
parent 62a65f599d
commit 2eccf504f5
3 changed files with 104 additions and 1 deletions
+7 -1
View File
@@ -62,6 +62,7 @@ class MiceMaze:
self.scrolling = False
self.sounds = {}
self.background_texture = None
self.tunnel_cover_texture = None
self.combined_scores = None
def _setup_engine(self):
@@ -527,12 +528,17 @@ class MiceMaze:
if getattr(unit, "draw_on_top", False) and not getattr(unit, "draw_last", False):
unit.draw()
# Draw tunnel cover overlay above units/effects but below cave foreground and points
self.render_engine.draw_overlay_texture(self.graphics.tunnel_cover_texture, alpha=191)
# Draw cave foreground (tunnel entrances) above the tunnel cover
self.graphics.draw_cave_foreground()
# Draw foreground/last-layer units (points) on top of everything
for unit in sorted_units:
if getattr(unit, "draw_last", False):
unit.draw()
self.graphics.draw_cave_foreground()
self.render_engine.draw_pointer(self.pointer[0] * self.cell_size, self.pointer[1] * self.cell_size)
self.render_engine.update_status(f"Mice: {self.unit_manager.count_rats()} - Points: {self.points}")