1 /**************************************************************************
2                           global.h  -  description
3                              -------------------
4     begin                : Mon Jan 3 2000
5     copyright            : (C) 2000 by Perdig
6     email                : perdig@linuxbr.com.br
7 
8     $Id: global.h,v 1.10 2001/01/11 15:28:03 perdig Exp $
9  ***************************************************************************/
10 
11 /***************************************************************************
12  *                                                                         *
13  *   This program is free software; you can redistribute it and/or modify  *
14  *   it under the terms of the GNU General Public License as published by  *
15  *   the Free Software Foundation; either version 2 of the License, or     *
16  *   (at your option) any later version.                                   *
17  *                                                                         *
18  ***************************************************************************/
19 
20 #ifndef GLOBAL_H
21 #define GLOBAL_H
22 
23 #include <X11/Xlib.h>
24 #include "stdio.h"
25 #include "config.h"
26 
27 typedef int bool;
28 #define true 1
29 #define false 0
30 
31 // Frames per second
32 #define FPS 20
33 
34 
35 typedef struct {
36 	Pixmap pix;
37 	Pixmap mask;
38 } Image;
39 
40 typedef struct {
41 	int x;
42 	int y;
43 	int direction;
44 	int toGoDir;
45 	Image *img[4];
46 	int fuel;
47 	int vel;
48 	int aiguess;
49 	int ai;
50 } carStruct;
51 
52 typedef struct {
53 	Pixmap pix;
54 	char *data;
55 	int width;
56 	int height;
57 	int offX;
58 	int offY;
59 	int tX;
60 	int tY;
61 	int startX;
62 	int startY;
63 	int *red_startX;
64 	int *red_startY;
65 	int redNum;
66 	int flagNum;
67 	int flagLeft;
68 	int *flagX;
69 	int *flagY;
70 	char startDir;
71 	int carVel;
72 	int aiVel;
73 	int startFuel;
74 	int fuelImpact;
75 	int fuelpts;
76 	bool bonus;
77 	int radarmode;
78 	int radarrange;
79 	int enemywait;
80 } mapStruct;
81 
82 typedef struct {
83 	char name[256];
84 	char sum[256];
85 	char tileset[256];
86 	mapStruct *map;
87 	int number;
88 	int pics;
89 	int lives;
90 	int extra;
91 	int livesbonus;
92 	int border;
93 	FILE *file;
94 	int volume;
95 } levelStruct;
96 
97 typedef struct {
98 	Pixmap pix;
99 	GC gc;
100 	int width;
101 	int height;
102 	float factor;
103 } radarStruct;
104 
105 typedef struct {
106 	carStruct *bot;
107 	int number;
108 	int *order;
109 	int *data;
110 } aiStruct;
111 
112 #define FLAG_VALUE 100
113 #define SCORE_DIGITS 8
114 #define SCORE_TIMER 10
115 #define COLOR_SCORE "#FFFFFF"
116 
117 typedef struct {
118 	char string[SCORE_DIGITS];
119 	unsigned int value;
120 	unsigned int bonus;
121 	unsigned int last;
122 	int x;
123 	int y;
124 	int num_extra;
125 	int current_extra;
126 	unsigned char timer;
127 } scoreStruct;
128 
129 
130 
131 #define SMOKE_NUM 10
132 // Smoke duration, in seconds
133 #define SMOKE_DURATION 4 * FPS
134 // Fuel spent (in frames)
135 #define SMOKE_FUEL FPS * 1
136 
137 typedef struct {
138 	int x[SMOKE_NUM];
139 	int y[SMOKE_NUM];
140 	int left[SMOKE_NUM];
141 	int current;
142 } smoke_struct;
143 
144 // Define Directions
145 #define UP 0
146 #define RIGHT 1
147 #define DOWN 2
148 #define LEFT 3
149 
150 // Define velocity
151 #define STEP 9
152 #define STEP2 10
153 
154 
155 // Lives
156 #define NUM_LIVES 5
157 #define EXTRA_LIVE 5000
158 
159 // Define fonts
160 #define FONT_SMALL 0
161 #define FONT_MEDIUM 1
162 #define FONT_BIG 2
163 #define FONT_FIXED 3
164 
165 // Define colors
166 #define COLOR_BLACK "rgb:00/00/00"
167 #define COLOR_YELLOW "rgb:FF/FF/00"
168 #define COLOR_WHITE "rgb:FF/FF/FF"
169 #define COLOR_BLUE "rgb:00/00/FF"
170 #define COLOR_RED "rgb:FF/00/00"
171 #define COLOR_GREEN "rgb:77/FF/87"
172 
173 
174 // DEBUG MACRO
175 // ldbg: Level debug (not very important) (4)
176 // dbg: Normal debug (important)          (2)
177 // hdbg: Error debug (very important)     (1)
178 #define DEBUG 3
179 
180 #if DEBUG > 0
181 #define _D_INFO "\x1b[33m"
182 #define _D_CRIT "\x1b[31m"
183 #define _D_WARN "\x1b[36m"
184 #define _D(args...) { \
185         printf("\x1b[33m%s \x1b[37m[%s:%d]%s", \
186 	__PRETTY_FUNCTION__, __FILE__, __LINE__, _D_INFO); \
187 	printf(args); \
188 	printf("\x1b[0m\n"); \
189         }
190 
191 #define ldbg(STR...) { if (DEBUG&4) _D(_D_INFO STR); }
192 #define dbg(STR...)  { if (DEBUG&2) _D(_D_WARN STR); }
193 #define hdbg(STR...) { if (DEBUG)   _D(_D_CRIT STR); }
194 #endif
195 
196 
197 // Sound
198 #ifdef USE_SOUND
199 #define SOUND_ALARM	0x0f
200 #define SOUND_BONUS	0x10
201 #define SOUND_CHKFUEL	0x0a
202 #define SOUND_LIGHT	0x1b
203 #define SOUND_SMOKE	0x1c
204 #define SOUND_GETFLAG	0x1d
205 #define SOUND_CRASH	0x1e
206 
207 void play_sound (int);
208 #endif
209 
210 // Results
211 #define RESULT_WIN 0
212 #define RESULT_LOSE 1
213 #define RESULT_QUIT 2
214 
215 
216 #define PLAYABLE
217 
218 #ifndef USE_SOUND
219 #define sound_switch()
220 #define sound_stop()
221 #define sound_volume(a)
222 #define sound_start()
223 #define sound_select(a)
224 #define sound_load(a)
225 #endif
226 
227 #endif
228