Files
akbasic/tests/docs_preludes/galagahost.pre
Tachikoma 81e8582d2d Write the GALAGA tutorial chapters and the repeated-host-calls guide
docs/20 builds the engine and the boundary: the startup order, the
starfield, actors and collision, booting a DEF-only script, the issue #8
mode workaround, the custom update hook, first light, screens, and the
headless harness. docs/21 builds the three shared structures and the AI:
the host type tables, the actor binding, the randomness route around
issue #16, the measured case against structure arguments (issue #36),
the three language rules that shape the script, the maneuvers, the
argued formation decision, the script-death policy, and the interop
proof. Every fenced block runs under tests/docs_examples.sh in both
build configurations; five new preludes carry the C fragments.

docs/10 gains the 'Calling a function every frame' section the chapters
lean on: the per-call akbasic_environment_zero() rule, the set_mode(RUN)
workaround, the clear_error() revival, and the case for rebinding over
structure arguments. Index rows and chapter counts updated.

Co-authored-by: andrew <andrew@aklabs.net>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XiGgpHuXUm2mR4Wzndw3dc
2026-08-04 18:49:11 -04:00

56 lines
1.3 KiB
Plaintext

/*
* Prelude for statement-context fragments in docs/20: runs of CATCH calls
* from the galaga frame loop, shown without their scaffolding because the
* ATTEMPT protocol is the scaffolding. Same policy as hostcalls.pre.
*/
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <SDL3/SDL.h>
#include <SDL3_ttf/SDL_ttf.h>
#include <akerror.h>
#include <akstdlib.h>
#include <akgl/actor.h>
#include <akgl/controller.h>
#include <akgl/draw.h>
#include <akgl/game.h>
#include <akgl/heap.h>
#include <akgl/renderer.h>
#include <akgl/ui.h>
#include <akbasic/error.h>
#include <akbasic/runtime.h>
typedef enum
{
GALAGA_SCREEN_TITLE = 0,
GALAGA_SCREEN_PLAY,
GALAGA_SCREEN_GAMEOVER,
GALAGA_SCREEN_VICTORY
} galaga_Screen;
struct galaga_docs_Game
{
galaga_Screen screen;
float dt;
akgl_Actor *player;
};
extern struct galaga_docs_Game galaga_game;
extern akgl_Actor *galaga_enemy_actors[40];
akerr_ErrorContext AKERR_NOIGNORE *declare_title(void);
akerr_ErrorContext AKERR_NOIGNORE *declare_play(void);
akerr_ErrorContext AKERR_NOIGNORE *declare_end(void);
akerr_ErrorContext AKERR_NOIGNORE *galaga_docs_fragment(void);
akerr_ErrorContext AKERR_NOIGNORE *galaga_docs_fragment(void)
{
PREPARE_ERROR(errctx);
SDL_Event event;
ATTEMPT {