[Change] Improved StarMap by displaying color based on the path you can travel.
This commit is contained in:
parent
a153cb9a37
commit
6365ad186a
23
dat/ssys.xml
23
dat/ssys.xml
@ -71,6 +71,29 @@
|
|||||||
<jumps>
|
<jumps>
|
||||||
<jump>SaraSys</jump>
|
<jump>SaraSys</jump>
|
||||||
<jump>KonoSys</jump>
|
<jump>KonoSys</jump>
|
||||||
|
<jump>NCG-7292</jump>
|
||||||
|
</jumps>
|
||||||
|
</ssys>
|
||||||
|
<ssys name="NCG-7292">
|
||||||
|
<pos>
|
||||||
|
<x>67</x>
|
||||||
|
<y>20</y>
|
||||||
|
</pos>
|
||||||
|
<general>
|
||||||
|
<stars>230</stars>
|
||||||
|
<asteroids>0</asteroids>
|
||||||
|
<interference>0</interference>
|
||||||
|
</general>
|
||||||
|
<planets>
|
||||||
|
</planets>
|
||||||
|
<fleets>
|
||||||
|
<fleet chance="80">Merchant Ship</fleet>
|
||||||
|
<fleet chance="60">Merchant Mule</fleet>
|
||||||
|
<fleet chance="60">Pirate</fleet>
|
||||||
|
<fleet chance="60">Pirate</fleet>
|
||||||
|
</fleets>
|
||||||
|
<jumps>
|
||||||
|
<jump>NCG-7291</jump>
|
||||||
</jumps>
|
</jumps>
|
||||||
</ssys>
|
</ssys>
|
||||||
</Systems>
|
</Systems>
|
||||||
|
@ -13,7 +13,6 @@ glColour cGrey20 = { .r = 0.20, .g = 0.20, .b = 0.20, .a = 1. };
|
|||||||
glColour cGrey10 = { .r = 0.10, .g = 0.10, .b = 0.10, .a = 1. };
|
glColour cGrey10 = { .r = 0.10, .g = 0.10, .b = 0.10, .a = 1. };
|
||||||
glColour cBlack = { .r = 0.00, .g = 0.00, .b = 0.00, .a = 1. };
|
glColour cBlack = { .r = 0.00, .g = 0.00, .b = 0.00, .a = 1. };
|
||||||
|
|
||||||
glColour cTrans = { .r = 1.00, .g = 1.00, .b = 1.00, .a = 0. };
|
|
||||||
glColour cGreen = { .r = 0.20, .g = 0.80, .b = 0.20, .a = 1. };
|
glColour cGreen = { .r = 0.20, .g = 0.80, .b = 0.20, .a = 1. };
|
||||||
glColour cDarkRed = { .r = 0.60, .g = 0.10, .b = 0.10, .a = 1. };
|
glColour cDarkRed = { .r = 0.60, .g = 0.10, .b = 0.10, .a = 1. };
|
||||||
glColour cRed = { .r = 0.80, .g = 0.20, .b = 0.20, .a = 1. };
|
glColour cRed = { .r = 0.80, .g = 0.20, .b = 0.20, .a = 1. };
|
||||||
|
@ -22,7 +22,6 @@ extern glColour cGrey30;
|
|||||||
extern glColour cGrey20;
|
extern glColour cGrey20;
|
||||||
extern glColour cGrey10;
|
extern glColour cGrey10;
|
||||||
|
|
||||||
extern glColour cTrans;
|
|
||||||
extern glColour cGreen;
|
extern glColour cGreen;
|
||||||
extern glColour cDarkRed;
|
extern glColour cDarkRed;
|
||||||
extern glColour cRed;
|
extern glColour cRed;
|
||||||
|
27
src/map.c
27
src/map.c
@ -22,8 +22,12 @@ static int map_selected = 0;
|
|||||||
static int map_drag = 0; // Is the user dragging the map?
|
static int map_drag = 0; // Is the user dragging the map?
|
||||||
|
|
||||||
// Extern.
|
// Extern.
|
||||||
|
// space.c
|
||||||
extern StarSystem* systems_stack;
|
extern StarSystem* systems_stack;
|
||||||
extern int systems_nstack;
|
extern int systems_nstack;
|
||||||
|
// player.c
|
||||||
|
extern int planet_target;
|
||||||
|
extern int hyperspace_target;
|
||||||
|
|
||||||
static void map_close(char* str);
|
static void map_close(char* str);
|
||||||
static void map_update(void);
|
static void map_update(void);
|
||||||
@ -123,6 +127,7 @@ static void map_render(double bx, double by, double w, double h) {
|
|||||||
int i, j;
|
int i, j;
|
||||||
double x, y, r;
|
double x, y, r;
|
||||||
StarSystem* sys;
|
StarSystem* sys;
|
||||||
|
glColour* col;
|
||||||
|
|
||||||
r = 5.;
|
r = 5.;
|
||||||
x = bx - map_xpos + w/2;
|
x = bx - map_xpos + w/2;
|
||||||
@ -150,17 +155,23 @@ static void map_render(double bx, double by, double w, double h) {
|
|||||||
|
|
||||||
// Draw the hyperspace paths.
|
// Draw the hyperspace paths.
|
||||||
glShadeModel(GL_SMOOTH);
|
glShadeModel(GL_SMOOTH);
|
||||||
for(j = 0; j < sys->njumps; j++) {
|
|
||||||
// Cheaply use transparency instead of actually
|
// Cheaply use transparency instead of actually
|
||||||
// calculating from x to y the line must go. :)
|
// calculating from x to y the line must go. :)
|
||||||
|
for(j = 0; j < sys->njumps; j++) {
|
||||||
|
// Set the colours, is the route the current one?
|
||||||
|
if(((cur_system == sys) && (j == hyperspace_target)) ||
|
||||||
|
((cur_system == &systems_stack[sys->jumps[j]]) &&
|
||||||
|
(sys = &systems_stack[cur_system->jumps[hyperspace_target]])))
|
||||||
|
col = &cRed;
|
||||||
|
else col = &cInert;
|
||||||
glBegin(GL_LINE_STRIP);
|
glBegin(GL_LINE_STRIP);
|
||||||
COLOUR(cTrans);
|
ACOLOUR(*col, 0.);
|
||||||
glVertex2d(x+sys->pos.x, y+sys->pos.y);
|
glVertex2d(x+sys->pos.x, y+sys->pos.y);
|
||||||
COLOUR(cInert);
|
COLOUR(*col);
|
||||||
glVertex2d(
|
glVertex2d(
|
||||||
x+sys->pos.x+(systems_stack[sys->jumps[j]].pos.x-sys->pos.x)/2.,
|
x+sys->pos.x+(systems_stack[sys->jumps[j]].pos.x-sys->pos.x)/2.,
|
||||||
y+sys->pos.y+(systems_stack[sys->jumps[j]].pos.y-sys->pos.y)/2.);
|
y+sys->pos.y+(systems_stack[sys->jumps[j]].pos.y-sys->pos.y)/2.);
|
||||||
COLOUR(cTrans);
|
ACOLOUR(*col, 0.);
|
||||||
glVertex2d(x+systems_stack[sys->jumps[j]].pos.x,
|
glVertex2d(x+systems_stack[sys->jumps[j]].pos.x,
|
||||||
y+systems_stack[sys->jumps[j]].pos.y);
|
y+systems_stack[sys->jumps[j]].pos.y);
|
||||||
glEnd();
|
glEnd();
|
||||||
@ -175,7 +186,7 @@ static void map_render(double bx, double by, double w, double h) {
|
|||||||
|
|
||||||
// Map event handling.
|
// Map event handling.
|
||||||
static void map_mouse(SDL_Event* event, double mx, double my) {
|
static void map_mouse(SDL_Event* event, double mx, double my) {
|
||||||
int i;
|
int i, j;
|
||||||
double x, y, t;
|
double x, y, t;
|
||||||
|
|
||||||
t = 13.*13.; // Threshold.
|
t = 13.*13.; // Threshold.
|
||||||
@ -193,6 +204,12 @@ static void map_mouse(SDL_Event* event, double mx, double my) {
|
|||||||
|
|
||||||
if((pow2(mx-x)+pow2(my-y)) < t) {
|
if((pow2(mx-x)+pow2(my-y)) < t) {
|
||||||
map_selected = i;
|
map_selected = i;
|
||||||
|
for(j = 0; j < cur_system->njumps; j++)
|
||||||
|
if(i == cur_system->jumps[j]) {
|
||||||
|
planet_target = -1; // Override planet target.
|
||||||
|
hyperspace_target = j;
|
||||||
|
break;
|
||||||
|
}
|
||||||
map_update();
|
map_update();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,8 @@ typedef struct glInfo_ {
|
|||||||
} glInfo;
|
} glInfo;
|
||||||
extern glInfo gl_screen; // Local structure set with gl_init etc.
|
extern glInfo gl_screen; // Local structure set with gl_init etc.
|
||||||
|
|
||||||
#define COLOUR(x) glColor4d((x).r, (x).g, (x).b, (x).a)
|
#define COLOUR(x) glColor4d((x).r, (x).g, (x).b, (x).a)
|
||||||
|
#define ACOLOUR(x,a) glColor4d((x).r, (x).g, (x).b, a)
|
||||||
|
|
||||||
// Spritesheet info.
|
// Spritesheet info.
|
||||||
typedef struct glTexture_ {
|
typedef struct glTexture_ {
|
||||||
|
@ -35,9 +35,9 @@ unsigned int player_flags = 0; // Player flags.
|
|||||||
double player_turn = 0.; // Turn velocity from input.
|
double player_turn = 0.; // Turn velocity from input.
|
||||||
double player_acc = 0.; // Accel velocity from input.
|
double player_acc = 0.; // Accel velocity from input.
|
||||||
unsigned int player_target = PLAYER_ID; // Targetted pilot.
|
unsigned int player_target = PLAYER_ID; // Targetted pilot.
|
||||||
static int planet_target = -1; // Targetted planet.
|
// Internal
|
||||||
// Internal.
|
int planet_target = -1; // Targetted planet.
|
||||||
static int hyperspace_target = -1; // Target hyperspace route.
|
int hyperspace_target = -1; // Target hyperspace route.
|
||||||
|
|
||||||
// Pilot stuff for GUI.
|
// Pilot stuff for GUI.
|
||||||
extern Pilot** pilot_stack;
|
extern Pilot** pilot_stack;
|
||||||
|
Loading…
Reference in New Issue
Block a user