[Add] Early map is actually drawing planets quite nicely.
This commit is contained in:
		
							parent
							
								
									3eadb955ff
								
							
						
					
					
						commit
						fe170aede4
					
				
							
								
								
									
										27
									
								
								src/map.c
									
									
									
									
									
								
							
							
						
						
									
										27
									
								
								src/map.c
									
									
									
									
									
								
							@ -5,7 +5,7 @@
 | 
			
		||||
#include "opengl.h"
 | 
			
		||||
#include "map.h"
 | 
			
		||||
 | 
			
		||||
#define MAP_WIDTH			500
 | 
			
		||||
#define MAP_WIDTH			550
 | 
			
		||||
#define MAP_HEIGHT		400
 | 
			
		||||
 | 
			
		||||
#define BUTTON_WIDTH	60
 | 
			
		||||
@ -14,31 +14,32 @@
 | 
			
		||||
static int 		map_wid 	= 0;
 | 
			
		||||
static double map_xpos 	= 0.;
 | 
			
		||||
static double map_ypos 	= 0.;
 | 
			
		||||
static int map_selected = 0;
 | 
			
		||||
 | 
			
		||||
// Extern.
 | 
			
		||||
extern StarSystem* systems_stack;
 | 
			
		||||
extern int systems_nstack;
 | 
			
		||||
 | 
			
		||||
void map_render(double bx, double by, double w, double h);
 | 
			
		||||
void map_close(char* str);
 | 
			
		||||
static void map_render(double bx, double by, double w, double h);
 | 
			
		||||
static void map_close(char* str);
 | 
			
		||||
 | 
			
		||||
// Open the map window.
 | 
			
		||||
void map_open(void) {
 | 
			
		||||
	if(map_wid) map_close(NULL);
 | 
			
		||||
 | 
			
		||||
	// Set the position to focus on current system.
 | 
			
		||||
	map_xpos = cur_system->pos.x + (MAP_WIDTH-120)/2;
 | 
			
		||||
	map_ypos = cur_system->pos.y + (MAP_HEIGHT-60)/2;
 | 
			
		||||
	map_xpos = cur_system->pos.x;
 | 
			
		||||
	map_ypos = cur_system->pos.y;
 | 
			
		||||
 | 
			
		||||
	map_wid = window_create("Star Map", -1, -1, MAP_WIDTH, MAP_HEIGHT);
 | 
			
		||||
 | 
			
		||||
	window_addCust(map_wid, 20, 20, MAP_WIDTH - 120, MAP_HEIGHT - 60,
 | 
			
		||||
	window_addCust(map_wid, 20, 20, MAP_WIDTH - 150, MAP_HEIGHT - 60,
 | 
			
		||||
				"cstMap", 1, map_render);
 | 
			
		||||
	window_addButton(map_wid, -20, 20, BUTTON_WIDTH, BUTTON_HEIGHT,
 | 
			
		||||
				"btnClose", "Close", map_close);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void map_close(char* str) {
 | 
			
		||||
static void map_close(char* str) {
 | 
			
		||||
	(void)str;
 | 
			
		||||
	if(map_wid) {
 | 
			
		||||
		window_destroy(map_wid);
 | 
			
		||||
@ -47,7 +48,7 @@ void map_close(char* str) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Render the map as a custom widget.
 | 
			
		||||
void map_render(double bx, double by, double w, double h) {
 | 
			
		||||
static void map_render(double bx, double by, double w, double h) {
 | 
			
		||||
	int i;
 | 
			
		||||
	// Background
 | 
			
		||||
	COLOUR(cBlack);
 | 
			
		||||
@ -59,8 +60,12 @@ void map_render(double bx, double by, double w, double h) {
 | 
			
		||||
	glEnd();
 | 
			
		||||
 | 
			
		||||
	COLOUR(cYellow);
 | 
			
		||||
	for(i = 0; i < systems_nstack; i++)
 | 
			
		||||
		gl_drawCircleInRect(systems_stack[i].pos.x, systems_stack[i].pos.y,
 | 
			
		||||
					5, bx, by, w, h);
 | 
			
		||||
	for(i = 0; i < systems_nstack; i++) {
 | 
			
		||||
		if(i == map_selected) COLOUR(cRadar_targ);
 | 
			
		||||
		else COLOUR(cYellow);
 | 
			
		||||
			gl_drawCircleInRect(bx + systems_stack[i].pos.x - map_xpos + w/2,
 | 
			
		||||
						by + systems_stack[i].pos.y - map_ypos + h/2,
 | 
			
		||||
						5, bx, by, w, h);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user