Timer overhaul: update tests

This commit is contained in:
John McCardle 2026-01-03 22:44:53 -05:00
commit cec76b63dc
78 changed files with 521 additions and 495 deletions

View file

@ -266,7 +266,7 @@ def handle_keypress(scene_name, keycode):
sys.exit(0)
# Timer callback for animation
def update_animation(dt):
def update_animation(timer, dt):
"""Update animation state"""
animate_movement(dt / 1000.0) # Convert ms to seconds
@ -335,7 +335,7 @@ for i, entity in enumerate(entities):
dijkstra_enhanced.on_key = handle_keypress
# Set up animation timer (60 FPS)
mcrfpy.setTimer("animation", update_animation, 16)
animation_timer = mcrfpy.Timer("animation", update_animation, 16)
# Show the scene
dijkstra_enhanced.activate()

View file

@ -88,11 +88,11 @@ def test_dijkstra(grid, entities):
return results
def run_test(runtime):
def run_test(timer, runtime):
"""Timer callback to run tests and take screenshot"""
# Run pathfinding tests
results = test_dijkstra(grid, entities)
# Update display with results
y_pos = 380
for result in results:
@ -100,9 +100,9 @@ def run_test(runtime):
caption.fill_color = mcrfpy.Color(200, 200, 200)
ui.append(caption)
y_pos += 20
# Take screenshot
mcrfpy.setTimer("screenshot", lambda rt: take_screenshot(), 500)
# Take screenshot (one-shot timer)
screenshot_timer = mcrfpy.Timer("screenshot", lambda t, rt: take_screenshot(), 500, once=True)
def take_screenshot():
"""Take screenshot and exit"""
@ -140,7 +140,7 @@ ui.append(legend)
# Set scene
dijkstra_test.activate()
# Run test after scene loads
mcrfpy.setTimer("test", run_test, 100)
# Run test after scene loads (one-shot timer)
test_timer = mcrfpy.Timer("test", run_test, 100, once=True)
print("Running Dijkstra tests...")