1 #ifdef _WIN32
2 #include "windows.h"
3 #endif
4 
5 #include "string.h"
6 #include "stdio.h"
7 #include "math.h"
8 
9 #include "GL/gl.h"
10 #include "GL/glu.h"
11 #include "GL/glut.h"
12 #include "SDL/SDL.h"
13 #include "SDL/SDL_mixer.h"
14 
15 #include "list.h"
16 #include "vector.h"
17 #include "cmc.h"
18 #include "3dobject.h"
19 #include "shadow3dobject.h"
20 #include "piece3dobject.h"
21 #include "myglutaux.h"
22 #include "nether.h"
23 
24 
25 #include "glprintf.h"
26 
draw_radar(void)27 void NETHER::draw_radar(void)
28 {
29     /* Clear the color and depth buffers. */
30     glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
31 
32     glMatrixMode(GL_MODELVIEW);
33     glLoadIdentity();
34 
35 	glTranslatef(64.0,8.0,0.0);
36 	glColor3f(0.5f,0.5f,1.0f);
37 	scaledglprintf(0.18f,0.4f,"RADAR:");
38 
39 	glLoadIdentity();
40 	glScalef(4.0,4.0,4.0);
41 
42 	/* It will draw the RADAR map, directly taken from the IA variables: */
43 	{
44 		int x,y;
45 		int starty,startx;
46 		int maxy=94,maxx=16;
47 
48 		startx=(int)((shipp.x-4)*2);
49 		starty=(int)((shipp.y-23)*2);
50 		if ((starty+maxy)>(map_h*2)) starty=(map_h*2)-maxy;
51 		if (starty<0) starty=0;
52 		if ((startx+maxx)>(map_w*2)) startx=(map_w*2)-maxx;
53 		if (startx<0) startx=0;
54 
55 		glNormal3f(0,0,1);
56 		for(y=0;y<maxy;y++) {
57 			for(x=0;x<maxx;x++) {
58 				if (x+startx<(map_w*2) &&
59 					y+starty<(map_h*2) &&
60 					discreetmap!=0) {
61 					switch(discreetmap[x+startx+(y+starty)*(map_w*2)]) {
62 					case T_GRASS:
63 							glColor3f(0.0,1.0,0.0);
64 							break;
65 					case T_SAND:
66 							glColor3f(0.2,0.9,0.0);
67 							break;
68 					case T_MOUNTAINS:
69 							glColor3f(0.4,0.8,0.0);
70 							break;
71 					case T_HOLE:
72 							glColor3f(0.0,0.8,0.0);
73 							break;
74 					case T_BUILDING:
75 							glColor3f(0.0,0.0,0.0);
76 							break;
77 					case T_SHIP:
78 							glColor3f(1.0f,1.0f,1.0f);
79 							break;
80 					case T_ROBOT:
81 							glColor3f(0.0,0.0,1.0f);
82 							break;
83 					case T_EROBOT:
84 							glColor3f(1.0f,0.0,0.0);
85 							break;
86 					} /* switch */
87 					glBegin(GL_QUADS);
88 					glVertex3f(30+y,maxx-(x+1),0);
89 					glVertex3f(30+y+1,maxx-(x+1),0);
90 					glVertex3f(30+y+1,maxx-x,0);
91 					glVertex3f(30+y,maxx-x,0);
92 					glEnd();
93 				} /* if */
94 
95 /*				if (atackmap[x+(y+starty)*(map_w*2)]!=0) {
96 					glColor3f(1.0,1.0,0.0);
97 					glBegin(GL_QUADS);
98 					glVertex3f(30+y,(map_w*2)-(x+1),1);
99 					glVertex3f(30+y+1,(map_w*2)-(x+1),1);
100 					glVertex3f(30+y+1,(map_w*2)-x,1);
101 					glVertex3f(30+y,(map_w*2)-x,1);
102 					glEnd();
103 				} /* if */
104 			} /* for */
105 		} /* for */
106 
107 		/* Draw the SHIP: */
108 		x=(int)(shipp.x*2-startx);
109 		y=(int)(shipp.y*2-starty);
110 		glColor3f(1.0f,1.0f,1.0f);
111 		glBegin(GL_QUADS);
112 		glVertex3f(30+y,maxx-(x+2),2);
113 		glVertex3f(30+y+2,maxx-(x+2),2);
114 		glVertex3f(30+y+2,maxx-x,2);
115 		glVertex3f(30+y,maxx-x,2);
116 		glEnd();
117 
118 	}
119 
120 
121 } /* NETHER::draw_radar */
122