Add types.h, standardize integer types on stdint
This commit is contained in:
20
src/game.c
20
src/game.c
@@ -104,7 +104,8 @@ akerr_ErrorContext AKERR_NOIGNORE *akgl_game_init()
|
||||
camera.x = 0;
|
||||
camera.y = 0;
|
||||
camera.w = game.screenwidth;
|
||||
camera.h = game.screenheight;
|
||||
camera.h = game.screenheight;
|
||||
SUCCEED(errctx);
|
||||
}
|
||||
|
||||
void akgl_game_updateFPS()
|
||||
@@ -119,3 +120,20 @@ void akgl_game_updateFPS()
|
||||
game.framesSinceUpdate += 1;
|
||||
game.lastIterTime = curTime;
|
||||
}
|
||||
|
||||
akerr_ErrorContext AKERR_NOIGNORE *akgl_game_save(char *fpath)
|
||||
{
|
||||
FILE *fp = NULL;
|
||||
PREPARE_ERROR(errctx);
|
||||
|
||||
FAIL_ZERO_RETURN(errctx, fpath, AKERR_NULLPOINTER, "NULL file path");
|
||||
fp = fopen(fpath, "rb");
|
||||
fclose(fp);
|
||||
SUCCEED(errctx); // SUCCEED_NORETURN if in main().
|
||||
}
|
||||
|
||||
akerr_ErrorContext AKERR_NOIGNORE *akgl_game_load(char *fpath)
|
||||
{
|
||||
PREPARE_ERROR(errctx);
|
||||
SUCCEED(errctx);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
#include <SDL3/SDL.h>
|
||||
#include <akerror.h>
|
||||
#include <jansson.h>
|
||||
|
||||
#include <akgl/heap.h>
|
||||
#include <akgl/sprite.h>
|
||||
#include <akgl/registry.h>
|
||||
#include <akgl/iterator.h>
|
||||
#include <akgl/actor.h>
|
||||
#include <akgl/json_helpers.h>
|
||||
|
||||
SDL_PropertiesID AKGL_REGISTRY_ACTOR;
|
||||
SDL_PropertiesID AKGL_AKGL_REGISTRY_ACTOR_STATE_STRINGS;
|
||||
@@ -104,3 +107,45 @@ akerr_ErrorContext *akgl_registry_init_character()
|
||||
FAIL_ZERO_RETURN(errctx, AKGL_REGISTRY_CHARACTER, AKERR_NULLPOINTER, "Error initializing character registry");
|
||||
SUCCEED_RETURN(errctx);
|
||||
}
|
||||
|
||||
akerr_ErrorContext AKERR_NOIGNORE *akgl_registry_load_properties(char *fname)
|
||||
{
|
||||
json_t *json = NULL;
|
||||
json_t *props = NULL;
|
||||
const char *pkey = NULL;
|
||||
json_t *pvalue = NULL;
|
||||
|
||||
json_error_t error;
|
||||
akgl_String *tmpstr;
|
||||
|
||||
PREPARE_ERROR(errctx);
|
||||
FAIL_ZERO_RETURN(errctx, fname, AKERR_NULLPOINTER, "null filename");
|
||||
ATTEMPT {
|
||||
SDL_Log("Loading from %s", fname);
|
||||
json = json_load_file(fname, 0, &error);
|
||||
FAIL_ZERO_BREAK(
|
||||
errctx,
|
||||
json,
|
||||
AKERR_NULLPOINTER,
|
||||
"Error while loading properties from %s on line %d: %s-",
|
||||
fname,
|
||||
error.line,
|
||||
error.text);
|
||||
CATCH(errctx, akgl_get_json_object_value(json, "properties", &props));
|
||||
} CLEANUP {
|
||||
} PROCESS(errctx) {
|
||||
} FINISH(errctx, true);
|
||||
|
||||
json_object_foreach(props, pkey, pvalue) {
|
||||
ATTEMPT {
|
||||
CATCH(errctx, akgl_heap_next_string(&tmpstr));
|
||||
CATCH(errctx, akgl_get_json_string_value(props, (char *)pkey, &tmpstr));
|
||||
SDL_SetStringProperty(AKGL_REGISTRY_PROPERTIES, pkey, tmpstr->data);
|
||||
CATCH(errctx, akgl_heap_release_string(tmpstr));
|
||||
} CLEANUP {
|
||||
} PROCESS(errctx) {
|
||||
} FINISH(errctx, true);
|
||||
}
|
||||
SDL_Log("Properties loaded");
|
||||
SUCCEED(errctx);
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ akerr_ErrorContext *akgl_sprite_load_json(char *filename)
|
||||
|
||||
CATCH(errctx, akgl_get_json_integer_value((json_t *)json, "width", &obj->width));
|
||||
CATCH(errctx, akgl_get_json_integer_value((json_t *)json, "height", &obj->height));
|
||||
CATCH(errctx, akgl_get_json_integer_value((json_t *)json, "speed", (int *)&obj->speed));
|
||||
CATCH(errctx, akgl_get_json_integer_value((json_t *)json, "speed", &obj->speed));
|
||||
obj->speed = obj->speed * AKGL_TIME_ONESEC_MS;
|
||||
CATCH(errctx, akgl_get_json_boolean_value((json_t *)json, "loop", &obj->loop));
|
||||
CATCH(errctx, akgl_get_json_boolean_value((json_t *)json, "loopReverse", &obj->loopReverse));
|
||||
@@ -106,7 +106,7 @@ akerr_ErrorContext *akgl_sprite_load_json(char *filename)
|
||||
CATCH(errctx, akgl_get_json_array_value((json_t *)json, "frames", &frames));
|
||||
obj->frames = json_array_size((json_t *)frames);
|
||||
for ( i = 0 ; i < obj->frames; i++ ) {
|
||||
CATCH(errctx, akgl_get_json_array_index_integer((json_t *)frames, i, &obj->frameids[i]));
|
||||
CATCH(errctx, akgl_get_json_array_index_integer((json_t *)frames, i, (uint32_t *)&obj->frameids[i]));
|
||||
}
|
||||
} CLEANUP {
|
||||
if ( errctx != NULL && errctx->status != 0 ) {
|
||||
|
||||
Reference in New Issue
Block a user