McRogueFace/tests/docs/test_quickstart_simple_scene.py
John McCardle 6d5e99a114 Remove legacy string enum comparisons from InputState/Key/MouseButton, closes #306
Removed custom __eq__/__ne__ that allowed comparing enums to legacy string
names (e.g., Key.ESCAPE == "Escape"). Removed _legacy_names dicts and
to_legacy_string() functions. Kept from_legacy_string() in PyKey.cpp as
it's used by C++ event dispatch. Updated ~50 Python test/demo/cookbook
files to use enum members instead of string comparisons. Also updates
grid.position -> grid.pos in files that had both types of changes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-09 22:19:02 -04:00

48 lines
1.2 KiB
Python

#!/usr/bin/env python3
"""Test for quickstart.md 'Simple Test Scene' example.
Original (DEPRECATED - lines 48-74):
mcrfpy.createScene("test")
grid = mcrfpy.Grid(20, 15, texture, (10, 10), (800, 600))
ui = mcrfpy.sceneUI("test")
mcrfpy.setScene("test")
mcrfpy.keypressScene(move_around)
Modern equivalent below.
"""
import mcrfpy
from mcrfpy import automation
import sys
# Create scene using modern API
scene = mcrfpy.Scene("test")
scene.activate()
mcrfpy.step(0.01) # Initialize
# Load texture
texture = mcrfpy.Texture("assets/kenney_tinydungeon.png", 16, 16)
# Create grid using modern keyword API
grid = mcrfpy.Grid(
grid_size=(20, 15),
texture=texture,
pos=(10, 10),
size=(800, 600)
)
# Add to scene's children (not sceneUI)
scene.children.append(grid)
# Add keyboard controls using modern API
def move_around(key, state):
if state == mcrfpy.InputState.PRESSED:
print(f"You pressed {key}")
scene.on_key = move_around
# Render and screenshot
mcrfpy.step(0.1)
automation.screenshot("/opt/goblincorps/repos/McRogueFace/tests/docs/screenshots/quickstart_simple_scene.png")
print("PASS - quickstart simple scene")
sys.exit(0)