home *** CD-ROM | disk | FTP | other *** search
/ PC Format (South-Africa) 2001 June / PCFJune.iso / Xenon / XenonSource.exe / demo3 / level.h < prev   
Encoding:
C/C++ Source or Header  |  2000-09-11  |  3.0 KB  |  116 lines

  1. //-------------------------------------------------------------
  2. //
  3. // Class:    CLevel
  4. //
  5. // Author:    John M Phillips
  6. //
  7. // Started:    06/05/00
  8. //
  9. // Remarks:    This is a cut-down version of the level loader
  10. //            used in Xenon2000
  11. //
  12. //-------------------------------------------------------------
  13.  
  14. #ifndef _INCLUDE_LEVEL_H
  15. #define _INCLUDE_LEVEL_H
  16.  
  17. #include "gamesystem.h"
  18.  
  19. //-------------------------------------------------------------
  20.  
  21. struct MPHD
  22. {                            /* Map header structure */
  23.     char mapverhigh;        /* map version number to left of . (ie X.0). */
  24.     char mapverlow;            /* map version number to right of . (ie 0.X). */
  25.     char lsb;                /* if 1, data stored LSB first, otherwise MSB first. */
  26.     char reserved;
  27.     short int mapwidth;        /* width in blocks. */
  28.     short int mapheight;    /* height in blocks. */
  29.     short int reserved1;
  30.     short int reserved2;
  31.     short int blockwidth;    /* width of a block (tile) in pixels. */
  32.     short int blockheight;    /* height of a block (tile) in pixels. */
  33.     short int blockdepth;    /* depth of a block (tile) in planes (ie. 256 colours is 8) */
  34.     short int blockstrsize;    /* size of a block data structure */
  35.     short int numblockstr;    /* Number of block structures in BKDT */
  36.     short int numblockgfx;    /* Number of 'blocks' in graphics (BGFX) */
  37. };
  38.  
  39. //-------------------------------------------------------------
  40.  
  41. struct BLKSTR
  42. {                                    /* Structure for data blocks */
  43. unsigned long bgoff, fgoff;            /* offsets from start of graphic blocks */
  44. unsigned long fgoff2, fgoff3;         /* more overlay blocks */
  45. unsigned long int user1, user2;        /* user long data */
  46. unsigned short int user3, user4;    /* user short data */
  47. unsigned char user5, user6, user7;    /* user byte data */
  48. unsigned char tl : 1;                /* bits for collision detection */
  49. unsigned char tr : 1;
  50. unsigned char bl : 1;
  51. unsigned char br : 1;
  52. unsigned char trigger : 1;            /* bit to trigger an event */
  53. unsigned char unused1 : 1;
  54. unsigned char unused2 : 1;
  55. unsigned char unused3 : 1;
  56. };
  57.  
  58. //-------------------------------------------------------------
  59.  
  60. typedef enum {
  61.     ID_NORMAL_TILE,            // 0
  62.     ID_PICKUP,                // 1
  63.     ID_ALIEN,                // 2
  64.     ID_DESTROYABLE_TILE,    // 3
  65.     ID_CHECKPOINT,            // 4
  66.     ID_WARP_START,            // 5
  67.     ID_WARP_END,            // 6
  68.     ID_BOSS_MOUTH,            // 7
  69.     ID_BOSS_EYE,            // 8
  70.     ID_BOSS_CONTROL            // 9
  71. } TileId;
  72.  
  73. //-------------------------------------------------------------
  74. // collision flags
  75.  
  76. const gsUBYTE COLLIDE_WITH_SHIP = 1;
  77. const gsUBYTE COLLIDE_WITH_BULLETS = 2;
  78.  
  79. //-------------------------------------------------------------
  80.  
  81. class CLevel
  82. {
  83.     private:
  84.         MPHD m_header;
  85.  
  86.         gsCFile m_file;
  87.  
  88.         bool readUWORD(gsUWORD& w);
  89.         bool readUDWORD(gsUDWORD& d);
  90.         bool error();
  91.  
  92.         BLKSTR *m_blocks;
  93.  
  94.         int m_scan_y;
  95.  
  96.     public:
  97.  
  98.         CLevel();
  99.         ~CLevel();
  100.  
  101.         gsCMap m_back_layer;
  102.         gsCMap m_front_layer;
  103.  
  104.         gsCTiledImage m_image;
  105.  
  106.         bool load(const char *filename,const char *levels_directory,const char *graphics_directory);
  107.  
  108.         void reset();
  109.  
  110.         void destroy();
  111. };
  112.  
  113. //-------------------------------------------------------------
  114.  
  115. #endif
  116.