From 74867ea82e0754ebfdc821954f5c726bebddc246 Mon Sep 17 00:00:00 2001 From: Andrew Kesterson Date: Sat, 20 Jun 2026 13:19:58 -0400 Subject: [PATCH] README --- README.md | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2bb54d8..5183c50 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ Physics properties (gravity and drag along X, Y and Z) are optional and default ## How do I update and render the game world in my main loop -In your game loop (or in your `SDL_AppIterate` method), lock the game state, call the renderer to draw the world within the visible camera, and then unlock the game state +In your game loop (or in your `SDL_AppIterate` method), lock the game state, call the game update function, and then unlock the game state ```c PASS(e, akgl_game_state_lock()); @@ -76,6 +76,33 @@ Load a character from a JSON file. Characters map sprites to actor states and de PASS(e, akgl_character_load_json(SOME_FILENAME)) ``` +You don't strictly have to load sprites and characters from json files, you can initialize them yourself, it's just tedious work. Here's an example of initializing a 32x32 sprite from a spritesheet that uses the first 4 frames in a looping animation. + +```c +akgl_SpriteSheet *sheet; +akgl_Sprite *sprite; +akgl_Character *character; +PASS(e, akgl_heap_next_spritesheet(&sheet); +PASS(e, akgl_spritesheet_initialize(sheet, 32, 32, IMAGE_FILENAME)); +PASS(e, akgl_heap_next_sprite(&sprite)); +PASS(e, akgl_sprite_initialize(sprite, SPRITE_NAME, &sheet); +sprite->frames = 4; +sprite->frameids = [0, 1, 2, 3]; +sprite->width = 32; +sprite->height = 32; +sprite->speed = 1000; +sprite->loop = true; +strncpy((char *)&sprite->name, "SPRITE NAME", AKGL_SPRITE_MAX_NAME_LENGTH); +PASS(e, akgl_heap_next_character(&character)); +PASS(e, akgl_character_initialize(&character, "CHAR NAME")); +PASS(e, akgl_character_sprite_add(&character, &sprite, STATE_MASK)); +// Set the character acceleration and scale if desired +character->ax = 64.0; +character->ay = 64.0; +character->sx = 2.0; +character->sy = 2.0; +``` + Initialize an actor. Actors are named ("player", "Quest NPC", whatever) and names must be unique. ```c