home *** CD-ROM | disk | FTP | other *** search
/ Black Art of 3D Game Programming / Black_Art_of_3D_Game_Programming.iso / source / borland / chap_18 / krkm0.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-27  |  17.8 KB  |  512 lines

  1.  
  2. // KRKM0.H - Header file for modular kill or be killed
  3.  
  4. // D E F I N E S /////////////////////////////////////////////////////////////
  5.  
  6. // defines for the radar scanner
  7.  
  8. #define SCANNER_X               12      // position of scanner
  9. #define SCANNER_Y               135
  10. #define SCANNER_WIDTH           57      // size of scanner area
  11. #define SCANNER_HEIGHT          42
  12.  
  13. // commands that can be sent to the scanner engine
  14.  
  15. #define SCANNER_CLEAR           0       // clear the scanner
  16. #define SCANNER_LOGO            1       // draw the KRK logo
  17. #define SCANNER_ERASE_BLIPS     2       // erase all the radar blips
  18. #define SCANNER_DRAW_BLIPS      3       // draw all the radar blips
  19.  
  20. // defines for the general multi function tactical display
  21.  
  22. #define TACTICAL_X              249     // position of tactical
  23. #define TACTICAL_Y              134
  24. #define TACTICAL_WIDTH          57      // size of tactical
  25. #define TACTICAL_HEIGHT         34
  26.  
  27. // different modes of operation for the tactical display
  28.  
  29. #define TACTICAL_MODE_STS       0       // ship status mode
  30. #define TACTICAL_MODE_HULL      1       // hull damage report
  31. #define TACTICAL_MODE_OFF       2       // tactical display off
  32.  
  33. // these are the different icon indexes for the tactical display
  34.  
  35. #define TACTICAL_ICON_BLANK     0       // a black square
  36. #define TACTICAL_ICON_KRK       1       // the kill or be killed logo
  37. #define TACTICAL_ICON_GAUGE     2       // the gauge set
  38. #define TACTICAL_ICON_TALLON    3       // the tallon hull
  39. #define TACTICAL_ICON_SLIDER    4       // the slider hull
  40.  
  41. #define TACTICAL_ICON_WIDTH     38      // size of sprite bitmaps for tactical
  42. #define TACTICAL_ICON_HEIGHT    28
  43.  
  44. // commands the drawing engine of the tactical display
  45.  
  46. #define TACTICAL_CLEAR          0       // clear the tactical
  47. #define TACTICAL_DRAW           1       // draw the tactical
  48. #define TACTICAL_UPDATE         2       // refresh the tactical
  49.  
  50. // the main menu selection system defines
  51.  
  52. #define SELECT_BOX_SX           104     // starting position of selection boxes
  53. #define SELECT_BOX_SY           58
  54. #define SELECT_BOX_DY           19      // vertical change between boxes
  55. #define SELECT_BOX_WIDTH        94      // dimensions of selection boxes
  56. #define SELECT_BOX_HEIGHT       10
  57.  
  58. #define SELECT_LGT_SX           86      // starting position of little lights by box
  59. #define SELECT_LGT_SY           61
  60. #define SELECT_LGT_DY           19      // vertical change to next light
  61. #define SELECT_LGT_WIDTH        4       // dimensions of light
  62. #define SELECT_LGT_HEIGHT       4
  63.  
  64. #define MAX_SELECTION           3       // maximum number of selections
  65.  
  66. // defines for the background moutain scape
  67.  
  68. #define MOUNTAIN_HEIGHT         43      // height of mountain
  69. #define MOUNTAIN_WIDTH          320     // total width of backdrop
  70. #define MOUNTAIN_Y_POS          56      // starting y position to map down backdrop
  71.  
  72. // starting position of the intro startup sequence
  73.  
  74. #define START_MESS_X            2
  75. #define START_MESS_Y            8
  76.  
  77. // position of alpha numeric input area
  78.  
  79. #define DISPLAY_X              0
  80. #define DISPLAY_Y              0
  81.  
  82.  
  83. // defines for the aliens and logic
  84.  
  85. #define ALIEN_DEAD              0      // alien is dead
  86. #define ALIEN_DYING             1      // alien is dying
  87. #define ALIEN_NEW_STATE         2      // alien wishes a new state
  88. #define ALIEN_ATTACK            3      // alien is attacking player
  89. #define ALIEN_RANDOM            4      // alien is moving in random directions
  90. #define ALIEN_EVADE             5      // alien is evading player
  91. #define ALIEN_STOP              6      // alien is at a full stop
  92. #define ALIEN_TURN              7      // alien is making a turn
  93.  
  94. #define NUM_ALIENS              4      // total number of aliens in game
  95.  
  96. #define ALIEN_TALLON            0      // id for an alien with a tallon class ship
  97. #define ALIEN_SLIDER            1      // is for an alien with a slider class ship
  98.  
  99. // dimesions of the game world
  100.  
  101. #define GAME_MAX_WORLD_X        7500    // x dimensions
  102. #define GAME_MIN_WORLD_X        -7500
  103.  
  104. #define GAME_MAX_WORLD_Y        400     // y dimensions
  105. #define GAME_MIN_WORLD_Y        -400
  106.  
  107. #define GAME_MAX_WORLD_Z        7500    // z dimensions
  108. #define GAME_MIN_WORLD_Z        -7500
  109.  
  110. #define GUN_HEIGHT              -10    // height of weapon system from ground level
  111.  
  112. #define NUM_DYNAMIC              3     // total number of dynamic game objects
  113.  
  114. #define NUM_MISSILES             12    // maxium number of missiles in the game
  115.  
  116. // possible missle states
  117.  
  118. #define MISSILE_INACTIVE         0     // an inactive missile
  119. #define MISSILE_ACTIVE           1     // an active and moving moving
  120.  
  121. #define MAX_PLAYER_MISSILES      6     // maximum number of missiles player
  122.                                        // can fire at once
  123.  
  124. // used to track who fired a missile, helps for collision detection
  125.  
  126. #define NO_OWNER                 0     // no owner, can cause damage to anyone
  127. #define PLAYER_OWNER             1     // the player fired it
  128. #define ALIEN_OWNER              2     // an alien fired it
  129. #define OTHER_OWNDER             3     // an unknown fired it
  130.  
  131. // these are used to index into the 3-D models
  132.  
  133. #define MISSILES_TEMPLATE        0     // the missile model
  134. #define TALLONS_TEMPLATE         1     // the tallon model
  135. #define SLIDERS_TEMPLATE         2     // the slider model
  136.  
  137.  
  138. // these define the number of each object type
  139.  
  140. #define NUM_STATIONARY           6    // total number of stationary object types
  141.  
  142. #define NUM_OBSTACLES_1          32   // number of rocks
  143. #define NUM_OBSTACLES_2          32   // number of crystals
  144. #define NUM_BARRIERS             8    // number of lasrer barriers
  145. #define NUM_TOWERS               4    // number of control towers
  146. #define NUM_STATIONS             1    // number of power stations
  147. #define NUM_TELEPODS             4    // number of telepods
  148.  
  149. // these are the model indices
  150.  
  151. #define OBSTACLES_1_TEMPLATE     0    // the rock model
  152. #define OBSTACLES_2_TEMPLATE     1    // the crystal model
  153. #define BARRIERS_TEMPLATE        2    // the laser barrier model
  154. #define TOWERS_TEMPLATE          3    // the control tower model
  155. #define STATIONS_TEMPLATE        4    // the power station model
  156. #define TELEPODS_TEMPLATE        5    // the telepod model
  157.  
  158. // digital sound system
  159.  
  160. #define KRKMIS_VOC                  0  // the sound a missile makess
  161. #define KRKEMIS_VOC                 1  // the sound an enemy missile makes
  162. #define KRKTAC_VOC                  2  // tactical engaging
  163. #define KRKSCN_VOC                  3  // scanner engaging
  164. #define KRKHUD_VOC                  4  // hud engaging
  165. #define KRKPOW_VOC                  5  // powering up
  166. #define KRKKEY_VOC                  6  // a key was pressed
  167. #define KRKEX1_VOC                  7  // the alien explosion
  168. #define KRKEX2_VOC                  8  // the blast of an alien
  169.  
  170. #define NUM_SOUND_FX                9      // the number of sound fx loaded in
  171.  
  172. // color fx registers for a multitude of objects
  173.  
  174. #define SHIELDS_REG                 232    // the insrument panel shields color register
  175. #define RADAR_REG                   233    // the insrument panel radar color register
  176. #define COMM_REG                    234    // the insrument panel communications color register
  177. #define HUD_REG                     235    // the insrument panel hud color register
  178.  
  179. #define STS_REG                     236    // the insrument panel ship status color register
  180. #define HULL_REG                    237    // the insrument panel hull color register
  181. #define OFF_REG                     238    // the insrument panel off color register
  182.  
  183. #define PLAYERS_WEAPON_FIRE_REG     239    // the little light that glows when the player fires
  184.  
  185. #define ENGINES_TALLON_REG          240    // the engine flicker for tallons
  186. #define ENGINES_SLIDER_REG          241    // the engine flicker for sliders
  187. #define BARRIERS_REG                242    // the laser barriers
  188. #define SHIELDS_FLICKER_REG         243    // the shields (not implemented)
  189.  
  190. #define START_PANEL_REG             224    // the start register for the main menu fx
  191. #define END_PANEL_REG               (224+7)// the end register for the main menu fx
  192.  
  193. #define SELECT_REG                  254    // the glowing currently selected main menu item
  194.  
  195. #define ALIEN_EXPL_BASE_REG         244    // the aliens that are killed all
  196.                                            // get allocated a color register at this base
  197.  
  198. // defines for the grdient sky and ground
  199.  
  200. #define SKY_COLOR_1                 50     // reds
  201. #define SKY_COLOR_2                 52
  202. #define SKY_COLOR_3                 53
  203.  
  204. #define GND_COLOR_1                 216    // browns
  205. #define GND_COLOR_2                 215
  206. #define GND_COLOR_3                 214
  207.  
  208. // music system
  209.  
  210. #define NUM_INTRO_SEQUENCES    11 // the number of elements in intro music score
  211. #define NUM_GAME_SEQUENCES     18 // the number of elements in game music score
  212.  
  213. // defines for briefing instructions
  214.  
  215. #define NUM_PAGES              8
  216. #define NUM_LINES_PAGE         17
  217. #define NUM_SHIP_SPECS         7
  218.  
  219.  
  220. // state of the game itself
  221.  
  222. #define GAME_SETUP             0   // the game is in the setup mode
  223. #define GAME_LINKING           1   // the communications link is being established
  224. #define GAME_RUNNING           2   // the game is running
  225. #define GAME_PAUSED            3   // the game is paused (not implemented)
  226. #define GAME_OVER              4   // what do you think
  227.  
  228. // general object states
  229.  
  230. #define DEAD                   0   // these are general states for any
  231. #define ALIVE                  1   // object
  232. #define DYING                  2
  233.  
  234. // defines for the ship state machine
  235.  
  236. #define SHIP_STABLE            0   // the ship is stable
  237. #define SHIP_HIT               1   // the ship has been hit
  238. #define SHIP_TELEPORT          2   // the ship is teleporting (not implemented)
  239.  
  240. #define SHIP_FLAME_COLOR       96  // odd ball, the starting base color register
  241.                                    // that is used to flicker the screen to simulate
  242.                                    // a torpedo blast
  243.  
  244. // used to indicate which ship type the player is using
  245.  
  246. #define PLAYER_TALLON          0
  247. #define PLAYER_SLIDER          1
  248.  
  249. // defines for setup selections
  250.  
  251. #define SETUP_CHALLENGE             0
  252. #define SETUP_SELECT_MECH           1
  253. #define SETUP_RULES                 2
  254. #define SETUP_EXIT                  3
  255.  
  256. #define NUM_SETUP                   4   // number of setup choices
  257.  
  258. // size of the "tech" font used in intro
  259.  
  260. #define TECH_FONT_WIDTH             4   // width of high tech font
  261. #define TECH_FONT_HEIGHT            7   // height of high tech font
  262. #define NUM_TECH_FONT               64  // number of characters in tech font
  263.  
  264. // S T R U C T U R E S ///////////////////////////////////////////////////////
  265.  
  266. // this structure is used to replicate static similar objects based on the
  267. // same model
  268.  
  269. typedef struct fixed_obj_typ
  270.         {
  271.         int state;        // state of object
  272.         int rx,ry,rz;     // rotation rate of object
  273.         float x,y,z;      // position of object
  274.  
  275.         } fixed_obj, *fixed_obj_ptr;
  276.  
  277. // this structure is used for all projectiles in the game, similar
  278. // to the above structure except with added fields for animation, collision,
  279. // etc.
  280.  
  281. typedef struct proj_obj_typ
  282.         {
  283.  
  284.         int state;            // state of projectile
  285.         int owner;            // owner of projectile
  286.         int lifetime;         // lifetime of projectile
  287.  
  288.         vector_3d direction;  // direction and velocity of projectile
  289.  
  290.         float x,y,z;          // position of projectile
  291.  
  292.         } missile_obj, proj_obj, *missile_obj_ptr, *proj_obj_ptr;
  293.  
  294. // this data structure is used to hold and alien attacker
  295.  
  296. typedef struct alien_typ
  297.         {
  298.         int state;                // state of alien
  299.         int counter_1;            // counters
  300.         int counter_2;
  301.         int threshold_1;          // thresholds for counters
  302.         int threshold_2;
  303.         int aux_1;                // auxialliary variables for whatever
  304.         int aux_2;
  305.         int color_reg;            // color register of alien during explosion
  306.         RGB_color color;          // actual rgb color of explosion
  307.         int type;                 // type of alien
  308.         int angular_heading;      // curr angle about y axis, i.e. yaw
  309.  
  310.         int speed;                // speed of ship
  311.  
  312.         vector_3d direction;      // the current trajectory vector
  313.  
  314.         float x,y,z;              // position of alien
  315.  
  316.         } alien, *alien_ptr;
  317.  
  318. // P R O T O T Y P E S //////////////////////////////////////////////////////
  319.  
  320. void Select_Mech(void);
  321.  
  322. void Misc_Color_Init(void);
  323.  
  324. void Tallon_Color_FX(void);
  325.  
  326. void Slider_Color_FX(void);
  327.  
  328. void Barrier_Color_FX(void);
  329.  
  330. void Draw_Hud(void);
  331.  
  332. void Draw_Tactical(int command);
  333.  
  334. void Load_Tactical(void);
  335.  
  336. void Draw_Scanner(int command);
  337.  
  338. void Init_Missiles(void);
  339.  
  340. void Move_Missiles(void);
  341.  
  342. void Draw_Missiles(void);
  343.  
  344. int Start_Missile(int owner,
  345.                   vector_3d_ptr pos,
  346.                   vector_3d_ptr dir,
  347.                   int speed,
  348.                   int lifetime);
  349.  
  350. void Init_Aliens(void);
  351.  
  352. void Process_Aliens(void);
  353.  
  354. void Draw_Aliens(void);
  355.  
  356. void Draw_Background(int mountain_pos);
  357.  
  358. void Draw_Box(int x1,int y1,int x2, int y2,int color);
  359.  
  360. void Tech_Print(int x,int y,char *string,unsigned char far *destination);
  361.  
  362. void Font_Engine_1(int x,int y,
  363.                    int font,int color,
  364.                    char *string,unsigned char far *destination);
  365.  
  366. void Panel_FX(int reset);
  367.  
  368. void Intro_Planet(void);
  369.  
  370. void Closing_Screen(void);
  371.  
  372. void Intro_Waite(void);
  373.  
  374. void Intro_KRK(void);
  375.  
  376. void Intro_Controls(void);
  377.  
  378. void Intro_Briefing(void);
  379.  
  380. void Reset_System(void);
  381.  
  382. void Music_Init(void);
  383.  
  384. void Music_Close(void);
  385.  
  386. void Digital_FX_Init(void);
  387.  
  388. void Digital_FX_Close(void);
  389.  
  390. int Digital_FX_Play(int the_effect, int priority);
  391.  
  392. int Parse_Commands(int argc, char **argv);
  393.  
  394. void Draw_Stationary_Objects(void);
  395.  
  396. void Set_3D_View(void);
  397.  
  398. void Load_3D_Objects(void);
  399.  
  400. // G L O B A L S  ////////////////////////////////////////////////////////////
  401.  
  402. extern object static_obj[NUM_STATIONARY];      // there are six basic stationary object types
  403.  
  404. extern fixed_obj obstacles_1[NUM_OBSTACLES_1]; // general obstacles, rocks etc.
  405. extern fixed_obj obstacles_2[NUM_OBSTACLES_2]; // general obstacles, rocks etc.
  406.  
  407. extern fixed_obj barriers[NUM_BARRIERS];       // boundary universe boundaries
  408. extern fixed_obj towers[NUM_TOWERS];           // the control towers
  409. extern fixed_obj stations[NUM_STATIONS];       // the power stations
  410. extern fixed_obj telepods[NUM_TELEPODS];       // the teleporters
  411.  
  412.  
  413. extern object dynamic_obj[NUM_DYNAMIC];        // this array holds the models
  414.                                         // for the dynamic game objects
  415.  
  416. extern alien aliens[NUM_ALIENS];               // take a wild guess!
  417.  
  418. extern missile_obj missiles[NUM_MISSILES];     // holds the missiles
  419.  
  420. extern int active_player_missiles;         // how many missiles has player activated
  421.  
  422. extern int total_active_missiles;          // total active missiles
  423.  
  424. extern layer mountains;              // the background mountains
  425.  
  426. extern pcx_picture image_pcx,        // general PCX image used to load background and imagery
  427.             image_controls;   // this holds the controls screen
  428.  
  429. extern sprite tactical_spr,          // holds the images for the tactical displays
  430.        buttons_spr;           // holds the images for the control buttons
  431.  
  432. extern RGB_color color_1,color_2;    // used for temporaries during color rotation
  433.  
  434. extern RGB_palette game_palette;     // this will hold the startup system palette
  435.  
  436. extern bitmap tech_font[NUM_TECH_FONT];   // the tech font bitmaps
  437.  
  438. extern int game_state;      // the overall state of the game
  439.  
  440. extern int scanner_state,            // state of scanner
  441.     hud_state,
  442.     tactical_state;
  443.  
  444. extern int ship_pitch,   // current direction of ship
  445.     ship_yaw    ,   // not used
  446.     ship_roll   ,   // not used
  447.     ship_speed  ,   // speed of ship
  448.     ship_energy ,  // current energy of ship
  449.     ship_damage ,   // current damage up to 50 points
  450.     ship_message,  // current message to ship state machine
  451.     ship_timer  ,  // a little timer
  452.      ship_kills  ,  // how many bad guys has player killed
  453.     ship_deaths ;  // how many times has player been killed
  454.  
  455. extern vector_3d unit_z,  // a unit vector in the Z direction
  456.           ship_direction;  // the ships direction
  457.  
  458. extern int players_ship_type;  // the player starts off with a tallon
  459.  
  460. // musical sequence information
  461.  
  462. extern int music_enabled,      // flags that enable music and sound FX
  463.     digital_enabled;
  464.  
  465. extern int digital_FX_priority; // the priority tracker of the current effect
  466.  
  467. extern int intro_sequence[];
  468.  
  469. extern int intro_seq_index; // starting intro index number of sequence to be played
  470.  
  471. extern int game_sequence[];
  472.  
  473. extern int game_seq_index; // starting game index number of sequence to be played
  474.  
  475. extern music song;    // the music structure
  476.  
  477. // sound fx stuff
  478.  
  479. extern _sound digital_FX[NUM_SOUND_FX];
  480.  
  481. // basic colors
  482.  
  483. extern RGB_color  bright_red,    // bright red
  484.            bright_blue,    // bright blue
  485.            bright_green,    // bright green
  486.  
  487.            medium_red,    // medium red
  488.               medium_blue,    // medium blue
  489.            medium_green,    // medium green
  490.  
  491.               dark_red,    // dark red
  492.            dark_blue,    // dark blue
  493.            dark_green,    // dark green
  494.  
  495.            black,     // pure black
  496.            white,  // pure white
  497.  
  498.            color_1,color_2,color_3;    // general color variables
  499.  
  500. // the instruction pages
  501.  
  502. extern char *instructions[];
  503.  
  504. // specification for the tallon
  505.  
  506. extern char *tallon_specs[];
  507.  
  508. // specifications for the slider
  509.  
  510. extern char *slider_specs[];
  511.  
  512.