Highlight all mission targets, not just the one the player is targetting.

This commit is contained in:
Steve 2015-11-13 22:08:59 +00:00
parent 414c12e48f
commit ec72a5dd40
3 changed files with 34 additions and 34 deletions

View File

@ -22,8 +22,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
static void drawEntity(Entity *e);
static void doEntity(void);
static void drawEntity(Entity *e);
static void activateEpicFighters(int n, int side);
static void restrictToGrid(Entity *e);
static void drawTargetRects(Entity *e);
static int drawComparator(const void *a, const void *b);
Entity *spawnEntity(void)
@ -204,10 +206,8 @@ void drawEntities(void)
candidates = getAllEntsWithin(battle.camera.x, battle.camera.y, SCREEN_WIDTH, SCREEN_HEIGHT, NULL);
for (i = 0, e = candidates[i] ; e != NULL ; i++, e = candidates[i])
{
}
/* count number of candidates for use with qsort */
for (i = 0, e = candidates[i] ; e != NULL ; i++, e = candidates[i]) {}
qsort(candidates, i, sizeof(Entity*), drawComparator);
@ -226,6 +226,8 @@ void drawEntities(void)
break;
}
}
drawTargetRects(e);
}
}
@ -234,6 +236,33 @@ static void drawEntity(Entity *e)
blitRotated(e->texture, e->x - battle.camera.x, e->y - battle.camera.y, e->angle);
}
static void drawTargetRects(Entity *e)
{
SDL_Rect r;
if (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;
SDL_SetRenderDrawColor(app.renderer, 255, 0, 0, 255);
SDL_RenderDrawRect(app.renderer, &r);
}
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;
SDL_SetRenderDrawColor(app.renderer, 0, 255, 0, 255);
SDL_RenderDrawRect(app.renderer, &r);
}
}
void activateEntities(char *name)
{
Entity *e;

View File

@ -30,6 +30,7 @@ extern void addToGrid(Entity *e);
extern void removeFromGrid(Entity *e);
extern Entity **getAllEntsWithin(int x, int y, int w, int h, Entity *ignore);
extern App app;
extern Battle battle;
extern Entity *self;
extern Entity *player;

View File

@ -29,7 +29,6 @@ static void drawObjectives(void);
static void drawDistancesInfo(void);
static void drawHudMessages(void);
static void drawPlayerSelect(void);
static void drawTargetsRects(void);
static HudMessage hudMessageHead;
static HudMessage *hudMessageTail;
@ -127,8 +126,6 @@ void drawHud(void)
drawPlayerTargeter();
drawTargetsRects();
drawWeaponInfo();
drawNumFighters();
@ -285,33 +282,6 @@ static void drawPlayerTargeter(void)
}
}
static void drawTargetsRects(void)
{
SDL_Rect r;
if (player->target)
{
r.x = player->target->x - 32 - battle.camera.x;
r.y = player->target->y - 32 - battle.camera.y;
r.w = 64;
r.h = 64;
SDL_SetRenderDrawColor(app.renderer, 255, 64, 0, 255);
SDL_RenderDrawRect(app.renderer, &r);
}
if (battle.missionTarget && (battle.missionTarget->flags & EF_NO_MT_BOX) == 0)
{
r.x = battle.missionTarget->x - 28 - battle.camera.x;
r.y = battle.missionTarget->y - 28 - battle.camera.y;
r.w = 56;
r.h = 56;
SDL_SetRenderDrawColor(app.renderer, 64, 255, 0, 255);
SDL_RenderDrawRect(app.renderer, &r);
}
}
static void drawNumFighters(void)
{
/* Allies */