Move some of the sprite math out of the actor into the sprite

This commit is contained in:
2026-05-12 15:21:36 -04:00
parent 0f01126bad
commit 5439b8004b
4 changed files with 38 additions and 12 deletions

View File

@@ -235,16 +235,18 @@ akerr_ErrorContext *akgl_actor_render(akgl_Actor *obj, SDL_Renderer *renderer)
// get cleaned up on the next logic update. Just pass on rendering them this frame.
SUCCEED_RETURN(errctx);
}
ATTEMPT {
CATCH(errctx,
akgl_sprite_sheet_coords_for_frame(
curSprite,
&src,
obj->curSpriteFrameId)
);
} CLEANUP {
} PROCESS(errctx) {
} FINISH(errctx, true);
src.x = curSprite->width * curSprite->frameids[obj->curSpriteFrameId];
if ( src.x >= curSprite->sheet->texture->w ) {
src.y = ((int)src.x / curSprite->sheet->texture->w) * curSprite->height;
src.x = ((int)src.x % curSprite->sheet->texture->w);
} else {
src.y = 0;
}
src.w = curSprite->width;
src.h = curSprite->height;
if ( obj->parent != NULL ) {
dest.x = (obj->parent->x + obj->x - camera.x);
dest.y = (obj->parent->y + obj->y - camera.y);