docs: Update grid demo and regenerate API docs
- grid_demo.py: Updated for new layer-based rendering - Screenshots: Refreshed demo screenshots - API docs: Regenerated with latest method signatures 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
4713b62535
commit
d761b53d48
6 changed files with 957 additions and 81 deletions
|
|
@ -8,29 +8,33 @@ class GridDemo(DemoScreen):
|
|||
|
||||
def setup(self):
|
||||
self.add_title("Grid System")
|
||||
self.add_description("Tile-based rendering with camera, zoom, and children support")
|
||||
self.add_description("Multi-layer rendering with camera, zoom, and children support")
|
||||
|
||||
# Create a grid
|
||||
grid = mcrfpy.Grid(grid_size=(15, 10), pos=(50, 120), size=(400, 280))
|
||||
# Create a grid with no default layers
|
||||
grid = mcrfpy.Grid(grid_size=(15, 10), pos=(50, 120), size=(400, 280), layers={})
|
||||
grid.fill_color = mcrfpy.Color(20, 20, 40)
|
||||
|
||||
# Add a color layer for the checkerboard pattern (z_index=-1 = below entities)
|
||||
color_layer = grid.add_layer("color", z_index=-1)
|
||||
|
||||
# Center camera on middle of grid (in pixel coordinates: cells * cell_size / 2)
|
||||
# For 15x10 grid with 16x16 cells: center = (15*16/2, 10*16/2) = (120, 80)
|
||||
grid.center = (120, 80)
|
||||
self.ui.append(grid)
|
||||
|
||||
# Set some tile colors to create a pattern
|
||||
# Set tile colors via the color layer to create a pattern
|
||||
for x in range(15):
|
||||
for y in range(10):
|
||||
point = grid.at(x, y)
|
||||
# Checkerboard pattern
|
||||
if (x + y) % 2 == 0:
|
||||
point.color = mcrfpy.Color(40, 40, 60)
|
||||
color_layer.set(x, y, mcrfpy.Color(40, 40, 60))
|
||||
else:
|
||||
point.color = mcrfpy.Color(30, 30, 50)
|
||||
color_layer.set(x, y, mcrfpy.Color(30, 30, 50))
|
||||
|
||||
# Border
|
||||
if x == 0 or x == 14 or y == 0 or y == 9:
|
||||
point.color = mcrfpy.Color(80, 60, 40)
|
||||
color_layer.set(x, y, mcrfpy.Color(80, 60, 40))
|
||||
point.walkable = False
|
||||
|
||||
# Add some children to the grid
|
||||
|
|
@ -53,13 +57,12 @@ class GridDemo(DemoScreen):
|
|||
|
||||
props = [
|
||||
"grid_size: (15, 10)",
|
||||
"zoom: 1.0",
|
||||
"layers: [ColorLayer]",
|
||||
"center: (120, 80)",
|
||||
"fill_color: dark blue",
|
||||
"",
|
||||
"Features:",
|
||||
"- Multi-layer rendering",
|
||||
"- Camera pan/zoom",
|
||||
"- Tile colors",
|
||||
"- Children collection",
|
||||
"- FOV/pathfinding",
|
||||
]
|
||||
|
|
@ -69,8 +72,9 @@ class GridDemo(DemoScreen):
|
|||
info.children.append(cap)
|
||||
|
||||
# Code example
|
||||
code = """# Grid with children
|
||||
grid = mcrfpy.Grid(grid_size=(20, 15), pos=(50, 50), size=(320, 240))
|
||||
grid.at(5, 5).color = mcrfpy.Color(255, 0, 0) # Red tile
|
||||
code = """# Grid with layers
|
||||
grid = mcrfpy.Grid(grid_size=(20, 15), pos=(50, 50), size=(320, 240), layers={})
|
||||
layer = grid.add_layer("color", z_index=-1) # Below entities
|
||||
layer.set(5, 5, mcrfpy.Color(255, 0, 0)) # Red tile
|
||||
grid.children.append(mcrfpy.Caption("Label", pos=(80, 48)))"""
|
||||
self.add_code_example(code, y=420)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue