Abstract the global renderer, physics, camera and gamemap objects behind a pointer, so you can swap in and out different ones as needed

This commit is contained in:
2026-06-02 13:15:26 -04:00
parent 941eeb2493
commit 9fed59c4c8
12 changed files with 96 additions and 84 deletions

View File

@@ -210,7 +210,7 @@ akerr_ErrorContext *akgl_actor_render(akgl_Actor *obj)
ATTEMPT {
CATCH(errctx, akgl_character_sprite_get(obj->basechar, obj->state, &curSprite));
CATCH(errctx, actor_visible(obj, &camera, &visible));
CATCH(errctx, actor_visible(obj, camera, &visible));
} CLEANUP {
} PROCESS(errctx) {
} HANDLE(errctx, AKERR_KEY) {
@@ -242,16 +242,16 @@ akerr_ErrorContext *akgl_actor_render(akgl_Actor *obj)
} FINISH(errctx, true);
if ( obj->parent != NULL ) {
dest.x = (obj->parent->x + obj->x - camera.x);
dest.y = (obj->parent->y + obj->y - camera.y);
dest.x = (obj->parent->x + obj->x - camera->x);
dest.y = (obj->parent->y + obj->y - camera->y);
} else {
dest.x = (obj->x - camera.x);
dest.y = (obj->y - camera.y);
dest.x = (obj->x - camera->x);
dest.y = (obj->y - camera->y);
}
dest.w = curSprite->width * obj->scale;
dest.h = curSprite->width * obj->scale;
PASS(errctx, renderer.draw_texture(&renderer, curSprite->sheet->texture, &src, &dest, 0, NULL, SDL_FLIP_NONE));
PASS(errctx, renderer->draw_texture(renderer, curSprite->sheet->texture, &src, &dest, 0, NULL, SDL_FLIP_NONE));
SUCCEED_RETURN(errctx);
}