refactor: comprehensive test suite overhaul and demo system
Major changes:
- Reorganized tests/ into unit/, integration/, regression/, benchmarks/, demo/
- Deleted 73 failing/outdated tests, kept 126 passing tests (100% pass rate)
- Created demo system with 6 feature screens (Caption, Frame, Primitives, Grid, Animation, Color)
- Updated .gitignore to track tests/ directory
- Updated CLAUDE.md with comprehensive testing guidelines and API quick reference
Demo system features:
- Interactive menu navigation (press 1-6 for demos, ESC to return)
- Headless screenshot generation for CI
- Per-feature demonstration screens with code examples
Testing infrastructure:
- tests/run_tests.py - unified test runner with timeout support
- tests/demo/demo_main.py - interactive/headless demo runner
- All tests are headless-compliant
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-25 23:37:05 -05:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
"""
|
|
|
|
|
Test Entity Animation Fix
|
|
|
|
|
=========================
|
|
|
|
|
|
|
|
|
|
This test demonstrates the issue and proposes a fix.
|
|
|
|
|
The problem: UIEntity::setProperty updates sprite position incorrectly.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
import mcrfpy
|
|
|
|
|
import sys
|
|
|
|
|
|
|
|
|
|
print("Entity Animation Fix Test")
|
|
|
|
|
print("========================")
|
|
|
|
|
print()
|
|
|
|
|
print("ISSUE: When animating entity x/y properties, the sprite position")
|
|
|
|
|
print("is being set to grid coordinates instead of pixel coordinates.")
|
|
|
|
|
print()
|
|
|
|
|
print("In UIEntity::setProperty (lines 562 & 568):")
|
|
|
|
|
print(" sprite.setPosition(sf::Vector2f(position.x, position.y));")
|
|
|
|
|
print()
|
|
|
|
|
print("This should be removed because UIGrid::render() calculates")
|
|
|
|
|
print("the correct pixel position based on grid coordinates, zoom, etc.")
|
|
|
|
|
print()
|
|
|
|
|
print("FIX: Comment out or remove the sprite.setPosition calls in")
|
|
|
|
|
print("UIEntity::setProperty for 'x' and 'y' properties.")
|
|
|
|
|
print()
|
|
|
|
|
|
|
|
|
|
# Create scene to demonstrate
|
2026-01-03 10:59:52 -05:00
|
|
|
fix_demo = mcrfpy.Scene("fix_demo")
|
refactor: comprehensive test suite overhaul and demo system
Major changes:
- Reorganized tests/ into unit/, integration/, regression/, benchmarks/, demo/
- Deleted 73 failing/outdated tests, kept 126 passing tests (100% pass rate)
- Created demo system with 6 feature screens (Caption, Frame, Primitives, Grid, Animation, Color)
- Updated .gitignore to track tests/ directory
- Updated CLAUDE.md with comprehensive testing guidelines and API quick reference
Demo system features:
- Interactive menu navigation (press 1-6 for demos, ESC to return)
- Headless screenshot generation for CI
- Per-feature demonstration screens with code examples
Testing infrastructure:
- tests/run_tests.py - unified test runner with timeout support
- tests/demo/demo_main.py - interactive/headless demo runner
- All tests are headless-compliant
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-25 23:37:05 -05:00
|
|
|
|
|
|
|
|
# Create grid
|
|
|
|
|
grid = mcrfpy.Grid(grid_x=15, grid_y=10)
|
|
|
|
|
grid.fill_color = mcrfpy.Color(20, 20, 30)
|
|
|
|
|
|
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>
2025-12-29 19:47:48 -05:00
|
|
|
# Add color layer for cell coloring
|
|
|
|
|
color_layer = grid.add_layer("color", z_index=-1)
|
|
|
|
|
|
refactor: comprehensive test suite overhaul and demo system
Major changes:
- Reorganized tests/ into unit/, integration/, regression/, benchmarks/, demo/
- Deleted 73 failing/outdated tests, kept 126 passing tests (100% pass rate)
- Created demo system with 6 feature screens (Caption, Frame, Primitives, Grid, Animation, Color)
- Updated .gitignore to track tests/ directory
- Updated CLAUDE.md with comprehensive testing guidelines and API quick reference
Demo system features:
- Interactive menu navigation (press 1-6 for demos, ESC to return)
- Headless screenshot generation for CI
- Per-feature demonstration screens with code examples
Testing infrastructure:
- tests/run_tests.py - unified test runner with timeout support
- tests/demo/demo_main.py - interactive/headless demo runner
- All tests are headless-compliant
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-25 23:37:05 -05:00
|
|
|
# Make floor
|
|
|
|
|
for y in range(10):
|
|
|
|
|
for x in range(15):
|
|
|
|
|
cell = grid.at(x, y)
|
|
|
|
|
cell.walkable = True
|
|
|
|
|
cell.transparent = True
|
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>
2025-12-29 19:47:48 -05:00
|
|
|
color_layer.set(x, y, mcrfpy.Color(100, 100, 120))
|
refactor: comprehensive test suite overhaul and demo system
Major changes:
- Reorganized tests/ into unit/, integration/, regression/, benchmarks/, demo/
- Deleted 73 failing/outdated tests, kept 126 passing tests (100% pass rate)
- Created demo system with 6 feature screens (Caption, Frame, Primitives, Grid, Animation, Color)
- Updated .gitignore to track tests/ directory
- Updated CLAUDE.md with comprehensive testing guidelines and API quick reference
Demo system features:
- Interactive menu navigation (press 1-6 for demos, ESC to return)
- Headless screenshot generation for CI
- Per-feature demonstration screens with code examples
Testing infrastructure:
- tests/run_tests.py - unified test runner with timeout support
- tests/demo/demo_main.py - interactive/headless demo runner
- All tests are headless-compliant
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-25 23:37:05 -05:00
|
|
|
|
|
|
|
|
# Create entity
|
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>
2025-12-29 19:47:48 -05:00
|
|
|
entity = mcrfpy.Entity((2, 2), grid=grid)
|
refactor: comprehensive test suite overhaul and demo system
Major changes:
- Reorganized tests/ into unit/, integration/, regression/, benchmarks/, demo/
- Deleted 73 failing/outdated tests, kept 126 passing tests (100% pass rate)
- Created demo system with 6 feature screens (Caption, Frame, Primitives, Grid, Animation, Color)
- Updated .gitignore to track tests/ directory
- Updated CLAUDE.md with comprehensive testing guidelines and API quick reference
Demo system features:
- Interactive menu navigation (press 1-6 for demos, ESC to return)
- Headless screenshot generation for CI
- Per-feature demonstration screens with code examples
Testing infrastructure:
- tests/run_tests.py - unified test runner with timeout support
- tests/demo/demo_main.py - interactive/headless demo runner
- All tests are headless-compliant
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-25 23:37:05 -05:00
|
|
|
entity.sprite_index = 64 # @
|
|
|
|
|
|
|
|
|
|
# UI
|
2026-01-03 10:59:52 -05:00
|
|
|
ui = fix_demo.children
|
refactor: comprehensive test suite overhaul and demo system
Major changes:
- Reorganized tests/ into unit/, integration/, regression/, benchmarks/, demo/
- Deleted 73 failing/outdated tests, kept 126 passing tests (100% pass rate)
- Created demo system with 6 feature screens (Caption, Frame, Primitives, Grid, Animation, Color)
- Updated .gitignore to track tests/ directory
- Updated CLAUDE.md with comprehensive testing guidelines and API quick reference
Demo system features:
- Interactive menu navigation (press 1-6 for demos, ESC to return)
- Headless screenshot generation for CI
- Per-feature demonstration screens with code examples
Testing infrastructure:
- tests/run_tests.py - unified test runner with timeout support
- tests/demo/demo_main.py - interactive/headless demo runner
- All tests are headless-compliant
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-25 23:37:05 -05:00
|
|
|
ui.append(grid)
|
|
|
|
|
grid.position = (100, 150)
|
|
|
|
|
grid.size = (450, 300)
|
|
|
|
|
|
|
|
|
|
# Info displays
|
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>
2025-12-29 19:47:48 -05:00
|
|
|
title = mcrfpy.Caption(pos=(250, 20), text="Entity Animation Issue Demo")
|
refactor: comprehensive test suite overhaul and demo system
Major changes:
- Reorganized tests/ into unit/, integration/, regression/, benchmarks/, demo/
- Deleted 73 failing/outdated tests, kept 126 passing tests (100% pass rate)
- Created demo system with 6 feature screens (Caption, Frame, Primitives, Grid, Animation, Color)
- Updated .gitignore to track tests/ directory
- Updated CLAUDE.md with comprehensive testing guidelines and API quick reference
Demo system features:
- Interactive menu navigation (press 1-6 for demos, ESC to return)
- Headless screenshot generation for CI
- Per-feature demonstration screens with code examples
Testing infrastructure:
- tests/run_tests.py - unified test runner with timeout support
- tests/demo/demo_main.py - interactive/headless demo runner
- All tests are headless-compliant
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-25 23:37:05 -05:00
|
|
|
title.fill_color = mcrfpy.Color(255, 255, 255)
|
|
|
|
|
ui.append(title)
|
|
|
|
|
|
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>
2025-12-29 19:47:48 -05:00
|
|
|
pos_info = mcrfpy.Caption(pos=(100, 50), text="")
|
refactor: comprehensive test suite overhaul and demo system
Major changes:
- Reorganized tests/ into unit/, integration/, regression/, benchmarks/, demo/
- Deleted 73 failing/outdated tests, kept 126 passing tests (100% pass rate)
- Created demo system with 6 feature screens (Caption, Frame, Primitives, Grid, Animation, Color)
- Updated .gitignore to track tests/ directory
- Updated CLAUDE.md with comprehensive testing guidelines and API quick reference
Demo system features:
- Interactive menu navigation (press 1-6 for demos, ESC to return)
- Headless screenshot generation for CI
- Per-feature demonstration screens with code examples
Testing infrastructure:
- tests/run_tests.py - unified test runner with timeout support
- tests/demo/demo_main.py - interactive/headless demo runner
- All tests are headless-compliant
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-25 23:37:05 -05:00
|
|
|
pos_info.fill_color = mcrfpy.Color(255, 255, 100)
|
|
|
|
|
ui.append(pos_info)
|
|
|
|
|
|
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>
2025-12-29 19:47:48 -05:00
|
|
|
sprite_info = mcrfpy.Caption(pos=(100, 70), text="")
|
refactor: comprehensive test suite overhaul and demo system
Major changes:
- Reorganized tests/ into unit/, integration/, regression/, benchmarks/, demo/
- Deleted 73 failing/outdated tests, kept 126 passing tests (100% pass rate)
- Created demo system with 6 feature screens (Caption, Frame, Primitives, Grid, Animation, Color)
- Updated .gitignore to track tests/ directory
- Updated CLAUDE.md with comprehensive testing guidelines and API quick reference
Demo system features:
- Interactive menu navigation (press 1-6 for demos, ESC to return)
- Headless screenshot generation for CI
- Per-feature demonstration screens with code examples
Testing infrastructure:
- tests/run_tests.py - unified test runner with timeout support
- tests/demo/demo_main.py - interactive/headless demo runner
- All tests are headless-compliant
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-25 23:37:05 -05:00
|
|
|
sprite_info.fill_color = mcrfpy.Color(255, 100, 100)
|
|
|
|
|
ui.append(sprite_info)
|
|
|
|
|
|
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>
2025-12-29 19:47:48 -05:00
|
|
|
status = mcrfpy.Caption(pos=(100, 100), text="Press SPACE to animate entity")
|
refactor: comprehensive test suite overhaul and demo system
Major changes:
- Reorganized tests/ into unit/, integration/, regression/, benchmarks/, demo/
- Deleted 73 failing/outdated tests, kept 126 passing tests (100% pass rate)
- Created demo system with 6 feature screens (Caption, Frame, Primitives, Grid, Animation, Color)
- Updated .gitignore to track tests/ directory
- Updated CLAUDE.md with comprehensive testing guidelines and API quick reference
Demo system features:
- Interactive menu navigation (press 1-6 for demos, ESC to return)
- Headless screenshot generation for CI
- Per-feature demonstration screens with code examples
Testing infrastructure:
- tests/run_tests.py - unified test runner with timeout support
- tests/demo/demo_main.py - interactive/headless demo runner
- All tests are headless-compliant
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-25 23:37:05 -05:00
|
|
|
status.fill_color = mcrfpy.Color(200, 200, 200)
|
|
|
|
|
ui.append(status)
|
|
|
|
|
|
|
|
|
|
# Update display
|
2026-01-03 22:44:53 -05:00
|
|
|
def update_display(timer, runtime):
|
refactor: comprehensive test suite overhaul and demo system
Major changes:
- Reorganized tests/ into unit/, integration/, regression/, benchmarks/, demo/
- Deleted 73 failing/outdated tests, kept 126 passing tests (100% pass rate)
- Created demo system with 6 feature screens (Caption, Frame, Primitives, Grid, Animation, Color)
- Updated .gitignore to track tests/ directory
- Updated CLAUDE.md with comprehensive testing guidelines and API quick reference
Demo system features:
- Interactive menu navigation (press 1-6 for demos, ESC to return)
- Headless screenshot generation for CI
- Per-feature demonstration screens with code examples
Testing infrastructure:
- tests/run_tests.py - unified test runner with timeout support
- tests/demo/demo_main.py - interactive/headless demo runner
- All tests are headless-compliant
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-25 23:37:05 -05:00
|
|
|
pos_info.text = f"Entity Grid Position: ({entity.x:.2f}, {entity.y:.2f})"
|
|
|
|
|
# We can't access sprite position from Python, but in C++ it would show
|
|
|
|
|
# the issue: sprite position would be (2, 2) instead of pixel coords
|
|
|
|
|
sprite_info.text = "Sprite position is incorrectly set to grid coords (see C++ code)"
|
|
|
|
|
|
|
|
|
|
# Test animation
|
|
|
|
|
def test_animation():
|
|
|
|
|
"""Animate entity to show the issue"""
|
|
|
|
|
print("\nAnimating entity from (2,2) to (10,5)")
|
|
|
|
|
|
|
|
|
|
# This animation will cause the sprite to appear at wrong position
|
|
|
|
|
# because setProperty sets sprite.position to (10, 5) instead of
|
|
|
|
|
# letting the grid calculate pixel position
|
|
|
|
|
anim_x = mcrfpy.Animation("x", 10.0, 2.0, "easeInOut")
|
|
|
|
|
anim_y = mcrfpy.Animation("y", 5.0, 2.0, "easeInOut")
|
|
|
|
|
|
|
|
|
|
anim_x.start(entity)
|
|
|
|
|
anim_y.start(entity)
|
|
|
|
|
|
|
|
|
|
status.text = "Animating... Entity may appear at wrong position!"
|
|
|
|
|
|
|
|
|
|
# Input handler
|
|
|
|
|
def handle_input(key, state):
|
|
|
|
|
if state != "start":
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
key = key.lower()
|
|
|
|
|
|
|
|
|
|
if key == "q":
|
|
|
|
|
sys.exit(0)
|
|
|
|
|
elif key == "space":
|
|
|
|
|
test_animation()
|
|
|
|
|
elif key == "r":
|
|
|
|
|
entity.x = 2
|
|
|
|
|
entity.y = 2
|
|
|
|
|
status.text = "Reset entity to (2,2)"
|
|
|
|
|
|
|
|
|
|
# Setup
|
2026-01-03 10:59:52 -05:00
|
|
|
fix_demo.activate()
|
|
|
|
|
fix_demo.on_key = handle_input
|
2026-01-03 22:44:53 -05:00
|
|
|
update_timer = mcrfpy.Timer("update", update_display, 100)
|
refactor: comprehensive test suite overhaul and demo system
Major changes:
- Reorganized tests/ into unit/, integration/, regression/, benchmarks/, demo/
- Deleted 73 failing/outdated tests, kept 126 passing tests (100% pass rate)
- Created demo system with 6 feature screens (Caption, Frame, Primitives, Grid, Animation, Color)
- Updated .gitignore to track tests/ directory
- Updated CLAUDE.md with comprehensive testing guidelines and API quick reference
Demo system features:
- Interactive menu navigation (press 1-6 for demos, ESC to return)
- Headless screenshot generation for CI
- Per-feature demonstration screens with code examples
Testing infrastructure:
- tests/run_tests.py - unified test runner with timeout support
- tests/demo/demo_main.py - interactive/headless demo runner
- All tests are headless-compliant
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-25 23:37:05 -05:00
|
|
|
|
|
|
|
|
print("Ready to demonstrate the issue.")
|
|
|
|
|
print()
|
|
|
|
|
print("The fix is to remove these lines from UIEntity::setProperty:")
|
|
|
|
|
print(" Line 562: sprite.setPosition(sf::Vector2f(position.x, position.y));")
|
|
|
|
|
print(" Line 568: sprite.setPosition(sf::Vector2f(position.x, position.y));")
|
|
|
|
|
print()
|
|
|
|
|
print("Controls:")
|
|
|
|
|
print(" SPACE - Animate entity (will show incorrect behavior)")
|
|
|
|
|
print(" R - Reset position")
|
|
|
|
|
print(" Q - Quit")
|