]> git.jsancho.org Git - lugaru.git/blob - Source/Game.h
a378efcd28b3fb249a06d6f4c04769ac97ef4f01
[lugaru.git] / Source / Game.h
1 /*
2 Copyright (C) 2003, 2010 - Wolfire Games
3
4 This file is part of Lugaru.
5
6 Lugaru is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
15 See the GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
20 */
21
22 #ifndef _GAME_H_
23 #define _GAME_H_
24
25 #include "SDL.h"
26
27 #if (defined(__APPLE__) && defined(__MACH__))
28 #  ifdef PLATFORM_MACOSX
29 #    error Do not define PLATFORM_MACOSX for new builds. It is for the old Carbonized build.
30 #  endif
31 #endif
32
33 #ifdef PLATFORM_MACOSX
34 #include <Carbon.h>
35 #include "Quicktime.h"
36 #endif
37
38 //Jordan included glut.h
39 //#include <glut.h>
40
41 #include "TGALoader.h"
42
43 #include "Terrain.h"
44 #include "Skybox.h"
45 #include "Skeleton.h"
46 #include "Models.h"
47 #include "Lights.h"
48 #include "Person.h"
49 #include "Sprite.h"
50 //#include <agl.h>
51 #include "Text.h"
52 #include "Objects.h"
53 //#include <DrawSprocket.h>
54 #include "Weapons.h"
55 #include "binio.h"
56 #include <fstream>
57 #include "gamegl.h"
58 #include "Stereo.h"
59 #include "Account.h"
60 #include "Sounds.h"
61 #include "Texture.h"
62
63 #define NB_CAMPAIGN_MENU_ITEM 7
64
65 namespace Game {
66     extern Texture terraintexture;
67     extern Texture terraintexture2;
68     extern Texture loadscreentexture;
69     extern Texture Maparrowtexture;
70     extern Texture Mapboxtexture;
71     extern Texture Mapcircletexture;
72     extern Texture cursortexture;
73     extern GLuint screentexture;
74     extern GLuint screentexture2;
75     extern Texture Mainmenuitems[10];
76
77     extern int selected;
78     extern int keyselect;
79
80     extern int newdetail;
81     extern int newscreenwidth;
82     extern int newscreenheight;
83
84     extern bool gameon;
85     extern float deltah,deltav;
86     extern int mousecoordh,mousecoordv;
87     extern int oldmousecoordh,oldmousecoordv;
88     extern float yaw,pitch;
89     extern SkyBox *skybox;
90     extern bool cameramode;
91     extern bool firstload;
92
93     extern float leveltime;
94     extern float loadtime;
95
96     extern Model hawk;
97     extern XYZ hawkcoords;
98     extern XYZ realhawkcoords;
99     extern Texture hawktexture;
100     extern float hawkyaw;
101     extern float hawkcalldelay;
102
103     extern Model eye;
104     extern Model iris;
105     extern Model cornea;
106
107     extern bool stealthloading;
108     extern int loading;
109
110     extern int musictype;
111
112     extern XYZ mapcenter;
113     extern float mapradius;
114
115     extern Text *text;
116     extern float fps;
117
118     extern bool editorenabled;
119     extern int editortype;
120     extern float editorsize;
121     extern float editoryaw;
122     extern float editorpitch;
123
124     extern int tryquit;
125
126     extern XYZ pathpoint[30];
127     extern int numpathpoints;
128     extern int numpathpointconnect[30];
129     extern int pathpointconnect[30][30];
130     extern int pathpointselected;
131
132     extern int endgame;
133     extern bool scoreadded;
134     extern int numchallengelevels;
135
136     extern bool console;
137     extern char consoletext[15][256];
138     extern int consolechars[15];
139     extern bool chatting;
140     extern char displaytext[15][256];
141     extern int displaychars[15];
142     extern float displaytime[15];
143     extern float displayblinkdelay;
144     extern bool displayblink;
145     extern int displayselected;
146     extern float consoleblinkdelay;
147     extern bool consoleblink;
148     extern int consoleselected;
149
150     extern int oldenvironment;
151     extern int targetlevel;
152     extern float changedelay;
153
154     extern bool waiting;
155     extern Account* accountactive;
156
157     extern unsigned short crouchkey,jumpkey,forwardkey,chatkey,backkey,leftkey,rightkey,drawkey,throwkey,attackkey;
158     extern unsigned short consolekey;
159
160     void newGame();
161     void deleteGame();
162
163     void InitGame();
164     void LoadStuff();
165     void LoadScreenTexture();
166     void LoadingScreen();
167     int DrawGLScene(StereoSide side);
168     void LoadMenu();
169     void Tick();
170     void TickOnce();
171     void TickOnceAfter();
172     void SetUpLighting();
173     GLvoid ReSizeGLScene(float fov, float near);
174     int checkcollide(XYZ startpoint, XYZ endpoint);
175     int checkcollide(XYZ startpoint, XYZ endpoint, int what);
176     
177     void fireSound(int sound=fireendsound);
178     void setKeySelected();
179
180     void inputText(char* str, int* charselected, int* nb_chars);
181     void flash();
182 }
183
184 #ifndef __forceinline
185 #  ifdef __GNUC__
186 #    define __forceinline inline __attribute__((always_inline))
187 #  endif
188 #endif
189
190 static __forceinline void swap_gl_buffers(void)
191 {
192     SDL_GL_SwapBuffers();
193 }
194
195 extern "C" { void UndefinedSymbolToExposeStubbedCode(void); }
196 //#define STUBBED(x) UndefinedSymbolToExposeStubbedCode();
197 #define STUBBED(x) { static bool seen = false; if (!seen) { seen = true; fprintf(stderr, "STUBBED: %s at %s:%d\n", x, __FILE__, __LINE__); } }
198 //#define STUBBED(x)
199
200 extern int numplayers;
201
202 extern int numdialogues;
203 const int max_dialogues = 20;
204 const int max_dialoguelength = 20;
205 extern int numdialogueboxes[max_dialogues];
206 extern int dialoguetype[max_dialogues];
207 extern int dialogueboxlocation[max_dialogues][max_dialoguelength];
208 extern float dialogueboxcolor[max_dialogues][max_dialoguelength][3];
209 extern int dialogueboxsound[max_dialogues][max_dialoguelength];
210 extern char dialoguetext[max_dialogues][max_dialoguelength][128];
211 extern char dialoguename[max_dialogues][max_dialoguelength][64];
212 extern XYZ dialoguecamera[max_dialogues][max_dialoguelength];
213 extern XYZ participantlocation[max_dialogues][10];
214 extern int participantfocus[max_dialogues][max_dialoguelength];
215 extern int participantaction[max_dialogues][max_dialoguelength];
216 extern float participantyaw[max_dialogues][10];
217 extern XYZ participantfacing[max_dialogues][max_dialoguelength][10];
218 extern float dialoguecamerayaw[max_dialogues][max_dialoguelength];
219 extern float dialoguecamerapitch[max_dialogues][max_dialoguelength];
220 extern int indialogue;
221 extern int whichdialogue;
222 extern int directing;
223 extern float dialoguetime;
224 extern int dialoguegonethrough[20];
225
226 enum maptypes {
227   mapkilleveryone, mapgosomewhere,
228   mapkillsomeone, mapkillmost // These two are unused
229 };
230
231 enum pathtypes {wpkeepwalking, wppause};
232
233 static const char *pathtypenames[] = {"keepwalking", "pause"};
234
235 enum editortypes {typeactive, typesitting, typesittingwall, typesleeping,
236                   typedead1, typedead2, typedead3, typedead4};
237
238 static const char *editortypenames[] = {
239   "active", "sitting", "sitting wall", "sleeping",
240   "dead1", "dead2", "dead3", "dead4"
241 };
242
243 #endif