From 68e700473b6d7b459be9b52f263af6f92a629963 Mon Sep 17 00:00:00 2001 From: Steve Date: Mon, 16 Nov 2015 14:39:20 +0000 Subject: [PATCH] Based target / mission rectangles on entity size. --- src/battle/entities.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/battle/entities.c b/src/battle/entities.c index a0676fd..d1cb735 100644 --- a/src/battle/entities.c +++ b/src/battle/entities.c @@ -246,12 +246,14 @@ static void drawTargetRects(Entity *e) { SDL_Rect r; + int size = MAX(e->w, e->h) + 16; + if (player != NULL && e == player->target) { - r.x = e->x - 32 - battle.camera.x; - r.y = e->y - 32 - battle.camera.y; - r.w = 64; - r.h = 64; + r.x = e->x - (size / 2) - battle.camera.x; + r.y = e->y - (size / 2) - battle.camera.y; + r.w = size; + r.h = size; SDL_SetRenderDrawColor(app.renderer, 255, 0, 0, 255); SDL_RenderDrawRect(app.renderer, &r); @@ -259,10 +261,10 @@ static void drawTargetRects(Entity *e) if ((e == battle.missionTarget || e->flags & EF_MISSION_TARGET) && (e->flags & EF_NO_MT_BOX) == 0) { - r.x = e->x - 28 - battle.camera.x; - r.y = e->y - 28 - battle.camera.y; - r.w = 56; - r.h = 56; + r.x = e->x - (size / 2) - battle.camera.x; + r.y = e->y - (size / 2) - battle.camera.y; + r.w = size; + r.h = size; SDL_SetRenderDrawColor(app.renderer, 0, 255, 0, 255); SDL_RenderDrawRect(app.renderer, &r);