Replaced radar drawCircle call with graphic. Added radar range warning.

This commit is contained in:
Steve 2015-11-02 10:11:47 +00:00
parent f585a30f3f
commit a7c1906950
8 changed files with 65 additions and 6 deletions

BIN
gfx/hud/radar.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

BIN
gfx/hud/radarWarning.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 689 B

View File

@ -57,6 +57,8 @@ void initBattle(void)
initHud();
initRadar();
initMissionInfo();
resetWaypoints();

View File

@ -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);

View File

@ -150,6 +150,8 @@ void drawHud(void)
{
drawPlayerSelect();
}
drawRadarRangeWarning();
}
static void drawHealthBars(void)

View File

@ -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;

View File

@ -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!");
}
}

View File

@ -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;