Experimented with game save and load functions
This commit is contained in:
@@ -55,6 +55,11 @@ akerr_ErrorContext AKERR_NOIGNORE *music_toggle(akgl_Actor *obj, SDL_Event *even
|
|||||||
SUCCEED_RETURN(errctx);
|
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)
|
akerr_ErrorContext AKERR_NOIGNORE *user_breakpoint(akgl_Actor *obj, SDL_Event *event)
|
||||||
{
|
{
|
||||||
PREPARE_ERROR(errctx);
|
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");
|
strcpy((char *)&game.uri, "net.aklabs.games.sdl3-gametest");
|
||||||
game.screenwidth = 640;
|
game.screenwidth = 640;
|
||||||
game.screenheight = 480;
|
game.screenheight = 480;
|
||||||
|
|
||||||
|
//CATCH(errctx, akgl_game_load("assets/savegame.bin"));
|
||||||
CATCH(errctx, akgl_game_init());
|
CATCH(errctx, akgl_game_init());
|
||||||
CATCH(errctx, akgl_registry_load_properties("assets/properties.json"));
|
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;
|
control.handler_on = &music_toggle;
|
||||||
CATCH(errctx, akgl_controller_pushmap(0, &control));
|
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));
|
CATCH(errctx, akgl_text_loadfont("C64Pro", "assets/C64_Pro-STYLE.ttf", 18));
|
||||||
|
|
||||||
} CLEANUP {
|
} CLEANUP {
|
||||||
|
|||||||
Reference in New Issue
Block a user