(Underdepths) Pass 5

This commit is contained in:
AlexKucera committed 2026-08-14 09:46:04 +02:00
1 parent 05e340dec2
commit b6d2a058e3
53 files changed
+5020

No files matched your search

+49
View File
@@ -0,0 +1,49 @@
#!/usr/bin/env python3
"""Comprehensive demo frame: equipped player, all 7 enemies, combat log, on stairs.
Gives vision a fair read and serves as the recording reference pose."""
from __future__ import annotations
import os, sys
os.environ.setdefault("SDL_VIDEODRIVER", "dummy"); os.environ.setdefault("SDL_AUDIODRIVER", "dummy")
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))); sys.path.insert(0, ROOT)
import pygame; pygame.init()
from main import new_game, SCREEN_W, SCREEN_H
from data import enemies as E, items as I
from engine import actions as act
from render.renderer import Renderer
from render.camera import Camera
SHOTS = os.path.join(ROOT, ".shots"); os.makedirs(SHOTS, exist_ok=True)
R = Renderer(); cam = Camera()
def reveal(gm):
for y in range(gm.height):
for x in range(gm.width): gm.explored[y][x] = True
def shoot(s, name):
surf = pygame.Surface((SCREEN_W, SCREEN_H)); cam.reset((s.player.x, s.player.y))
off = cam.offset_for((SCREEN_W, SCREEN_H), (s.player.x, s.player.y)); R.render(surf, s, camera_xy=off)
p = os.path.join(SHOTS, name); pygame.image.save(surf, p); print(" saved", p)
s = new_game(seed=5); gm = s.dungeon[3]; s.current_floor = 3; reveal(gm)
# gear up so equipment ICONS are populated
s.player.equip(I.make_item("war_hammer", 0, 0))
s.player.equip(I.make_item("plate_armor", 0, 0))
# place player ON the stairs (-> "Press F to descend") with an item adjacent
sx, sy = gm.stairs_down
s.player.x, s.player.y = sx, sy
# sprinkle all 7 enemy kinds in a cluster around the player (within sight)
kinds = ["rat","goblin","skeleton_archer","orc_warrior","wraith","green_slime","small_slime"]
spots = [(2,0),(-2,0),(0,2),(0,-2),(2,2),(-2,-2),(2,-2)]
for k,(dx,dy) in zip(kinds, spots):
tx, ty = sx+dx, sy+dy
if 0<=tx<gm.width and 0<=ty<gm.height and gm.walkable(tx,ty):
gm.entities.append(E.make_enemy(k, tx, ty))
# an item on a near tile
for (ix,iy) in [(sx+1,sy),(sx-1,sy),(sx,sy+1)]:
if gm.walkable(ix,iy): gm.entities.append(I.make_item("healing_potion", ix, iy)); break
# generate colored combat log lines by attacking a couple of adjacent enemies
for _ in range(4): act.apply_input(s, "left")
act.apply_input(s, "right")
# return the player ONTO the stairs so the F-prompt + translucent stairs-peek show
s.player.x, s.player.y = sx, sy
shoot(s, "demo_full.png")
print(f" equipped: {s.player.equipped_weapon.name}, {s.player.equipped_armor.name}; log lines: {len(s.log)}")
print(" last log:", s.log[-3:] if s.log else [])