]> git.jsancho.org Git - lugaru.git/blob - Source/Game.h
More work: compiles, missing like 5 symbols.
[lugaru.git] / Source / Game.h
1 #ifndef _GAME_H_
2 #define _GAME_H_
3
4 #ifdef PLATFORM_MACOSX
5 #include <Carbon.h>
6 #include "Quicktime.h"
7 #endif
8
9 //Jordan included glut.h
10 //#include <glut.h>
11
12 #include "TGALoader.h"
13 #ifdef WIN32
14 #include "WinInput.h"
15 #elif USE_SDL
16 #include "SDL.h"
17 #include "SDLInput.h"
18 #else
19 #include "Macinput.h"
20 #endif
21 #include "Terrain.h"
22 #include "Skybox.h"
23 #include "Skeleton.h"
24 #include "Models.h"   
25 #include "Lights.h"
26 #include "Person.h"
27 #include "Constants.h"
28 #include "fmod.h"
29 #include "Sprites.h"
30 //#include <agl.h>
31 #include "Text.h"
32 #include "Objects.h"
33 //#include <DrawSprocket.h>
34 #include "Weapons.h"
35 #include "binio.h"
36 #include <fstream>
37 #include "gamegl.h"
38
39 extern GLuint rabbittexture;
40
41 class Game              
42 {
43 public:
44
45         typedef std::map<std::string, GLuint> TextureList;
46         typedef std::map<GLuint, std::string> GLTextureList;
47         typedef TextureList::iterator TexIter;
48         static TextureList textures;
49
50         GLuint terraintexture;
51         GLuint terraintexture2;
52         GLuint terraintexture3;
53         GLuint screentexture;
54         GLuint screentexture2;
55         GLuint logotexture;
56         GLuint loadscreentexture;
57         GLuint Maparrowtexture;
58         GLuint Mapboxtexture;
59         GLuint Mapcircletexture;
60         GLuint cursortexture;
61         GLuint Mainmenuitems[10];
62
63         int nummenuitems;
64         int startx[100];
65         int starty[100];
66         int endx[100];
67         int endy[100];
68         float selectedlong[100];
69         float offsetx[100];
70         float offsety[100];
71         float movex[100];
72         float movey[100];
73         float transition;
74         int anim;
75         int selected;
76         int loaddistrib;
77         int keyselect;
78         int indemo;
79         int registered;
80
81         bool won;
82
83         bool entername;
84
85         char menustring[100][256];
86         char registrationname[256];
87         float registrationnumber;
88
89         int newdetail;
90         int newscreenwidth;
91         int newscreenheight;
92
93         bool gameon;
94         float deltah,deltav;
95         int mousecoordh,mousecoordv;
96         int oldmousecoordh,oldmousecoordv;
97         float rotation,rotation2;
98         SkyBox skybox;
99         bool cameramode;
100         bool cameratogglekeydown;
101         bool chattogglekeydown;
102         int olddrawmode;
103         int drawmode;
104         bool drawmodetogglekeydown;
105         bool explodetogglekeydown;
106         bool detailtogglekeydown;
107         bool firstload;
108         bool oldbutton;
109
110         float leveltime;
111         float loadtime;
112
113         Model hawk;
114         XYZ hawkcoords;
115         XYZ realhawkcoords;
116         GLuint hawktexture;
117         float hawkrotation;
118         float hawkcalldelay;
119
120         Model eye;
121         Model iris;
122         Model cornea;
123
124         bool stealthloading;
125
126         int campaignnumlevels;
127         char campaignmapname[50][256];
128         char campaigndescription[50][256];
129         int campaignchoosenext[50];
130         int campaignnumnext[50];
131         int campaignnextlevel[50][10];
132         int campaignchoicesmade;
133         int campaignchoices[5000];
134         int campaignlocationx[50];
135         int campaignlocationy[50];
136         int campaignchoicenum;
137         int campaignchoicewhich[10];
138         int whichchoice;
139
140         int numlevelspassed;
141         int levelorder[5000];
142         int levelvisible[50];
143         int levelhighlight[50];
144
145         bool minimap;
146
147         int musictype,oldmusictype,oldoldmusictype;
148         bool realthreat;
149
150         Model rabbit;
151         XYZ rabbitcoords;
152
153         XYZ mapcenter;
154         float mapradius;
155
156         Text text;
157         float fps;
158
159         XYZ cameraloc;
160         float cameradist;
161
162         bool envtogglekeydown;
163         bool slomotogglekeydown;
164         bool texturesizetogglekeydown;
165         bool freezetogglekeydown;
166         int drawtoggle;
167
168         bool editorenabled;
169         int editortype;
170         float editorsize;
171         float editorrotation;
172         float editorrotation2;
173
174         float brightness;
175
176         int quit;
177         int tryquit;
178
179         XYZ pathpoint[30];
180         int numpathpoints;
181         int numpathpointconnect[30];
182         int pathpointconnect[30][30];
183         int pathpointselected;
184
185         int endgame;
186         bool scoreadded;
187         int numchallengelevels;
188
189         bool console;
190         int archiveselected;
191         char consoletext[15][256];
192         int consolechars[15];
193         bool chatting;
194         char displaytext[15][256];
195         int displaychars[15];
196         float displaytime[15];
197         float displayblinkdelay;
198         bool displayblink;
199         int displayselected;
200         bool consolekeydown;
201         bool consoletogglekeydown;
202         float consoleblinkdelay;
203         bool consoleblink;
204         int consoleselected;
205         int togglekey[140];
206         float togglekeydelay[140];
207         bool registernow;
208         bool autocam;
209
210         unsigned short crouchkey,jumpkey,forwardkey,chatkey,backkey,leftkey,rightkey,drawkey,throwkey,attackkey;
211         bool oldattackkey;
212
213         long long MD5_string (char *string);
214         static void LoadTexture(char *fileName, GLuint *textureid,int mipmap, bool hasalpha);
215         static void LoadTextureSave(char *fileName, GLuint *textureid,int mipmap,GLubyte *array, int *skinsize);
216         void LoadSave(char *fileName, GLuint *textureid,bool mipmap,GLubyte *array, int *skinsize);
217         bool AddClothes(char *fileName, GLuint *textureid,bool mipmap,GLubyte *array, int *skinsize);
218         void InitGame();
219         void LoadStuff();
220         void LoadingScreen();
221         void FadeLoadingScreen(float howmuch);
222         void Dispose();
223         int DrawGLScene(GLvoid);
224         void Tick();
225         void TickOnce();
226         void TickOnceAfter();
227         void SetUpLighting();
228         void Loadlevel(int which);
229         void Loadlevel(char *name);
230         void LoadSounds();
231         void Setenvironment(int which);
232         GLvoid ReSizeGLScene(float fov, float near);
233         int findPathDist(int start,int end);
234         int checkcollide(XYZ startpoint, XYZ endpoint);
235         int checkcollide(XYZ startpoint, XYZ endpoint, int what);
236         int loading;
237         float talkdelay;
238
239         int numboundaries;
240         XYZ boundary[360];
241
242         int whichlevel;
243         int oldenvironment;
244         int targetlevel;
245         float changedelay;
246
247         float musicvolume[4];
248         float oldmusicvolume[4];
249         int musicselected;
250         int change;
251         Game();
252         ~Game() {               
253                 for(int i=0;i<10;i++){
254                         if(Mainmenuitems[i])glDeleteTextures( 1, &Mainmenuitems[i] );
255                 }
256                 glDeleteTextures( 1, &cursortexture );
257                 glDeleteTextures( 1, &Maparrowtexture );
258                 glDeleteTextures( 1, &Mapboxtexture );
259                 glDeleteTextures( 1, &Mapcircletexture );
260                 glDeleteTextures( 1, &terraintexture );
261                 glDeleteTextures( 1, &terraintexture2 );
262                 if(screentexture>0)glDeleteTextures( 1, &screentexture );
263                 if(screentexture2>0)glDeleteTextures( 1, &screentexture2 );
264                 glDeleteTextures( 1, &hawktexture );
265                 glDeleteTextures( 1, &logotexture );
266                 glDeleteTextures( 1, &loadscreentexture );
267
268                 Dispose();
269         }
270
271 };
272
273 #ifndef __forceinline
274 #  ifdef __GNUC__
275 #    define __forceinline inline __attribute__((always_inline))
276 #  endif
277 #endif
278
279 static __forceinline void swap_gl_buffers(void)
280 {
281 #ifdef WIN32
282     extern HDC hDC;
283     SwapBuffers( hDC);
284 #elif USE_SDL
285     SDL_GL_SwapBuffers();
286 #elif PLATFORM_MACOSX
287     extern AGLContext gaglContext;
288     aglSwapBuffers(gaglContext);
289 #else
290     #error define your platform.
291 #endif
292 }
293
294 #ifdef __GNUC__
295 #define LONGLONGCONST(x) (x##ll)
296 #else
297 #define LONGLONGCONST(x) (x)
298 #endif
299
300 #endif