capture.pyΒΆ
Part of Dodge the Creeps.
1"""Headless screenshot capture for Dodge the Creeps.
2
3Run from the repository root:
4 uv run python examples/ports/dodge_the_creeps/capture.py
5"""
6
7from __future__ import annotations
8
9import sys
10from pathlib import Path
11
12# Make the port's `nodes` package importable.
13HERE = Path(__file__).resolve().parent
14sys.path.insert(0, str(HERE))
15
16from main import HEIGHT, WIDTH, Main # noqa: E402
17
18from simvx.graphics import App, save_png # noqa: E402
19
20OUT = HERE / "screenshots"
21OUT.mkdir(exist_ok=True)
22
23FRAMES_TO_CAPTURE = [60, 119]
24
25app = App(width=WIDTH, height=HEIGHT, title="Dodge the Creeps", visible=False)
26captured = app.run_headless(Main(), frames=120, capture_frames=FRAMES_TO_CAPTURE)
27
28for idx, frame_no in enumerate(FRAMES_TO_CAPTURE):
29 if idx < len(captured):
30 save_png(captured[idx], OUT / f"frame_{frame_no}.png")
31 print(f"Saved {OUT / f'frame_{frame_no}.png'}")