fix: Update test files to use current API patterns

Migrates test suite to current API:
- Frame(x, y, w, h) → Frame(pos=(x, y), size=(w, h))
- Caption("text", x, y) → Caption(pos=(x, y), text="text")
- caption.size → caption.font_size
- Entity(x, y, ...) → Entity((x, y), ...)
- Grid(w, h, ...) → Grid(grid_size=(w, h), ...)
- cell.color → ColorLayer system

Tests now serve as valid API usage examples.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
John McCardle 2025-12-29 19:47:48 -05:00
commit 9f481a2e4a
53 changed files with 614 additions and 586 deletions

View file

@ -4,28 +4,10 @@
import mcrfpy
import sys
# Colors as tuples (r, g, b, a)
WALL_COLOR = (60, 30, 30, 255)
FLOOR_COLOR = (200, 200, 220, 255)
PATH_COLOR = (100, 255, 100, 255)
def check_render(dt):
"""Timer callback to verify rendering"""
print(f"\nTimer fired after {dt}ms")
# Take screenshot
from mcrfpy import automation
automation.screenshot("visual_path_test.png")
print("Screenshot saved as visual_path_test.png")
# Sample some path cells to verify colors
print("\nSampling path cell colors from grid:")
for x, y in [(1, 1), (2, 2), (3, 3)]:
cell = grid.at(x, y)
color = cell.color
print(f" Cell ({x},{y}): color={color[:3]}")
sys.exit(0)
# Colors
WALL_COLOR = mcrfpy.Color(60, 30, 30)
FLOOR_COLOR = mcrfpy.Color(200, 200, 220)
PATH_COLOR = mcrfpy.Color(100, 255, 100)
# Create scene
mcrfpy.createScene("visual_test")
@ -34,20 +16,38 @@ mcrfpy.createScene("visual_test")
grid = mcrfpy.Grid(grid_x=5, grid_y=5)
grid.fill_color = mcrfpy.Color(0, 0, 0)
# Add color layer for cell coloring
color_layer = grid.add_layer("color", z_index=-1)
def check_render(dt):
"""Timer callback to verify rendering"""
print(f"\nTimer fired after {dt}ms")
# Take screenshot
from mcrfpy import automation
automation.screenshot("visual_path_test.png")
print("Screenshot saved as visual_path_test.png")
# Sample some path cells to verify colors
print("\nSampling path cell colors from grid:")
for x, y in [(1, 1), (2, 2), (3, 3)]:
color = color_layer.at(x, y)
print(f" Cell ({x},{y}): color=({color.r}, {color.g}, {color.b})")
sys.exit(0)
# Initialize all cells as floor
print("Initializing grid...")
for y in range(5):
for x in range(5):
grid.at(x, y).walkable = True
grid.at(x, y).color = FLOOR_COLOR
color_layer.set(x, y, FLOOR_COLOR)
# Create entities
e1 = mcrfpy.Entity(0, 0)
e2 = mcrfpy.Entity(4, 4)
e1 = mcrfpy.Entity((0, 0), grid=grid)
e2 = mcrfpy.Entity((4, 4), grid=grid)
e1.sprite_index = 64 # @
e2.sprite_index = 69 # E
grid.entities.append(e1)
grid.entities.append(e2)
print(f"Entity 1 at ({e1.x}, {e1.y})")
print(f"Entity 2 at ({e2.x}, {e2.y})")
@ -60,7 +60,7 @@ print(f"\nPath from E1 to E2: {path}")
if path:
print("\nColoring path cells green...")
for x, y in path:
grid.at(x, y).color = PATH_COLOR
color_layer.set(x, y, PATH_COLOR)
print(f" Set ({x},{y}) to green")
# Set up UI
@ -70,7 +70,7 @@ grid.position = (50, 50)
grid.size = (250, 250)
# Add title
title = mcrfpy.Caption("Path Visualization Test", 50, 10)
title = mcrfpy.Caption(pos=(50, 10), text="Path Visualization Test")
title.fill_color = mcrfpy.Color(255, 255, 255)
ui.append(title)