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

@@ -19,7 +19,14 @@ All backends implement a common Display protocol (in `engine/display/__init__.py
```python
class Display(Protocol):
def show(self, buf: list[str]) -> None:
width: int
height: int
def init(self, width: int, height: int, reuse: bool = False) -> None:
"""Initialize the display"""
...
def show(self, buf: list[str], border: bool = False) -> None:
"""Display the buffer"""
...
@@ -27,7 +34,11 @@ class Display(Protocol):
"""Clear the display"""
...
def size(self) -> tuple[int, int]:
def cleanup(self) -> None:
"""Clean up resources"""
...
def get_dimensions(self) -> tuple[int, int]:
"""Return (width, height)"""
...
```
@@ -37,8 +48,8 @@ class Display(Protocol):
Discovers and manages backends:
```python
from engine.display import get_monitor
display = get_monitor("terminal") # or "websocket", "sixel", "null", "multi"
from engine.display import DisplayRegistry
display = DisplayRegistry.create("terminal") # or "websocket", "null", "multi"
```
### Available Backends
@@ -47,9 +58,9 @@ display = get_monitor("terminal") # or "websocket", "sixel", "null", "multi"
|---------|------|-------------|
| terminal | backends/terminal.py | ANSI terminal output |
| websocket | backends/websocket.py | Web browser via WebSocket |
| sixel | backends/sixel.py | Sixel graphics (pure Python) |
| null | backends/null.py | Headless for testing |
| multi | backends/multi.py | Forwards to multiple displays |
| moderngl | backends/moderngl.py | GPU-accelerated OpenGL rendering (optional) |
### WebSocket Backend
@@ -68,9 +79,11 @@ Forwards to multiple displays simultaneously - useful for `terminal + websocket`
3. Register in `engine/display/__init__.py`'s `DisplayRegistry`
Required methods:
- `show(buf: list[str])` - Display buffer
- `init(width: int, height: int, reuse: bool = False)` - Initialize display
- `show(buf: list[str], border: bool = False)` - Display buffer
- `clear()` - Clear screen
- `size() -> tuple[int, int]` - Terminal dimensions
- `cleanup()` - Clean up resources
- `get_dimensions() -> tuple[int, int]` - Get terminal dimensions
Optional methods:
- `title(text: str)` - Set window title
@@ -81,6 +94,5 @@ Optional methods:
```bash
python mainline.py --display terminal # default
python mainline.py --display websocket
python mainline.py --display sixel
python mainline.py --display both # terminal + websocket
python mainline.py --display moderngl # GPU-accelerated (requires moderngl)
```

View File

@@ -86,8 +86,8 @@ Edit `engine/presets.toml` (requires PR to repository).
- `terminal` - ANSI terminal
- `websocket` - Web browser
- `sixel` - Sixel graphics
- `null` - Headless
- `moderngl` - GPU-accelerated (optional)
## Available Effects