1 /*
2  * GNUjump
3  * =======
4  *
5  * Copyright (C) 2005-2008, Juan Pedro Bolivar Puente
6  *
7  * GNUjump 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 3 of the License, or
10  * (at your option) any later version.
11  *
12  * GNUjump 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 this program.  If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef _GNUJUMP_H_
22 #define _GNUJUMP_H_
23 
24 /*
25  * HEADERS
26  */
27 
28 #ifdef HAVE_CONFIG_H
29 #include <config.h>
30 #endif
31 
32 #include <math.h>
33 #include <stdio.h>
34 #include <string.h>
35 #include <stdlib.h>
36 #include <stdlib.h>
37 #include <unistd.h>
38 #include <time.h>
39 
40 #include <SDL/SDL.h>
41 #include <SDL/SDL_image.h>
42 #include <SDL/SDL_mixer.h>
43 #include <SDL/SDL_opengl.h>
44 
45 #include "gettext.h"
46 #define _(str) gettext(str)
47 
48 #include "surface.h"
49 #include "sprite.h"
50 #include "SFont.h"
51 
52 /*
53  DEFINITIONS
54 */
55 
56 /* Me */
57 #define AUTHOR "Juan Pedro Bolivar Puente"
58 
59 /* Config, theme and language files format version */
60 #define PROT_VERS "03"
61 #define THEME_VERS "03"
62 #define SOUND_VERS "01"
63 #define LANG_VERS  "01"
64 #define REP_VERS 3
65 
66 #ifndef HAVE_CONFIG_H
67 #define VERSION "1.0.5"
68 #endif
69 
70 /* Some code switchs */
71 //#define DEVEL
72 #define GLFINISH
73 
74 /* Files */
75 #define THEMEFILE "/config.theme"
76 #define SOUNDFILE "/config.sounds"
77 #define DEFTHEME "default"
78 #define CFGFILE "gnujump.cfg"
79 #define HSCFILE "gnujump.hsc"
80 #define REPEXTOLD ".rep"
81 #define REPEXT ".gjr"
82 #define CONFDIR ".gnujump"
83 
84 #ifdef WIN32
85 #define DEFSOUND "sound"
86 #else
87 #ifdef DEVEL
88 #define DEFSOUND "sound"
89 #else
90 #define DEFSOUND DATA_PREFIX"/"PACKAGE"/sound"
91 #endif
92 #endif
93 
94 #define MAX_CHAR 512
95 
96 #define TRUE 1
97 #define FALSE 0
98 #define ON 1
99 #define OFF 0
100 
101 /* Hero rotation modes */
102 enum
103 {
104   ROTNONE,
105   ROTORIG,
106   ROTFULL
107 };
108 
109 /* Scrolling modes */
110 enum
111 {
112   HARDSCROLL,
113   SOFTSCROLL
114 };
115 
116 enum
117 {
118   FPS40,
119   FPS100,
120   FPS300,
121   FPSNOLIMIT
122 };
123 
124 enum
125 {
126   BPP32,
127   BPP16,
128   BPP8,
129   BPPAUTO
130 };
131 
132 enum
133 {
134   NOTRAIL,
135   THINTRAIL,
136   NORMALTRAIL,
137   STRONGTRAIL
138 };
139 
140 #define MAXBLUR 9
141 
142 /* Player states*/
143 enum
144 {
145   H_STAND, H_WALK, H_JUMP, HEROANIMS
146 };
147 
148 /* Mouse states*/
149 enum
150 {
151   M_IDLE, M_OVER, M_DOWN, M_STATES
152 };
153 
154 
155 /* Maximun number of players */
156 #define MAX_PLAYERS 4
157 
158 /* The number of records */
159 #define MAX_RECORDS 10
160 
161 /* Be careful, these values are not arbitrary */
162 #define RIGHT 1
163 #define LEFT  0
164 
165 /* Delay and rate in original mode*/
166 #define DELAY   25
167 #define FPSRATE 40
168 
169 
170 /* Keys ids */
171 enum
172 {
173   LEFTK,
174   RIGHTK,
175   JUMPK,
176   KEYS
177 };
178 
179 /* Default keys */
180 #define KEY_QUIT SDLK_ESCAPE
181 
182 #define KEY_LEFT1 SDLK_LEFT
183 #define KEY_LEFT2 SDLK_a
184 #define KEY_LEFT3 SDLK_j
185 #define KEY_LEFT4 SDLK_KP4
186 
187 #define KEY_RIGHT1 SDLK_RIGHT
188 #define KEY_RIGHT2 SDLK_d
189 #define KEY_RIGHT3 SDLK_l
190 #define KEY_RIGHT4 SDLK_KP6
191 
192 #define KEY_UP1 SDLK_UP
193 #define KEY_UP2 SDLK_w
194 #define KEY_UP3 SDLK_i
195 #define KEY_UP4 SDLK_KP8
196 
197 /* Default player name */
198 #define PNAME "Player"
199 
200 #define MIN(a,b) ((a) < (b) ? (a) : (b))
201 
202 /*
203   TYPES
204 */
205 
206 /*
207  * A record entry
208  */
209 typedef struct
210 {
211   char *pname;
212   int floor;
213   char *mode;
214   int time;
215   char date[64];
216 } records_t;
217 
218 /*
219  * Global Options
220  */
221 typedef struct
222 {
223   int useGL;
224   GLint texFilter;		/* use GL_NEAREST or GL_LINEAR */
225   int aa;
226   int w;
227   int h;
228   int bpp;
229   int fullsc;
230   int sndvolume;
231   int musvolume;
232 
233   int fps;
234   int rotMode;
235   int scrollMode;
236   int scrollBg;
237   int trailMode;
238   int blur;
239   int mpLives;
240   int nplayers;
241   int recReplay;
242   int repFps;
243 
244   /* Players */
245   SDLKey keys[MAX_PLAYERS][KEYS];
246   char *pname[MAX_PLAYERS];
247 
248   /* Data files */
249   char *dataDir;
250   char **themeDirs;
251   char *repDir;
252   char **repDirs;
253   int nrfolders;
254   int ntfolders;
255 
256   /* The records tab, organized from best to worst */
257   records_t records[MAX_RECORDS];
258 } L_gblOptions;
259 
260 /*
261  * The theme data structure
262  */
263 typedef struct
264 {
265   /* Sound */
266   Mix_Chunk *gjump;
267   Mix_Chunk *gfall;
268   Mix_Chunk *gdie;
269   Mix_Chunk *grecord;
270   Mix_Chunk *gquestion;
271   Mix_Chunk *mclick;
272   Mix_Chunk *mback;
273   Mix_Music *musmenu;
274   Mix_Music *musgame;
275   int soundloaded;
276 
277   /* Mouse */
278   L_spriteData *mouse[M_STATES];
279   int mouseX;
280   int mouseY;
281 
282   /* Menu */
283   JPB_surface *menuBg;
284   JPB_surface *upArrow;
285   JPB_surface *dwArrow;
286   int mUpArrowX;
287   int mDwArrowX;
288   int mUpArrowY;
289   int mDwArrowY;
290   int menuX;
291   int menuY;
292   int menuW;
293   int menuH;
294   int mMaxOps;
295   int mMargin;
296   int tipX;
297   int tipY;
298   int tipW;
299   int tipH;
300   int mAlign;
301   int tAlign;
302   SFont_Font *menufont;
303   SFont_Font *tipfont;
304   Uint32 hlcolor;
305   Uint8 hlalpha;
306 
307   /* Players */
308   L_spriteDataRot *heroSprite[MAX_PLAYERS][HEROANIMS];
309   Uint8 tcolorr[MAX_PLAYERS];
310   Uint8 tcolorg[MAX_PLAYERS];
311   Uint8 tcolorb[MAX_PLAYERS];
312 
313   /* In game screen */
314   JPB_surface *gameBg;
315   JPB_surface *livePic;
316   int liveAlign;
317   int gameX;
318   int gameY;
319   int gameTileH;
320   int borderTileH;
321   int borderTileW;
322   int scoreX[MAX_PLAYERS];
323   int scoreY[MAX_PLAYERS];
324   int livesX[MAX_PLAYERS];
325   int livesY[MAX_PLAYERS];
326   int timeX;
327   int timeY;
328   SFont_Font *scorefont;
329   SFont_Font *textfont;
330   SFont_Font *timefont;
331   Uint32 gcolor;
332   Uint8 galpha;
333 
334   JPB_surface *floorL;
335   JPB_surface *floorR;
336   JPB_surface *floorC;
337 
338   /* Credits */
339   char *gfxauth;
340   char *sndauth;
341   char *langauth;
342 } data_t;
343 
344 
345 #endif //_GNUJUMP_H_
346