[Add] Added an indication on minimap as to where targeted planets

reside.
This commit is contained in:
Allanis 2014-03-15 17:42:10 +00:00
parent 84ea77284a
commit 77afa506e4
6 changed files with 50 additions and 12 deletions

View File

@ -38,9 +38,11 @@ glColour cNeutral = { .r = 0.9, .g = 1.0, .b = 0.3, .a = 1. }; /**< Neutra
glColour cFriend = { .r = 0.0, .g = 1.0, .b = 0.0, .a = 1. }; /**< Friend object colour. */
glColour cHostile = { .r = 0.9, .g = 0.2, .b = 0.2, .a = 1. }; /**< Hostile object colour. */
/* Radar */
glColour cRadar_player = { .r = 0.4, .g = 0.8, .b = 0.4, .a = 1. }; /**< Player colour on radar. */
glColour cRadar_targ = { .r = 0.0, .g = 0.7, .b = 1.0, .a = 1. }; /**< Targetted object colour.*/
glColour cRadar_weap = { .r = 0.8, .g = 0.2, .b = 0.2, .a = 1. }; /**< Weapon colour on radar. */
glColour cRadar_player = { .r = 0.4, .g = 0.8, .b = 0.4, .a = 1. }; /**<Player colour on radar. */
glColour cRadar_tPilot = { .r = 0.0, .g = 1.0, .b = 1.0, .a = 1. }; /**<Targetted object colour.*/
glColour cRadar_tPlanet = { .r = 0.4, .g = 0.0, .b = 1.0, .a = 1. }; /**<Targetted planet colour.*/
glColour cRadar_weap = { .r = 0.8, .g = 0.2, .b = 0.2, .a = 1. }; /**< Weapon colour on radar.*/
/* Bars. */
glColour cShield = { .r = 0.2, .g = 0.2, .b = 0.8, .a = 1. }; /**< Shield bar colour. */
glColour cArmour = { .r = 0.5, .g = 0.5, .b = 0.5, .a = 1. }; /**< Armour bar colour. */

View File

@ -49,7 +49,8 @@ extern glColour cFriend;
extern glColour cHostile;
/* Radar. */
extern glColour cRadar_player;
extern glColour cRadar_targ;
extern glColour cRadar_tPilot;
extern glColour cRadar_tPlanet;
extern glColour cRadar_weap;
/* Health. */
extern glColour cShield;

View File

@ -8,6 +8,7 @@
#include "space.h"
#include "opengl.h"
#include "mission.h"
#include "colour.h"
#include "map.h"
#define MAP_WDWNAME "Star Map"
@ -329,8 +330,8 @@ static void map_render(double bx, double by, double w, double h) {
/* Check to make sure system is known of adjacent to known (or marked). */
if(!sys_isMarked(sys) && !space_sysReachable(sys)) continue;
/* System Colours. */
if(sys == cur_system) col = &cRadar_targ;
/* System colours. */
if(sys == cur_system) col = &cRadar_tPlanet;
else if(!sys_isKnown(sys) || (sys->nplanets == 0)) col = &cInert;
else col = faction_getColour(sys->faction);
COLOUR(*col);

View File

@ -8,7 +8,7 @@
#define VANGLE(v) ((v).angle)
#define MOD(x,y) (sqrt((x)*(x) + (y)*(y)))
#define ANGLE(x,y) (((x)==0.) ? 0. : atan2(y,x))
#define ANGLE(x,y) (atan2(y,x))
#define vect_dist(v,u) MOD((v)->x-(u)->x, (v)->y-(u)->y)
#define vect_odist(v) MOD((v)->x, (v)->y)

View File

@ -1186,7 +1186,7 @@ static void gui_renderPilot(const Pilot* p) {
sx = 0.85 * x;
sy = 0.85 * y;
COLOUR(cRadar_targ);
COLOUR(cRadar_tPilot);
glBegin(GL_LINES);
glVertex2d(x, y);
glVertex2d(sx, sy);
@ -1207,7 +1207,7 @@ static void gui_renderPilot(const Pilot* p) {
glBegin(GL_QUADS);
/* Colours. */
if(p->id == player->target) col = &cRadar_targ;
if(p->id == player->target) col = &cRadar_tPilot;
else if(pilot_isDisabled(p)) col = &cInert;
else if(pilot_isFlag(p, PILOT_BRIBED)) col = &cNeutral;
else if(pilot_isFlag(p, PILOT_HOSTILE)) col = &cHostile;

View File

@ -78,6 +78,8 @@ static Star* stars = NULL; /* Star array. */
static int nstars = 0; /* Total stars. */
static int mstars = 0; /* Memory stars are taking. */
extern int planet_target; /* player.c */
/* Intern. */
/* Planet load. */
static int planet_parse(Planet* planet, const xmlNodePtr parent);
@ -107,28 +109,60 @@ void planets_minimap(const double res, const double w,
int i;
int cx, cy, x, y, r, rc;
double p;
double a, tx, ty;
Planet* planet;
glColour* col;
if(shape == RADAR_CIRCLE) rc = (int)(w*w);
glBegin(GL_POINTS);
for(i = 0; i < cur_system->nplanets; i++) {
planet = cur_system->planets[i];
/* Get the colour. */
col = faction_getColour(planet->faction);
if((col != &cHostile) && !planet_hasService(planet, PLANET_SERVICE_BASIC))
if(i == planet_target)
col = &cRadar_tPlanet;
else if((col != &cHostile) && !planet_hasService(planet, PLANET_SERVICE_BASIC))
col = &cInert; /* Override non-hostile planets without services. */
COLOUR(*col);
/* Some parameters. */
r = (int)(cur_system->planets[i]->gfx_space->sw / res);
cx = (int)((cur_system->planets[i]->pos.x - player->solid->pos.x) / res);
cy = (int)((cur_system->planets[i]->pos.y - player->solid->pos.y) / res);
/* Check if in range. */
if(shape == RADAR_RECT) {
/* Out of range. */
if((ABS(cx) - r> 2/2.) || (ABS(cy) - r > h/2.))
continue;
}
else if(shape == RADAR_CIRCLE) {
x = cx-r;
y = cy-r;
/* Out of range. */
if(x*x + y*y > rc) {
if(planet_target == i) {
/* Draw a line like the one for pilots. */
a = ANGLE(cx, cy);
tx = w*cos(a);
ty = w*sin(a);
COLOUR(cRadar_tPlanet);
glBegin(GL_LINES);
glVertex2d( tx, ty );
glVertex2d( 0.85*tx, 0.85*ty);
glEnd();
}
continue;
}
}
x = 0;
y = r;
p = (5. - (double)(r*3)) / 4.;
glBegin(GL_POINTS);
PIXEL(cx, cy+y);
PIXEL(cx, cy-y);
PIXEL(cx+y, cy);
@ -162,8 +196,8 @@ void planets_minimap(const double res, const double w,
PIXEL(cx-y, cy-x);
}
}
}
glEnd();
}
}
#undef PIXEL