Move some of the sprite math out of the actor into the sprite
This commit is contained in:
20
src/actor.c
20
src/actor.c
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user