Update docs, fix Pygame window, and improve camera stage timing

This commit is contained in:
2026-03-18 22:33:57 -07:00
parent c57617bb3d
commit bb0f1b85bf
12 changed files with 338 additions and 57 deletions

View File

@@ -99,9 +99,6 @@ class PygameDisplay:
self.width = width
self.height = height
import os
os.environ["SDL_VIDEODRIVER"] = "dummy"
try:
import pygame

View File

@@ -1,5 +1,6 @@
"""Adapter for camera stage."""
import time
from typing import Any
from engine.pipeline.core import DataType, PipelineContext, Stage
@@ -13,6 +14,7 @@ class CameraStage(Stage):
self.name = name
self.category = "camera"
self.optional = True
self._last_frame_time: float | None = None
@property
def stage_type(self) -> str:
@@ -39,9 +41,17 @@ class CameraStage(Stage):
if data is None:
return data
# Apply camera offset to items
current_time = time.perf_counter()
dt = 0.0
if self._last_frame_time is not None:
dt = current_time - self._last_frame_time
self._camera.update(dt)
self._last_frame_time = current_time
ctx.set_state("camera_y", self._camera.y)
ctx.set_state("camera_x", self._camera.x)
if hasattr(self._camera, "apply"):
# Extract viewport dimensions from context params
viewport_width = ctx.params.viewport_width if ctx.params else 80
viewport_height = ctx.params.viewport_height if ctx.params else 24
return self._camera.apply(data, viewport_width, viewport_height)