McRogueFace/tests/snippets/055_pathfinding_entity.py
John McCardle 3a85dd818d fix(snippets): drop the commit hash from verified -- it churned all 130 every commit
The `# mcrf:` stamp recorded verified=<version>@<commit>, so every commit rewrote
the hash in all 130 snippet headers -- a guaranteed 130-file diff carrying no signal
git history doesn't already have, and one `--check` ignores anyway. The version alone
is stable within a dev cycle ("0.2.8-dev") and becomes the release marker at a tag
("0.2.9"), which is the whole point of the field: freezing a version into the docs
site's history, not pinning a commit.

verified is now version-only. The stamper is idempotent again: a second run on a
clean tree changes zero files. This commit is the one-time normalization that strips
the @hash suffix from the existing headers.

Found while cleaning up after a make release-docs run left all 130 snippets dirty
with nothing but hash churn.
2026-07-14 19:14:49 -04:00

54 lines
1.3 KiB
Python

# mcrf: objects=[Caption,Color,ColorLayer,Entity,Grid,Scene] verified=0.2.8-dev status=ok
# Entity Pathfinding - Entity path_to method
import mcrfpy
scene = mcrfpy.Scene("demo")
mcrfpy.current_scene = scene
grid = mcrfpy.Grid(
grid_size=(16, 12),
texture=mcrfpy.default_texture,
pos=(0, 0),
size=(1024, 768),
zoom=4.0
)
scene.children.append(grid)
# Add color layer for path visualization
path_layer = mcrfpy.ColorLayer(z_index=1, name="path")
grid.add_layer(path_layer)
# Floor with some walls
for y in range(12):
for x in range(16):
cell = grid.at(x, y)
if x == 8 and y > 1 and y < 10:
cell.tilesprite = 1
cell.walkable = False
else:
cell.tilesprite = 48
cell.walkable = True
# Entity
player = mcrfpy.Entity(
grid_pos=(3, 6),
texture=mcrfpy.default_texture,
sprite_index=84
)
grid.entities.append(player)
# Find path to target
target = (13, 6)
path = player.path_to(target)
# Visualize path using color layer
for px, py in path:
path_layer.set((px, py), mcrfpy.Color(150, 200, 255, 180))
# Mark target
path_layer.set((target[0], target[1]), mcrfpy.Color(255, 200, 100, 200))
status = mcrfpy.Caption(text="Entity pathfinding around wall", pos=(360, 720))
status.outline = 2
status.outline_color = mcrfpy.Color(0, 0, 0)
scene.children.append(status)