1 /* GNU Robbo 2 * Copyright (C) 2002-2010 The GNU Robbo Team (see AUTHORS). 3 * 4 * GNU Robbo is free software - you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2, or (at your option) 7 * any later version. 8 * 9 * GNU Robbo is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the impled warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with GNU CC; see the file COPYING. If not, write to the 16 * Free Software Foundation, 59 Temple Place - Suite 330, 17 * Boston, MA 02111-1307, USA. 18 * 19 */ 20 21 /* Defines */ 22 #define MAX_W 32 /* max width of the board */ 23 #define MAX_H 31 /* max height of the board */ 24 #define MAX_ICONS 32 25 #define MAX_EFFECTS 32 26 27 #define DEFAULT_VIEWPORT_WIDTH 16 28 #define DEFAULT_VIEWPORT_HEIGHT 12 29 30 /* Object delays */ 31 //#undef _SMOOTH_SCRL_ 32 #ifdef _SMOOTH_SCRL_ 33 #define DELAY_RADIOACTIVE_FIELD (3*SCRL_MULT1) 34 #define DELAY_BIRD (4*SCRL_MULT1) 35 #define DELAY_LITTLE_BOOM (2*SCRL_MULT1) /* Thunor: I changed this from 1, as it's more like half a BIG_BOOM */ 36 #define DELAY_BEAR (4*SCRL_MULT1) 37 #define DELAY_BUTTERFLY (4*SCRL_MULT1) 38 #define DELAY_BIGBOOM (3*SCRL_MULT1) 39 #define DELAY_ROBBO (4*SCRL_MULT1) 40 #define DELAY_TELEPORT (8*SCRL_MULT1) /* Thunor: was 15, 8 is similar to Robbo */ 41 #define DELAY_LASER (4*SCRL_MULT1) 42 #define DELAY_CAPSULE (10*SCRL_MULT1) 43 #define DELAY_GUN (8*SCRL_MULT1) 44 #define DELAY_ROTATION (20*SCRL_MULT1) 45 #define DELAY_BLASTER (4*SCRL_MULT1) 46 #define DELAY_PUSHBOX (4*SCRL_MULT1) 47 #define DELAY_BARRIER (4*SCRL_MULT1) 48 #define DELAY_TELEPORTING (3*SCRL_MULT1) 49 #define DELAY_BOMB_TARGET (DELAY_BIGBOOM + 2) /* Was DELAY_BIGBOOM * 2 (6) but 5 is spot on: use RobboIX-003 and Original-020 to test */ 50 #define DELAY_ROBBO_ANIMATE (DELAY_ROBBO / 2) 51 #define DELAY_MAGNET_ATTRACT DELAY_ROBBO /* Was DELAY_ROBBO * 2 but it's the same as Robbo moving: use Original-011 to test */ 52 #define DELAY_BLINKSCREEN (6*SCRL_MULT1) /* how long screen should blink after exit opening */ 53 #define DELAY_RESTART (DELAY_BIGBOOM * 8) 54 #else 55 #define DELAY_RADIOACTIVE_FIELD 3 56 #define DELAY_BIRD 4 57 #define DELAY_LITTLE_BOOM 2 /* Thunor: I changed this from 1, as it's more like half a BIG_BOOM */ 58 #define DELAY_BEAR 4 59 #define DELAY_BUTTERFLY 4 60 #define DELAY_BIGBOOM 3 61 #define DELAY_ROBBO 4 62 #define DELAY_TELEPORT 8 /* Thunor: was 15, 8 is similar to Robbo */ 63 #define DELAY_LASER 4 64 #define DELAY_CAPSULE 10 65 #define DELAY_GUN 8 66 #define DELAY_ROTATION 20 67 #define DELAY_BLASTER 4 68 #define DELAY_PUSHBOX 4 69 #define DELAY_BARRIER 4 70 #define DELAY_TELEPORTING 3 71 #define DELAY_BOMB_TARGET (DELAY_BIGBOOM + 2) /* Was DELAY_BIGBOOM * 2 (6) but 5 is spot on: use RobboIX-003 and Original-020 to test */ 72 #define DELAY_ROBBO_ANIMATE (DELAY_ROBBO / 2) 73 #define DELAY_MAGNET_ATTRACT DELAY_ROBBO /* Was DELAY_ROBBO * 2 but it's the same as Robbo moving: use Original-011 to test */ 74 #define DELAY_BLINKSCREEN 6 /* how long screen should blink after exit opening */ 75 #define DELAY_RESTART (DELAY_BIGBOOM * 8) 76 #endif 77 /* Object ids */ 78 #define EMPTY_FIELD 0 79 #define ROBBO 1 80 #define WALL 2 81 #define WALL_RED 3 82 #define SCREW 4 83 #define BULLET 5 84 #define BOX 6 85 #define KEY 7 86 #define BOMB 8 87 #define DOOR 9 88 #define QUESTIONMARK 10 89 #define BEAR 11 90 #define BIRD 13 91 #define CAPSULE 15 92 #define LITTLE_BOOM 21 93 #define GROUND 24 94 #define WALL_GREEN 25 95 #define BEAR_B 26 96 #define BUTTERFLY 28 97 #define LASER_L 30 98 #define LASER_D 32 99 #define SOLID_LASER_L 34 /* Thunor: The solid laser uses only one frame so I'm seperating it so that I can create different laser/gun images for skins */ 100 #define SOLID_LASER_D 36 /* Thunor: The solid laser uses only one frame so I'm seperating it so that I can create different laser/gun images for skins */ 101 #define TELEPORT 40 102 #define TELEPORTING 41 103 #define BIG_BOOM 42 104 #define GUN 50 105 #define MAGNET 54 106 #define BLASTER 58 107 #define BLACK_WALL 59 108 #define PUSH_BOX 60 109 #define BARRIER 61 110 #define FAT_WALL 63 111 #define ROUND_WALL 64 112 #define BOULDER_WALL 65 113 #define SQUARE_WALL 66 114 #define LATTICE_WALL 67 115 #define RADIOACTIVE_FIELD 68 116 #define STOP 69 117 #define BOMB2 70 /* neurocyp: Robbo alex has two types of bombs, we'd like to support it */ 118 #define S_WALL 71 // Special type of the wall 119 120 #define MECHANIC_SENSIBLE_BEARS TRUE 121 #define MECHANIC_SENSIBLE_QUESTIONMARKS TRUE 122 #define MECHANIC_SENSIBLE_SOLID_LASERS TRUE 123 124 125 #define EFFECT_NONE -1 126 127 /* Variables */ 128 int restart_timeout; /* Time to wait before restarting a level after Robbo dies */ 129 130 struct Coords 131 { 132 int x; 133 int y; 134 }; 135 136 struct object 137 { 138 int type; 139 int state; /* This is for animation and is used as an index into the icon Coords array lower down */ 140 int direction; /* 0r 1d 2l 3u */ 141 int destroyable; /* can be destroyed */ 142 int blowable; /* can be blowed up */ 143 int killing; /* is object dangerous for robbo */ 144 int moved; /* When last object was moved (all movable) */ 145 int blowed; /* Should object be blowed up? */ 146 int shooted; /* When lately object shooted (guns) */ 147 int rotated; /* When object lately was rotated (guns) */ 148 int solidlaser; /* Does gun shoots solid or normal laser */ 149 int rotable; /* If object can be rotated ? (guns) */ 150 int randomrotated; /* When object has undetermining rotation */ 151 int teleportnumber; /* Number of teleport (kind of theleport) */ 152 int teleportnumber2; /* ID of teleport (for teleports with the same number */ 153 int id_questionmark; /* What object is covered under questionmark */ 154 int direction2; /* direction of moveing (for guns) (if direction2 for birds != (direction+-1) bird shoots */ 155 int movable; /* Is object moving (only for guns all animals do) */ 156 int returnlaser; /* only for solid lasers... */ 157 int shooting; /* if birds can shoot */ 158 int processed; /* Time stamped with cycle_count once processed in update_game() */ 159 int redraw; /* Set to 1 if this object/board location needs redrawing in show_game_area() */ 160 #ifdef LIGHTNINGENABLED 161 int effect; /* Visual effect on the object */ 162 #endif 163 struct Coords icon[MAX_ICONS]; /* Coords of left-up point of icons drawed on bitmap */ 164 }; 165 struct object board[MAX_W][MAX_H]; /* This is the game area. Each board location holds one and only one of the above objects */ 166 167 struct 168 { 169 int x; /* Board x position */ 170 int y; /* Board y position */ 171 int alive; /* if Robbo is alive */ 172 int state; /* Robbo's state (0 or 1 for exchange 2 icons for each direction) */ 173 int direction; /* Robbo's direction 0,2,4,6 + state => icon */ 174 int screws; /* The initial number of screws to collect at level start */ 175 int keys; /* Keys collected */ 176 int bullets; /* Bullets collected */ 177 int moved; /* A delay countdown till next move */ 178 int shooted; /* A delay countdown till next shot */ 179 int exitopened; /* Set to TRUE when all the required screws are collected */ 180 int blocked; /* robbo cannot move - possible magnet moving */ 181 int blocked_direction; /* where robbo should be moved after blocking */ 182 int teleporting; /* Set to TRUE when Robbo is teleporting */ 183 } robbo; 184 185 /* What is shown of the board is seen through this viewport */ 186 struct 187 { 188 int x; /* Board x position */ 189 int y; /* Board y position */ 190 #ifdef _SMOOTH_SCRL_ 191 int xs; 192 int ys; 193 #endif 194 int w; 195 int h; 196 int max_w; 197 int max_h; 198 int xoffset; 199 int yoffset; 200 int cycles_to_dest; 201 int maximise; 202 } viewport; 203 204 /* Some game mechanics that I have made available for modification via the rcfile */ 205 struct 206 { 207 int sensible_bears; 208 int sensible_questionmarks; 209 int sensible_solid_lasers; 210 } game_mechanics; 211 212 /* Function prototypes */ 213 void update_game (void); 214 void init_questionmarks (void); 215 void open_exit (void); 216 void init_robbo (void); 217 void move_robbo (int x, int y); 218 void shoot_robbo (int x, int y); 219 void viewport_needs_redrawing (void); 220 void create_object (int x, int y, int type); 221 void clear_entire_board (void); 222 void set_coords (struct Coords *coords, int x, int y); 223 int coords_out_of_range (struct Coords coords); 224 void negate_state (int x, int y); 225 void redraw_field (int x, int y); 226 void clear_field (int x, int y); 227 int in_viewport(int x, int y); 228 int check_wall(int x, int y); 229 int rearange_walls(); 230 int gcoord(int a); 231 232 233