Rewrite both tutorials as tutorials

They read as design commentary: why a choice was made, what the previous state
of the project was, which library defect a line works around. That is useful to
somebody who already knows the library and useless to somebody trying to build a
game, which is who a tutorial is for.

Both chapters now open with a screenshot of what the reader is building and a
numbered list of the steps to get there, and each step is its own section: what
you are trying to achieve, the code that achieves it, and the two or three things
about that code that are easy to get wrong. Chapter 20 starts from first
principles -- what a sprite, a character, an actor and a tilemap are, and the
four error macros -- and chapter 21 assumes it and covers what a top-down game
adds.

Where a line exists because of a defect, the line comes first and the defect
comes after it, with a pointer to the TODO entry that will remove the need. A
reader who is copying code should not have to read an apology before they can use
it.

The library's own history is gone from both. That belongs in the design chapters
and in git.

Two new docs_examples setups stage the tutorials' own art, so the sprite and
character files a reader is shown are loaded exactly as printed rather than
through a generic fixture. `json excerpt=` is new for the same reason: a Tiled
object is now quoted out of the real map instead of being retyped. Excerpts
across docs/ go from 91 to 137.

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 08:51:39 -04:00
parent 0972472cfa
commit 6553da812c
6 changed files with 1758 additions and 1095 deletions

35
tests/docs_setups/jrpg.sh Executable file
View File

@@ -0,0 +1,35 @@
#!/bin/bash
#
# Stage the JRPG tutorial's own assets in the sandbox.
#
# Same job as sidescroller.sh, and the same reason: docs/21-tutorial-jrpg.md
# shows the reader real sprite and character files out of
# docs/tutorials/assets/jrpg, and a beginner following the chapter types what is
# on the page -- so what is on the page has to be a file that loads.
#
# Two directories are staged, because the checker looks in two places:
#
# ./ a `json kind=sprite` block's spritesheet path is resolved
# relative to the sprite file, which lives in the sandbox root
# ./sprites tools/docs_checkjson.c loads everything here through
# akgl_sprite_load_json before it touches a `kind=character`
# block, since a character resolves its sprites by name
#
# $1 is the repository root. The caller runs this with the sandbox as the
# working directory.
set -u
ROOT="${1:-}"
if [ -z "${ROOT}" ]; then
echo "usage: jrpg.sh <repository-root>" >&2
exit 2
fi
ASSETS="${ROOT}/docs/tutorials/assets/jrpg"
cp "${ASSETS}"/*.png . || exit 1
mkdir -p sprites || exit 1
cp "${ASSETS}"/*.png sprites/ || exit 1
cp "${ASSETS}"/sprite_*.json sprites/ || exit 1