Fixed a bug in akgl_heap_next_string, made screen width and height load from properties, not on the game object

This commit is contained in:
2026-05-13 04:55:19 -04:00
parent 23dbc7d985
commit 36dfd47a06
6 changed files with 70 additions and 13 deletions

View File

@@ -32,6 +32,9 @@ akgl_Game game;
akerr_ErrorContext AKERR_NOIGNORE *akgl_game_init()
{
int screenwidth = 0;
int screenheight = 0;
int i = 0;
PREPARE_ERROR(errctx);
ATTEMPT {
@@ -75,30 +78,49 @@ akerr_ErrorContext AKERR_NOIGNORE *akgl_game_init()
FAIL_ZERO_RETURN(errctx, 0, AKGL_ERR_SDL, "%s", SDL_GetError());
}
}
SUCCEED_RETURN(errctx);
}
akerr_ErrorContext AKERR_NOIGNORE *akgl_game_init_screen()
{
akgl_String *width = NULL;
akgl_String *height = NULL;
int screenwidth;
int screenheight;
PREPARE_ERROR(e);
PASS(e, akgl_get_property("game.screenwidth", &width, "0"));
PASS(e, akgl_get_property("game.screenheight", &height, "0"));
PASS(e, aksl_atoi(width->data, &screenwidth));
PASS(e, aksl_atoi(height->data, &screenheight));
SDL_Log("Initializing screen (%sx%s = %dx%d)", width->data, height->data, screenwidth, screenheight);
PASS(e, akgl_heap_release_string(width));
PASS(e, akgl_heap_release_string(height));
FAIL_ZERO_RETURN(
errctx,
SDL_CreateWindowAndRenderer(game.uri, game.screenwidth, game.screenheight, 0, &window, &renderer),
e,
SDL_CreateWindowAndRenderer(game.uri, screenwidth, screenheight, 0, &window, &renderer),
AKGL_ERR_SDL,
"Couldn't create window/renderer: %s",
SDL_GetError());
FAIL_ZERO_RETURN(
errctx,
e,
MIX_Init(),
AKGL_ERR_SDL,
"Couldn't initialize audio: %s",
SDL_GetError());
akgl_mixer = MIX_CreateMixerDevice(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, 0);
FAIL_ZERO_RETURN(
errctx,
e,
akgl_mixer,
AKGL_ERR_SDL,
"Unable to create mixer device: %s",
SDL_GetError());
FAIL_ZERO_RETURN(
errctx,
e,
TTF_Init(),
AKGL_ERR_SDL,
"Couldn't initialize front engine: %s",
@@ -106,9 +128,9 @@ akerr_ErrorContext AKERR_NOIGNORE *akgl_game_init()
camera.x = 0;
camera.y = 0;
camera.w = game.screenwidth;
camera.h = game.screenheight;
SUCCEED(errctx);
camera.w = screenwidth;
camera.h = screenheight;
SUCCEED(e);
}
void akgl_game_updateFPS()