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>
49 lines
No EOL
1.1 KiB
Python
49 lines
No EOL
1.1 KiB
Python
#!/usr/bin/env python3
|
|
"""Simple interactive visibility test"""
|
|
|
|
import mcrfpy
|
|
import sys
|
|
|
|
# Create scene and grid
|
|
print("Creating scene...")
|
|
mcrfpy.createScene("vis_test")
|
|
|
|
print("Creating grid...")
|
|
grid = mcrfpy.Grid(grid_x=10, grid_y=10)
|
|
|
|
# Add color layer for cell coloring
|
|
color_layer = grid.add_layer("color", z_index=-1)
|
|
|
|
# Initialize grid
|
|
print("Initializing grid...")
|
|
for y in range(10):
|
|
for x in range(10):
|
|
cell = grid.at(x, y)
|
|
cell.walkable = True
|
|
cell.transparent = True
|
|
color_layer.set(x, y, mcrfpy.Color(100, 100, 120))
|
|
|
|
# Create entity
|
|
print("Creating entity...")
|
|
entity = mcrfpy.Entity((5, 5), grid=grid)
|
|
entity.sprite_index = 64
|
|
|
|
print("Updating visibility...")
|
|
entity.update_visibility()
|
|
|
|
# Set up UI
|
|
print("Setting up UI...")
|
|
ui = mcrfpy.sceneUI("vis_test")
|
|
ui.append(grid)
|
|
grid.position = (50, 50)
|
|
grid.size = (300, 300)
|
|
|
|
# Test perspective
|
|
print("Testing perspective...")
|
|
grid.perspective = -1 # Omniscient
|
|
print(f"Perspective set to: {grid.perspective}")
|
|
|
|
print("Setting scene...")
|
|
mcrfpy.setScene("vis_test")
|
|
|
|
print("Ready!") |