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