diff --git a/gfx/hud/radar.png b/gfx/hud/radar.png new file mode 100644 index 0000000..57cfccd Binary files /dev/null and b/gfx/hud/radar.png differ diff --git a/gfx/hud/radarWarning.png b/gfx/hud/radarWarning.png new file mode 100644 index 0000000..47ee353 Binary files /dev/null and b/gfx/hud/radarWarning.png differ 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;