home *** CD-ROM | disk | FTP | other *** search
/ PC Format (South-Africa) 2001 June / PCFJune.iso / Xenon / XenonSource.exe / demo4 / level.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-07-23  |  3.6 KB  |  149 lines

  1. //-------------------------------------------------------------
  2. //
  3. // Class:    CLevel
  4. //
  5. // Author:    John M Phillips
  6. //
  7. // Started:    06/05/00
  8. //
  9. // Base:    None
  10. //
  11. // Derived:    None
  12. //
  13. //-------------------------------------------------------------
  14.  
  15. #ifndef _INCLUDE_LEVEL_H
  16. #define _INCLUDE_LEVEL_H
  17.  
  18. #include "gamesystem.h"
  19. #include "scene.h"
  20.  
  21. //-------------------------------------------------------------
  22.  
  23. struct MPHD
  24. {                            /* Map header structure */
  25.     char mapverhigh;        /* map version number to left of . (ie X.0). */
  26.     char mapverlow;            /* map version number to right of . (ie 0.X). */
  27.     char lsb;                /* if 1, data stored LSB first, otherwise MSB first. */
  28.     char reserved;
  29.     short int mapwidth;        /* width in blocks. */
  30.     short int mapheight;    /* height in blocks. */
  31.     short int reserved1;
  32.     short int reserved2;
  33.     short int blockwidth;    /* width of a block (tile) in pixels. */
  34.     short int blockheight;    /* height of a block (tile) in pixels. */
  35.     short int blockdepth;    /* depth of a block (tile) in planes (ie. 256 colours is 8) */
  36.     short int blockstrsize;    /* size of a block data structure */
  37.     short int numblockstr;    /* Number of block structures in BKDT */
  38.     short int numblockgfx;    /* Number of 'blocks' in graphics (BGFX) */
  39. };
  40.  
  41. //-------------------------------------------------------------
  42.  
  43. struct BLKSTR
  44. {                                    /* Structure for data blocks */
  45. unsigned long bgoff, fgoff;            /* offsets from start of graphic blocks */
  46. unsigned long fgoff2, fgoff3;         /* more overlay blocks */
  47. unsigned long int user1, user2;        /* user long data */
  48. unsigned short int user3, user4;    /* user short data */
  49. unsigned char user5, user6, user7;    /* user byte data */
  50. unsigned char tl : 1;                /* bits for collision detection */
  51. unsigned char tr : 1;
  52. unsigned char bl : 1;
  53. unsigned char br : 1;
  54. unsigned char trigger : 1;            /* bit to trigger an event */
  55. unsigned char unused1 : 1;
  56. unsigned char unused2 : 1;
  57. unsigned char unused3 : 1;
  58. };
  59.  
  60. //-------------------------------------------------------------
  61.  
  62. typedef enum {
  63.     WALLHUGGER,                // 0
  64.     ASTEROID,                // 1
  65.     RUSHER,                    // 2
  66.     POD,                    // 3
  67.     HOMER,                    // 4
  68.     DRONE_GENERATOR,        // 5
  69.     LONER,                    // 6
  70.     REVERSE_RUSHER,            // 7
  71.     RUSHER_GENERATOR_RIGHT,    // 8
  72.     RUSHER_GENERATOR_LEFT,    // 9
  73.     ORGANIC_GUN,            // 10
  74. } AlienType;
  75.  
  76. typedef enum {
  77.     PICKUP_SHIELD,            // 0
  78.     PICKUP_SPEEDUP,            // 1
  79.     PICKUP_WEAPONUP,        // 2
  80.     PICKUP_CLOAK,            // 3
  81.     PICKUP_DIVE,            // 4
  82.     PICKUP_SCOREBONUS,        // 5
  83.     PICKUP_CLONE,            // 6
  84.     PICKUP_WINGTIP,            // 7
  85.     PICKUP_HOMINGMISSILE,    // 8
  86.     PICKUP_LASER,            // 9
  87. } PickupType;
  88.  
  89. typedef enum {
  90.     ID_NORMAL_TILE,            // 0
  91.     ID_PICKUP,                // 1
  92.     ID_ALIEN,                // 2
  93.     ID_DESTROYABLE_TILE,    // 3
  94.     ID_CHECKPOINT,            // 4
  95.     ID_WARP_START,            // 5
  96.     ID_WARP_END,            // 6
  97.     ID_BOSS_MOUTH,            // 7
  98.     ID_BOSS_EYE,            // 8
  99.     ID_BOSS_CONTROL            // 9
  100. } TileId;
  101.  
  102. //-------------------------------------------------------------
  103. // collision flags
  104.  
  105. const gsUBYTE COLLIDE_WITH_SHIP = 1;
  106. const gsUBYTE COLLIDE_WITH_BULLETS = 2;
  107.  
  108. //-------------------------------------------------------------
  109.  
  110. class CLevel
  111. {
  112.     private:
  113.         MPHD m_header;
  114.  
  115.         gsCFile m_file;
  116.  
  117.         bool readUWORD(gsUWORD& w);
  118.         bool readUDWORD(gsUDWORD& d);
  119.         bool error();
  120.  
  121.         BLKSTR *m_blocks;
  122.  
  123.         int m_scan_y;
  124.  
  125.         void destroy();
  126.  
  127.         bool m_boss_active;
  128.  
  129.     public:
  130.         CLevel();
  131.         ~CLevel();
  132.  
  133.         gsCMap m_back_layer;
  134.         gsCMap m_front_layer;
  135.  
  136.         gsCTiledImage m_image;
  137.  
  138.         bool load(const char *filename,const char *graphics_directory);
  139.  
  140.         void reset();
  141.         void scanForNewActors(CScene *scene);
  142.  
  143.         bool isBossActive() { return m_boss_active; };
  144. };
  145.  
  146. //-------------------------------------------------------------
  147.  
  148. #endif
  149.