tests/docs/: - API_FINDINGS.md: Comprehensive migration guide from deprecated to modern API - test_*.py: 9 executable tests verifying actual runtime behavior - screenshots/: Visual verification of working examples tests/conftest.py: - Add 'docs' and 'demo' to pytest collection paths Key findings documented: - Entity uses grid_pos= not pos= - Scene API: Scene() + activate() replaces createScene/setScene - scene.children replaces sceneUI() - scene.on_key replaces keypressScene() - mcrfpy.current_scene (property) replaces currentScene() (function) - Timer callback signature: (timer, runtime) - Opacity animation does NOT work on Frame (documented bug) 🤖 Generated with Claude Code (https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
49 lines
1.2 KiB
Python
49 lines
1.2 KiB
Python
#!/usr/bin/env python3
|
|
"""Test for quickstart.md 'Custom Sprite Sheet' example.
|
|
|
|
Original (DEPRECATED - lines 176-201):
|
|
mcrfpy.createScene("game")
|
|
grid = mcrfpy.Grid(20, 15, my_texture, (10, 10), (640, 480))
|
|
grid.at(5, 5).sprite = 10
|
|
ui = mcrfpy.sceneUI("game")
|
|
mcrfpy.setScene("game")
|
|
|
|
Modern equivalent below.
|
|
"""
|
|
import mcrfpy
|
|
from mcrfpy import automation
|
|
import sys
|
|
|
|
# Create scene using modern API
|
|
scene = mcrfpy.Scene("game")
|
|
scene.activate()
|
|
mcrfpy.step(0.01)
|
|
|
|
# Load sprite sheet (using existing texture for test)
|
|
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=(640, 480)
|
|
)
|
|
|
|
# Set specific tiles using modern API
|
|
# grid.at() returns a GridPoint with tilesprite property
|
|
grid.at((5, 5)).tilesprite = 10 # Note: tuple for position
|
|
grid.at((6, 5)).tilesprite = 11
|
|
|
|
# Set walkability
|
|
grid.at((6, 5)).walkable = False
|
|
|
|
# Add grid to scene
|
|
scene.children.append(grid)
|
|
|
|
# Render and screenshot
|
|
mcrfpy.step(0.1)
|
|
automation.screenshot("/opt/goblincorps/repos/McRogueFace/tests/docs/screenshots/quickstart_sprites.png")
|
|
|
|
print("PASS - quickstart sprites")
|
|
sys.exit(0)
|