4
#include <SDL/SDL_endian.h>
6
#include <SDL/SDL_ttf.h>
8
#define SPEED 4 // the less the fast...
9
#define FIELD_SIZE 32 // size of one field
10
#define ROBBO_LIVES_START 5 // how many lifes Robbo should have at start
11
#define ROBBO_LEVEL_START 1 // begining level for Robbo
12
#define TICK_INTERVAL 10 // Delay for SDL library
13
#define DELAY_BIRD 4 * SPEED // Delays for objects
14
#define DELAY_BOOM 1 * SPEED
15
#define DELAY_BEAR 4 * SPEED
16
#define DELAY_BUTTERFLY 4 * SPEED
17
#define DELAY_BIGBOOM 3 * SPEED
18
#define DELAY_ROBBO 4 * SPEED
19
#define DELAY_TELEPORT 15 * SPEED
20
#define DELAY_LASER 4 * SPEED
21
#define DELAY_CAPSULE 10 * SPEED
22
#define DELAY_GUN 8 * SPEED
23
#define DELAY_ROTATION 20 * SPEED
24
#define DELAY_BLASTER 4 * SPEED
25
#define DELAY_PUSHBOX 4 * SPEED
26
#define DELAY_BARRIER 4 * SPEED
27
#define SCROLL_RATE 32 // Scrolling rate
42
#define QUESTIONMARK 10
47
#define LITTLE_BOOM 21
63
/* game limitations */
64
#define MAX_X 200 // max x size of the board
65
#define MAX_Y 200 // max y size of the board
66
#define MAX_TELEPORT_IDS 10 // max number of teleports of one kind at level
67
#define DELAY_BLINKSCREEN 2 // how long screen should blink after exit opening
70
/* paths to additional files */
71
#ifdef PACKAGE_DATA_DIR
72
#define BMP_ICONS (PACKAGE_DATA_DIR "pixmaps/icons.bmp")
73
#define BMP_CIPHERS (PACKAGE_DATA_DIR "pixmaps/ciphers.bmp")
74
#define BMP_BACKGROUND (PACKAGE_DATA_DIR "pixmaps/background.bmp")
75
#define ROBBO_FONT (PACKAGE_DATA_DIR "robbo.ttf")
76
#define ROBBO_LEVELS (PACKAGE_DATA_DIR "levels.dat")
78
#define BMP_ICONS "pixmaps/icons.bmp"
79
#define BMP_CIPHERS "pixmaps/ciphers.bmp"
80
#define ROBBO_FONT "robbo.ttf"
81
#define ROBBO_LEVELS "levels.dat"
85
#define RESOURCE_FILE "/.gnurobborc"
88
char path_resource_file[100];
90
static Uint32 next_time;
91
Uint32 rmask, gmask, bmask,amask; /* variables for creating surfaces */
92
int KeyPressed; /* Structure with information about pressed keys */
93
/* Bits: RDLUS R - rigth ... etc... S - shift */
99
SDL_Surface* robbo_img[8];
100
SDL_Surface* score_img[10];
101
SDL_Surface* score_screw;
102
SDL_Surface* score_key;
103
SDL_Surface* score_bullet;
104
SDL_Surface* score_level;
105
SDL_Surface* score_robbo;
107
SDL_Surface* ciphers;
109
SDL_Surface* image_startscreen;
113
static char* Text[] = {"Robbo has been lost on unfriendly planet. Help him to get out ",
114
"of there, but remember, you have only limited number of lives...",
115
"This job is not so easy, there're many levels, killing animals, ",
116
"shooting guns and other kind things...",
117
" Game page: http://gnurobbo.sourceforge.net",
123
" SHIFT+ARROW Shooting",
131
static char* MenuText[] = { "Start game",
136
static char* EndScreen[] = {"Congtatulations you have completed all levels.",
137
"Robbo can safely go home now....",
139
"Press RETURN to start from the begining."};
150
int offset_description;
155
int direction; /* 0r 1d 2l 3u */
156
int destroyable; /* can be destroyed */
157
int blowable; /* can be blowed up */
158
int killing; /* is object dangerous for robbo */
159
int moved; /* When last object was moved (all movable) */
160
int blowed; /* Should object be blowed up? */
161
int shooted; /* When lately object shooted (guns) */
162
int rotated; /* When object lately was rotated (guns) */
163
int solidlaser; /* Does gun shoots solid or normal laser */
164
int rotable; /* If object can be rotated ? (guns) */
165
int randomrotated; /* When object has undetermining rotation */
166
int teleportnumber; /* Number of teleport (kind of theleport) */
167
int teleportnumber2; /* ID of teleport (for teleports with the same number */
168
int id_questionmark; /* What object is covered under questionmark */
169
int direction2; /* direction of moveing (for guns) (if direction2 for birds != (direction+-1) bird shoots */
170
int movable; /* Is object moving (only for guns all animals do) */
171
int returnlaser; /* only for solid lasers... */
172
int shooting; /* if birds can shoot */
173
struct Coords icon[5]; /* Coords of left-up point of icons drawed on bitmap */
177
struct object board[MAX_X][MAX_Y];
178
struct object board_copy[MAX_X][MAX_Y]; // the copy of board - it protects from reading
179
int board_changed[MAX_X][MAX_Y]; // 1 if board needs update, 0 another case
180
// data each time we need the same level
181
int old_level; // what was last level?
182
int score_was_changed; // score was changed ...
183
int typing_code; // typing the code
184
char TextBuffer[100]; // text buffer
185
char TypeBuffer[CODE_LENGTH+1];
186
char TextRGBColor[7]; // Buffer for hex RGB representation
190
int x; // actual x position
191
int y; // actual y position
192
int init_x; // init x position
193
int init_y; // init y position
194
int alive; // if Robbo is alive
195
int state; // Robbo's state (0 or 1 for exchange 2 icons for each direction)
196
int direction; // Robbo's direction 0,2,4,6 + state => icon
197
int score; // Robbo's score
198
int screws; // Screws to collect
199
int lives; // Lives remaining
206
int stepdirection; // 0 - direction of stepping
209
int blocked; /* robbo cannot move - possible magnet moving */
210
int blocked_direction; /* where robbo should be moved after blocking */
218
int init_screws; // initial number of screws to collect
219
char code[CODE_LENGTH+1];
223
int now_is_scrolling_h; // horizontal scrolling
224
int now_is_scrolling_v; // vertical scrolling
225
Uint32 color; // color of the level
228
unsigned int next_rand; // seed for random function
230
/******************************************/
231
/*********** All game functions ***********/
232
/******************************************/
234
void init_robbo(void);
235
SDL_Rect set_rect(int x, int y, int w, int h);
236
Uint32 getpixel(SDL_Surface *surface, int x, int y);
237
void load_bitmaps(void);
238
void draw_score(void);
239
void show_gamearea();
240
void move_robbo(int x,int y);
241
void shoot_robbo(int x,int y);
243
int update_coords(struct Coords *coords, int direction);
244
void prepare_objects();
245
void set_images(int type,int x, int y);
247
int read_from_file(int level_number);
248
void create_object(int x,int y,int type);
249
void clear_field(struct object *obj);
250
int transform_char(char c);
251
int level_init(int level, int force_fileread);
252
void set_coords(struct Coords *coords,int x, int y);
253
void set_mapoffset();
254
int can_move(struct Coords coords, int direction);
255
int next_laserfield(struct Coords coords, int direction);
256
void move_object(int x, int y, struct Coords coords);
257
void shoot_object(int x, int y, int direction);
258
void blow_bomb(int x, int y);
259
int coords_out_of_range(struct Coords coords);
260
void show_startscreen();
261
void show_endscreen();
263
void refresh_field(int x, int y);
266
int my_srand(unsigned int seed);
267
void init_questionmarks();
268
void read_resource_file();
269
void save_resurce_file();
270
int test_resource_file();