From 5c20693933ab0e5ec6f253afe4e2190861a07b43 Mon Sep 17 00:00:00 2001 From: Steve Date: Thu, 26 Nov 2015 10:54:40 +0000 Subject: [PATCH] Allow for radar range to be cycled. --- src/battle/player.c | 2 ++ src/battle/radar.c | 11 ++++++----- src/structs.h | 1 + 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/battle/player.c b/src/battle/player.c index ce429bc..b9054da 100644 --- a/src/battle/player.c +++ b/src/battle/player.c @@ -446,4 +446,6 @@ static void selectMissionTarget(void) static void cycleRadarZoom(void) { + battle.radarRange++; + battle.radarRange %= 3; } diff --git a/src/battle/radar.c b/src/battle/radar.c index 45e3b3c..476ffbf 100644 --- a/src/battle/radar.c +++ b/src/battle/radar.c @@ -20,10 +20,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "radar.h" -#define RADAR_RANGE 20 - static SDL_Texture *radarTexture; static SDL_Texture *radarWarningTexture; +static int radarRanges[] = {20, 40, 60}; void initRadar(void) { @@ -38,17 +37,19 @@ void drawRadar(void) blit(radarTexture, SCREEN_WIDTH - 85, SCREEN_HEIGHT - 85, 1); + drawText(SCREEN_WIDTH - 160, SCREEN_HEIGHT - 30, 14, TA_RIGHT, colors.white, "%dx", battle.radarRange + 1); + r.w = r.h = 3; for (f = battle.entityHead.next ; f != NULL ; f = f->next) { - if (f->active && getDistance(f->x, f->y, player->x, player->y) / RADAR_RANGE < 70) + if (f->active && getDistance(f->x, f->y, player->x, player->y) / radarRanges[battle.radarRange] < 70) { r.x = SCREEN_WIDTH - 85; r.y = SCREEN_HEIGHT - 85; - r.x -= (player->x - f->x) / RADAR_RANGE; - r.y -= (player->y - f->y) / RADAR_RANGE; + r.x -= (player->x - f->x) / radarRanges[battle.radarRange]; + r.y -= (player->y - f->y) / radarRanges[battle.radarRange]; r.x--; r.y--; diff --git a/src/structs.h b/src/structs.h index 01966d1..f199d14 100644 --- a/src/structs.h +++ b/src/structs.h @@ -246,6 +246,7 @@ typedef struct { int missionFinishedTimer; int boostTimer; int ecmTimer; + int radarRange; int numObjectivesComplete, numObjectivesTotal; Entity *missionTarget; Entity *extractionPoint;