Repository navigation
Conversation
SpriteManager::move_composite_{left,right,up,down}_blocked move a composite
as the limited moves do unless its Hitbox would step on a solid background
tile, read with the new TileCollision::when_free. TileManager::
background_tile_index gives a background tile's ID for maps and collision
sets.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The tests require every binary in src/bin to have a snapshot test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 30, 2026
Owner
Author
|
Already in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The olive-empire example needs obstacles: olive trees the player cannot walk through. The library could tell whether a screen pixel is on a solid tile (
TileCollision::at_screen_pixel), but it had no way to cancel a move before the player steps on one, and no public way to get a background tile's ID. This PR adds blocked composite moves with a hitbox, and registers olive-empire as an example so the test suite is green again.What changed
src/engine/tile_collision.rs:TileCollision::when_free(points, body)runsbodyonly when none of the screen pixels is on a solid tile (it stops at the first solid one; no points or no solid tiles: justbody). NewHitbox(a rectangle of a sprite, e.g. a character's feet).at_screen_pixelemits the same code as before.src/engine/sprites.rs:SpriteManager::move_composite_{left,right,up,down}_blocked(id, distance, limit, &solid, hitbox)do what the_limitmoves do, unless the hitbox would step on a solid tile. They read the lines 1 anddistancepixels ahead of the hitbox, every 8 pixels along its edge and at its last pixel, so no 8x8 tile is skipped (distancein 1..=8, checked).src/engine/tiles.rs:TileManager::background_tile_index(id), the tile ID of background tiles ($9000addressing) for tilemaps and collision sets.src/engine/mod.rs,src/prelude.rs: exportHitbox.tests/support/examples.rs,tests/report.rs,tests/snapshots.rs,scripts/assemble-examples.sh,CLAUDE.md) with its snapshotexamples/olive-empire/main.asm:every_example_has_a_snapshot_testwas failing on the base branch.Task.md,CONTEXT.md,CHANGELOG.md: the new API and the example.Tasks closed
How it was verified
cargo fmt --check: okcargo clippy --all-targets -- -D warnings: okcargo test: ok (472 lib tests, all integration tests);cargo +1.85 test: okscripts/assemble-examples.sh: all 8 examples assemble and link (RGBDS)RGBDS_LINK_CHECK=1 GB_TEST_ROMS=<dir> cargo test --lib --test emulator: ok (115 tests)blocked_composite_moves_stop_the_hitbox_against_solid_tiles(emulator: a 16x16 player with a feet hitbox stops touching a solid tile in all four directions, its head overlapping the tile row when walking up; it fails with an empty solid set), unit tests for the pixels read, the panics, the empty-set case,when_free's code andbackground_tile_index.Generated-asm impact
examples/olive-empire/main.asm(the example as it is on the base branch). No other example changes.Risks and follow-ups
limitis still checked for the wholedistance; withdistance> 1 the composite stops up todistance - 1pixels before an obstacle (documented).Independent review
How to review
src/engine/tile_collision.rs(when_free), thenblocked_pointsinsrc/engine/sprites.rs, then the emulator test at the end oftests/emulator.rs.🤖 Generated with Claude Code