From 7209b28993cf580a263addf1c1722badc840bb23 Mon Sep 17 00:00:00 2001 From: Andrew Kesterson Date: Fri, 8 May 2026 23:15:25 -0400 Subject: [PATCH] Experimented with game save and load functions --- src/sdl3-gametest.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/sdl3-gametest.c b/src/sdl3-gametest.c index 2e9c14f..2711227 100644 --- a/src/sdl3-gametest.c +++ b/src/sdl3-gametest.c @@ -55,6 +55,11 @@ akerr_ErrorContext AKERR_NOIGNORE *music_toggle(akgl_Actor *obj, SDL_Event *even SUCCEED_RETURN(errctx); } +akerr_ErrorContext AKERR_NOIGNORE *savegame(akgl_Actor *obj, SDL_Event *event) +{ + return akgl_game_save("assets/savegame.bin"); +} + akerr_ErrorContext AKERR_NOIGNORE *user_breakpoint(akgl_Actor *obj, SDL_Event *event) { PREPARE_ERROR(errctx); @@ -76,7 +81,8 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[]) strcpy((char *)&game.uri, "net.aklabs.games.sdl3-gametest"); game.screenwidth = 640; game.screenheight = 480; - + + //CATCH(errctx, akgl_game_load("assets/savegame.bin")); CATCH(errctx, akgl_game_init()); CATCH(errctx, akgl_registry_load_properties("assets/properties.json")); @@ -122,6 +128,12 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[]) control.handler_on = &music_toggle; CATCH(errctx, akgl_controller_pushmap(0, &control)); + // Save the game + control.key = SDLK_S; + control.event_on = SDL_EVENT_KEY_DOWN; + control.handler_on = &savegame; + CATCH(errctx, akgl_controller_pushmap(0, &control)); + CATCH(errctx, akgl_text_loadfont("C64Pro", "assets/C64_Pro-STYLE.ttf", 18)); } CLEANUP {