Delete the sidescroller's collision, and let the library do it

collision.c was 383 lines that re-implemented akgl_physics_simulate's own
arithmetic, because movementlogicfunc runs before gravity, drag and the move
and so had to predict where the actor would end up. The whole file goes. What
replaces it is three lines in main.c, a shape on the player and the blob, and a
`collidable` property on the map's terrain layer -- which also retires
SS_TERRAIN_LAYER_ID, a compiled-in layer id that broke whenever somebody
reordered layers in Tiled.

grounded stays a probe rather than becoming a contact test. A contact says
something pushed back this step; grounded asks whether there is a floor to push
off, and that stays true through the frame after landing. The blob keeps its own
wall and ledge probes for the same reason: the resolver does not say which side
of the blob it was pushed from, and says nothing at all about a floor that is
missing.

The summary line now carries the player's resting position, because exiting 0
was not evidence that collision ran. It reports 136.0,160.0 grounded after 240
autoplay frames -- feet at y=192, flush on the surface of terrain row 12.

The tutorial's collision section is rewritten around the library's, keeping the
quarter-of-a-pixel story as what a predicting resolver costs. The docs harness
learns `json excerpt=`, so the map property the chapter quotes is checked
against the map.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KzBDV2fqgnUAcqCKqKvc71
This commit is contained in:
2026-08-02 07:35:08 -04:00
parent 35a58670d0
commit 490e62dbbf
9 changed files with 232 additions and 596 deletions

View File

@@ -33,6 +33,7 @@
# ```c excerpt=PATH must appear verbatim in PATH; not compiled
# ```c screenshot=NAME also the source of docs/images/NAME.png
# ```json kind=KIND loaded through the real akgl_*_load_json
# ```json excerpt=PATH must appear verbatim in PATH; not loaded
# ```output the exact stdout of the runnable block above it
# ```sh run in a sandbox; must exit 0
# ```sh setup=NAME the same, after tests/docs_setups/NAME.sh
@@ -434,9 +435,10 @@ function run_c_run()
fi
}
# A declaration echoed from a header. Compiling it would redefine the type, so
# the check is that it still says what the header says -- which is the drift
# that actually happens, and the one a compile could not catch.
# A declaration echoed from a header, or a fragment quoted out of an asset file
# too large to show whole. Compiling or loading it is not the point -- the check
# is that it still says what the file says, which is the drift that actually
# happens and the one a compile could not catch.
function run_excerpt()
{
local where="$1" body="$2" path="$3"
@@ -640,7 +642,12 @@ for DOC in "${DOCS[@]}"; do
fi
;;
json)
run_json "${WHERE}" "${BODY}" "${INFO}"
EXCERPT="$(attr excerpt "${INFO}")"
if [ -n "${EXCERPT}" ]; then
run_excerpt "${WHERE}" "${BODY}" "${EXCERPT}"
else
run_json "${WHERE}" "${BODY}" "${INFO}"
fi
;;
sh)
run_sh "${WHERE}" "${BODY}" "${INFO}" "${EXPECTED}"