From a7c1906950c399285f5d50fc6c27ecbf3e72f786 Mon Sep 17 00:00:00 2001 From: Steve Date: Mon, 2 Nov 2015 10:11:47 +0000 Subject: [PATCH] Replaced radar drawCircle call with graphic. Added radar range warning. --- gfx/hud/radar.png | Bin 0 -> 3313 bytes gfx/hud/radarWarning.png | Bin 0 -> 689 bytes src/battle/battle.c | 2 ++ src/battle/battle.h | 1 + src/battle/hud.c | 2 ++ src/battle/hud.h | 1 + src/battle/radar.c | 60 +++++++++++++++++++++++++++++++++++---- src/battle/radar.h | 5 ++++ 8 files changed, 65 insertions(+), 6 deletions(-) create mode 100644 gfx/hud/radar.png create mode 100644 gfx/hud/radarWarning.png diff --git a/gfx/hud/radar.png b/gfx/hud/radar.png new file mode 100644 index 0000000000000000000000000000000000000000..57cfccd81196084a98dbd92b0cbff3073bcf8ed8 GIT binary patch literal 3313 zcmV&P)e zSad^gZEa<4bO1wgWnpw>WFU8GbZ8()Nlj2!fese{01R14L_t(|+U=cNZ(P+C$A8Cj zi^n*&<8cy)rZh->1_2TTsR-}`-@q`baDtLpg3#~asFg}n2?VJ_Y8y51kP+qs@IqQj zB@hn?dP^Trxl=o_9XmE2dpw>@AC8B)cs!mNpR>>2`>ek-55CMf`|>+$t-a2^fJo%C z9BG0I6-j&8vKeX6Fhf=gQ;rxp;%pFOoOgi)5C>vFbnDZx^>Kc@3f$THY;Jw>zy_l{ zMT|Ug@+8Vo5iv z=4c0)n~L}ZI3VP-p_4q!L2lB;6@jdt^_nHcANhxnvPTUwL?3e;W?l!Y=4b(!YrQ_j z)?8Om8sRvHm<`&hIf24ej=lbkOgr*NPxB-xW`m5?oIn9P&nLj3kf1=Pd61tl69i~Z zAb`0^)xQHh())_t=V4|@@}|9z6-l#97q4)g@VpMvOKBeGFyGU|lzosDNpHnp*QKX5 z7<~>f!vL?_0a+>jx=l-)L3V^pCjD#3p7Un6Zs8Vhi`>;U8DeJiYEDt83z2gwD(KFiln(gzcn$~Fhjfk z&otMpsOu6bW_gjr{6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zZ0)0k>;7E-()Ik3%%TmtqMP>f`R&M>ANhIpm8{F{KGkRIr=4BzzuH&Q=)RjHHn-nAALOi-&@@fT2x#KF{OL^3dX2Z7+~ZmG*eBO0 zf6}px?}aOm_ME*?nCT-md!=uh4_7QgBx{3l`TqHT1zPlKW3mjBjZ0#rCdZsS^zO!s z3r$fycg!xQ^yC`py1AH{NWSE2_vtP)c4x){~LEh;mI3?nIS@kMy8Urv(MPM9gACbQeyk$o5wqDoi>sDI}0du4J5P~By7;eNL;UfpmGg`njxgN@xNAuVW)< literal 0 HcmV?d00001 diff --git a/src/battle/battle.c b/src/battle/battle.c index e20caef..0e17021 100644 --- a/src/battle/battle.c +++ b/src/battle/battle.c @@ -57,6 +57,8 @@ void initBattle(void) initHud(); + initRadar(); + initMissionInfo(); resetWaypoints(); diff --git a/src/battle/battle.h b/src/battle/battle.h index ac2a4d4..216acaa 100644 --- a/src/battle/battle.h +++ b/src/battle/battle.h @@ -44,6 +44,7 @@ extern void doEffects(void); extern void doObjectives(void); extern void blit(SDL_Texture *texture, int x, int y, int centered); extern void initHud(void); +extern void initRadar(void); extern void initGalacticMap(void); extern void drawWidgets(char *groupName); extern void selectWidget(const char *name, const char *group); diff --git a/src/battle/hud.c b/src/battle/hud.c index 8604f18..7f59b4e 100644 --- a/src/battle/hud.c +++ b/src/battle/hud.c @@ -150,6 +150,8 @@ void drawHud(void) { drawPlayerSelect(); } + + drawRadarRangeWarning(); } static void drawHealthBars(void) diff --git a/src/battle/hud.h b/src/battle/hud.h index 546de2d..5ada754 100644 --- a/src/battle/hud.h +++ b/src/battle/hud.h @@ -32,6 +32,7 @@ extern float getAngle(int x1, int y1, int x2, int y2); extern void drawText(int x, int y, int size, int align, SDL_Color c, const char *format, ...); extern int getDistance(int x1, int y1, int x2, int y2); extern void drawRadar(void); +extern void drawRadarRangeWarning(void); extern int getPercent(float current, float total); extern App app; diff --git a/src/battle/radar.c b/src/battle/radar.c index 0ed9c1b..ef8bb16 100644 --- a/src/battle/radar.c +++ b/src/battle/radar.c @@ -22,15 +22,21 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define RADAR_RANGE 20 +static SDL_Texture *radarTexture; +static SDL_Texture *radarWarningTexture; + +void initRadar(void) +{ + radarTexture = getTexture("gfx/hud/radar.png"); + radarWarningTexture = getTexture("gfx/hud/radarWarning.png"); +} + void drawRadar(void) { SDL_Rect r; Entity *f; - drawFilledCircle(SCREEN_WIDTH - 85, SCREEN_HEIGHT - 85, 75, 0, 128, 0, 32); - - drawCircle(SCREEN_WIDTH - 85, SCREEN_HEIGHT - 85, 25, 0, 255, 0, 64); - drawCircle(SCREEN_WIDTH - 85, SCREEN_HEIGHT - 85, 50, 0, 255, 0, 64); + blit(radarTexture, SCREEN_WIDTH - 85, SCREEN_HEIGHT - 85, 1); r.w = r.h = 3; @@ -76,6 +82,48 @@ void drawRadar(void) SDL_RenderFillRect(app.renderer, &r); } } - - drawCircle(SCREEN_WIDTH - 85, SCREEN_HEIGHT - 85, 75, 0, 255, 0, 128); +} + +void drawRadarRangeWarning(void) +{ + int x, y, leaving; + + x = (int)player->x / GRID_CELL_WIDTH; + y = (int)player->y / GRID_CELL_HEIGHT; + leaving = 0; + + drawText(SCREEN_WIDTH / 2, SCREEN_HEIGHT - 100, 14, TA_CENTER, colors.white, "%d,%d", x, y); + + if (x <= 4) + { + blitRotated(radarWarningTexture, SCREEN_WIDTH - 85, SCREEN_HEIGHT - 85, 270); + + leaving = 1; + } + + if (y <= 4) + { + blitRotated(radarWarningTexture, SCREEN_WIDTH - 85, SCREEN_HEIGHT - 85, 0); + + leaving = 1; + } + + if (x >= GRID_SIZE - 4) + { + blitRotated(radarWarningTexture, SCREEN_WIDTH - 85, SCREEN_HEIGHT - 85, 90); + + leaving = 1; + } + + if (y >= GRID_SIZE - 4) + { + blitRotated(radarWarningTexture, SCREEN_WIDTH - 85, SCREEN_HEIGHT - 85, 180); + + leaving = 1; + } + + if (leaving && battle.stats[STAT_TIME] % FPS < 40) + { + drawText(SCREEN_WIDTH / 2, SCREEN_HEIGHT - 50, 14, TA_CENTER, colors.red, "WARNING: Leaving battle area - turn around!"); + } } diff --git a/src/battle/radar.h b/src/battle/radar.h index 8479772..b1c0e74 100644 --- a/src/battle/radar.h +++ b/src/battle/radar.h @@ -26,7 +26,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. extern void drawCircle(int cx, int cy, int radius, int r, int g, int b, int a); extern void drawFilledCircle(int cx, int cy, int radius, int r, int g, int b, int a); extern int getDistance(int x1, int y1, int x2, int y2); +extern void blit(SDL_Texture *texture, int x, int y, int center); +extern SDL_Texture *getTexture(char *filename); +extern void blitRotated(SDL_Texture *texture, int x, int y, int angle); +extern void drawText(int x, int y, int size, int align, SDL_Color c, const char *format, ...); extern App app; extern Battle battle; +extern Colors colors; extern Entity *player;