]> git.jsancho.org Git - lugaru.git/blob - Source/Game.h
Moved image loading/saving in TGALoader and renamed it accordingly
[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 #include "ImageIO.h"
26
27 #include "Terrain.h"
28 #include "Skybox.h"
29 #include "Skeleton.h"
30 #include "Models.h"
31 #include "Lights.h"
32 #include "Person.h"
33 #include "Sprite.h"
34 #include "Text.h"
35 #include "Objects.h"
36 #include "Weapons.h"
37 #include "binio.h"
38 #include <fstream>
39 #include "gamegl.h"
40 #include "Stereo.h"
41 #include "Account.h"
42 #include "Sounds.h"
43 #include "Texture.h"
44
45 #define NB_CAMPAIGN_MENU_ITEM 7
46
47 namespace Game
48 {
49 extern Texture terraintexture;
50 extern Texture terraintexture2;
51 extern Texture loadscreentexture;
52 extern Texture Maparrowtexture;
53 extern Texture Mapboxtexture;
54 extern Texture Mapcircletexture;
55 extern Texture cursortexture;
56 extern GLuint screentexture;
57 extern GLuint screentexture2;
58 extern Texture Mainmenuitems[10];
59
60 extern int selected;
61 extern int keyselect;
62
63 extern int newdetail;
64 extern int newscreenwidth;
65 extern int newscreenheight;
66
67 extern bool gameon;
68 extern float deltah, deltav;
69 extern int mousecoordh, mousecoordv;
70 extern int oldmousecoordh, oldmousecoordv;
71 extern float yaw, pitch;
72 extern SkyBox *skybox;
73 extern bool cameramode;
74 extern bool firstload;
75
76 extern float leveltime;
77 extern float loadtime;
78
79 extern Model hawk;
80 extern XYZ hawkcoords;
81 extern XYZ realhawkcoords;
82 extern Texture hawktexture;
83 extern float hawkyaw;
84 extern float hawkcalldelay;
85
86 extern Model eye;
87 extern Model iris;
88 extern Model cornea;
89
90 extern bool stealthloading;
91 extern int loading;
92
93 extern int musictype;
94
95 extern XYZ mapcenter;
96 extern float mapradius;
97
98 extern Text *text;
99 extern float fps;
100
101 extern bool editorenabled;
102 extern int editortype;
103 extern float editorsize;
104 extern float editoryaw;
105 extern float editorpitch;
106
107 extern int tryquit;
108
109 extern XYZ pathpoint[30];
110 extern int numpathpoints;
111 extern int numpathpointconnect[30];
112 extern int pathpointconnect[30][30];
113 extern int pathpointselected;
114
115 extern int endgame;
116 extern bool scoreadded;
117 extern int numchallengelevels;
118
119 extern bool console;
120 extern std::string consoletext[15];
121 extern std::string displaytext[15];
122 extern float displaytime[15];
123 extern float displayblinkdelay;
124 extern bool displayblink;
125 extern unsigned displayselected;
126 extern float consoleblinkdelay;
127 extern bool consoleblink;
128 extern unsigned consoleselected;
129
130 extern int oldenvironment;
131 extern int targetlevel;
132 extern float changedelay;
133
134 extern bool waiting;
135 extern Account* accountactive;
136
137 extern unsigned short crouchkey, jumpkey, forwardkey, backkey, leftkey, rightkey, drawkey, throwkey, attackkey;
138 extern unsigned short consolekey;
139
140 void newGame();
141 void deleteGame();
142
143 void InitGame();
144 void LoadStuff();
145 void LoadScreenTexture();
146 void LoadingScreen();
147 int DrawGLScene(StereoSide side);
148 void LoadMenu();
149 void playdialogueboxsound();
150 int findClosestPlayer();
151 bool AddClothes(const char *fileName, GLubyte *array);
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 extern float tintr, tintg, tintb;
219
220 enum maptypes {
221     mapkilleveryone, mapgosomewhere,
222     mapkillsomeone, mapkillmost // These two are unused
223 };
224
225 enum pathtypes {wpkeepwalking, wppause};
226
227 extern const char *pathtypenames[2];
228
229 enum editortypes {typeactive, typesitting, typesittingwall, typesleeping,
230                   typedead1, typedead2, typedead3, typedead4
231                  };
232
233 extern const char *editortypenames[8];
234
235 extern const char *rabbitskin[10];
236
237 extern const char *wolfskin[3];
238
239 extern const char **creatureskin[2];
240
241 #endif