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:
12
src/actor.c
12
src/actor.c
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user