Update main game sprite rendering

main
En Yi 2024-08-06 21:43:40 +08:00
parent 4a54bfe84f
commit f20daa9cce
1 changed files with 17 additions and 1 deletions

View File

@ -214,7 +214,23 @@ static void render_regular_game_scene(Scene_t* scene)
const SpriteRenderInfo_t spr = p_cspr->sprites[p_cspr->current_idx]; const SpriteRenderInfo_t spr = p_cspr->sprites[p_cspr->current_idx];
if (spr.sprite != NULL) if (spr.sprite != NULL)
{ {
Vector2 pos = Vector2Add(p_ent->position, spr.offset); Vector2 pos = p_ent->position;
if (p_bbox != NULL)
{
pos = Vector2Add(
pos,
get_anchor_offset(p_bbox->size, spr.dest_anchor, p_cspr->flip_x)
);
pos = Vector2Subtract(
pos,
get_anchor_offset(spr.sprite->frame_size, spr.src_anchor, p_cspr->flip_x)
);
}
Vector2 offset = spr.offset;
if (p_cspr->flip_x) offset.x *= -1;
pos = Vector2Add(pos, offset);
draw_sprite(spr.sprite, p_cspr->current_frame, pos, 0.0f, p_cspr->flip_x); draw_sprite(spr.sprite, p_cspr->current_frame, pos, 0.0f, p_cspr->flip_x);
} }
continue; continue;