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