1 /*************************************************************************** 2 game.h - description 3 ------------------- 4 begin : Mon Aug 14 2000 5 copyright : (C) 2000 by Michael Speck 6 email : kulkanie@gmx.net 7 ***************************************************************************/ 8 9 /*************************************************************************** 10 * * 11 * This program is free software; you can redistribute it and/or modify * 12 * it under the terms of the GNU General Public License as published by * 13 * the Free Software Foundation; either version 2 of the License, or * 14 * (at your option) any later version. * 15 * * 16 ***************************************************************************/ 17 18 #ifndef GAME_H 19 #define GAME_H 20 21 #include <sys/stat.h> 22 #include <dirent.h> 23 #include "levels.h" 24 #include "dynlist.h" 25 #include "profile.h" 26 #include "sdl.h" 27 #include "audio.h" 28 29 // gfx set // 30 typedef struct { 31 char nm[16]; // name 32 int ok; // can be used 33 SDL_Surface 34 *s_bkgd, // background 35 *s_wl, // walls 36 *s_flr, // floor 37 *s_r_arw, *s_l_arw, *s_u_arw, *s_d_arw, // arrows 38 *s_ud_bar, *s_lr_bar, // barriers 39 *s_tlp_0, *s_tlp_1, *s_tlp_2, *s_tlp_3, // teleporters 40 *s_crmbl; // crumbling wall 41 } GSet; 42 43 // animation information // 44 typedef struct { 45 int f; // frame limit // 46 float c; // change per millisecond // 47 float p; // current position // 48 int w, h; // size of one sprite // 49 } AInf; 50 51 // map animation // 52 typedef struct { 53 int x, y; // position in map 54 int t; // type 55 AInf *a; // animation info 56 } MAni; 57 58 // position 59 typedef struct { 60 int x, y; 61 } Pos; 62 63 // vector 64 typedef struct { 65 float x,y; 66 } Vec; 67 68 // shrapnell 69 typedef struct { 70 SDL_Surface *s_shr; // picture; 71 Vec d; //direction 72 float x,y; //position 73 int w, h; // size 74 float a; // alpha 75 } Shr; 76 77 // cursor states // 78 #define C_NONE 0 79 #define C_SEL 1 80 #define C_U 2 81 #define C_R 3 82 #define C_D 4 83 #define C_L 5 84 85 // valid marble directions // 86 #define MD_L (1<<0) 87 #define MD_R (1<<1) 88 #define MD_U (1<<2) 89 #define MD_D (1<<3) 90 91 #define L_GREEN 0 92 #define L_ORANGE 1 93 #define L_RED 2 94 #define L_WHITE 3 95 #define L_SIZE 12 96 typedef struct { 97 // gfx sets // 98 DLst g_sts; // gfx sets // 99 // mouse button state // 100 int bttn[4]; 101 // graphics // 102 SDL_Surface *s_lghts; // lamps displaying level progress // 103 SDL_Surface *s_brd; // side board // 104 SDL_Surface *s_mrb; // marbles // 105 SDL_Surface *s_fig; // figure // 106 SDL_Surface *s_bkgd; // background // 107 SDL_Surface *s_mf; // marble frame // 108 SDL_Surface *s_msf; // marble select frame // 109 // fonts // 110 SFnt *f_sml; // info // 111 SFnt *f_wht; // time // 112 SFnt *f_rd; // time2 - not much time left // 113 // references // 114 Prf *c_prf; // current profile // 115 SInf *c_s_inf; // current profile level set info // 116 LSet *c_l_st; // current level set // 117 GSet *c_g_st; // current gfx set // 118 Lvl *c_lvl; // current level // 119 // player // 120 int hi_scr; // last hiscore // 121 int c_l_id; // current level // 122 int c_ch; // current chapter // 123 int o_ch; // old chapter // 124 int l_done; // level finished // 125 // marble // 126 float m_v; // marble velocity per millisecond // 127 int m_sel; // selected a marble ? // 128 int m_mx, m_my; // position in map // 129 int m_o_x, m_o_y; // old position // 130 int m_o_move_count; // old move count // 131 float m_x, m_y; // position in screen // 132 int m_mv; // moving ? // 133 int m_d; // direction of moving // 134 int m_vd; // valid directions // 135 int m_tx, m_ty; // target position in screen // 136 int m_id; // current type of marble // 137 AInf m_a; // animation information // 138 int m_act; // action type // 139 int m_warp; // warp marble to destination // 140 // marble frame and marble select frame 141 AInf mf_a; // animation info 142 AInf msf_a; // animation info 143 // layout // 144 int l_x, l_y; // offset of level relative to 0,0 -- in L_Ini() 145 int f_x, f_y; // figure offset relative to b_x, 0 146 int b_x; // board x 147 int i_x, i_y; // info position relative to b_x,0 148 int t_x, t_y; // timer position relative to b_x,0 149 int s_x, s_y; // set info position relative to b_x,0 150 int c_x, c_y; // position of first chapter info relative to b_x,0 -- in L_Ini() 151 // geometry // 152 int t_w, t_h; // tile size // 153 int f_w, f_h; // figure marble size // 154 int f_fw, f_fh; // figure frame size // 155 int scr_w, scr_h; // screen size // 156 int brd_w; // board width 157 int s_w, s_h; // size of set info 158 int c_off; // offset between chapter infos // 159 // cursors // 160 int c_stat; // cursor state // 161 SDL_Cursor *c_u, *c_d, *c_l, *c_r, *c_s, *c_n, *c_w; // cursors 162 // old mouse pos // 163 int o_mx, o_my; 164 // level warp // 165 char inf_str[64]; // warp info string 166 int w_c, w_l; // warp level and chapter 167 // map animations // 168 MAni *m_ani; // animations 169 int ma_num; // animation number 170 AInf ma_ow_a; // oneway info 171 AInf ma_tlp_a; // teleport info 172 int tlp_a; // telporter alpha 173 // sounds 174 #ifdef SOUND 175 Sound_Chunk *wv_tlp; // teleport 176 Sound_Chunk *wv_sel; // select 177 Sound_Chunk *wv_stp; // stop 178 Sound_Chunk *wv_clk; // click 179 Sound_Chunk *wv_exp; // explode 180 Sound_Chunk *wv_alm; // alarm 181 Sound_Chunk *wv_arw; // arrow 182 Sound_Chunk *wv_scr; // score 183 #endif 184 DLst shr; // shrapnells 185 float shr_a_c; // alpha change per second 186 // credits 187 float cr_a_c; // alpha change per msecond 188 float cr_a; // current alpha 189 int cr_tm; // shown how long ? 190 int cr_c_tm; // current time 191 char cr_str[256]; // what is shown... 192 int cr_x, cr_y, cr_w, cr_h; // shown where ? 193 int cr_st; // state: 0 undim, 1 shown, 2 dim 194 // snapshot 195 int snap; 196 // blink time // 197 int blink_time; 198 } Game; 199 200 void G_Ini(); 201 void G_Trm(); 202 int G_Opn(); 203 void G_Cls(); 204 void G_Run(); 205 void G_LdGSts(); 206 void G_DelGSt(void *p); 207 void G_Ps(); 208 void G_CkFgr(); 209 int G_CfmWrp(); 210 int G_CfmQut(); 211 int G_CfmRst(); 212 int G_CkLSt(); 213 214 // marble // 215 void Mr_Hd(); 216 void Mr_Shw(); 217 int Mr_Upd(int ms); 218 void Mr_Sel(int x, int y); 219 void Mr_Rel(int x, int y); 220 void Mr_IniMv(); 221 void Mr_Stp(); 222 void Mr_Ins(); 223 void Mr_CkVDir(int mx, int my); 224 void Mr_Act(); 225 void Mr_ResPos(); 226 227 // timer // 228 void Tm_Hd(); 229 void Tm_Shw(); 230 int Tm_Upd(int ms); 231 232 // level info // 233 void Inf_Hd(); 234 int Inf_Upd(); 235 void Inf_Shw(); 236 237 // cursor // 238 void Cr_Ld(char *src, char *d, char*m); 239 void Cr_Cng(int x, int y); 240 241 // frame // 242 void MF_Hd(); 243 void MF_Upd(int ms); 244 void MF_Shw(); 245 246 // map animations // 247 void MA_Ini(); 248 void MA_Upd(int ms); 249 void MA_Shw(); 250 251 // shrapnells // 252 void Shr_Add(int x, int y, int w, int h, Vec d, SDL_Surface *s_shr); 253 void Shr_Del(void *p); 254 void Shr_Hd(); 255 void Shr_Upd(int ms); 256 void Shr_Shw(); 257 258 // wall // 259 void Wl_Exp(int x, int y, int v); 260 261 // figure animation // 262 void FA_Run(); 263 void FA_Add(int mx, int my, int m); 264 265 // credits // 266 void Cr_Ini(); 267 void Cr_Hd(); 268 void Cr_Upd(int ms); 269 void Cr_Shw(); 270 271 // bonus summary // 272 void BS_Run(float b_lvl, float b_tm); 273 void BS_Hd(int x, int y, int w, int h); 274 void BS_Shw(int x, int y, int v); 275 276 // shnapshot // 277 void SnapShot(); 278 279 #endif 280