home *** CD-ROM | disk | FTP | other *** search
/ Teach Yourself Game Programming in 21 Days / TYGAMES_R.ISO / source / appendix / graph4.h < prev    next >
Text File  |  1994-05-10  |  3KB  |  101 lines

  1.  
  2. // GRAPH4.H
  3.  
  4. // D E F I N E S  ////////////////////////////////////////////////////////////
  5.  
  6. #define SPRITE_WIDTH      16
  7. #define SPRITE_HEIGHT     16
  8.  
  9. #define MAX_SPRITE_FRAMES 24
  10. #define SPRITE_DEAD       0
  11. #define SPRITE_ALIVE      1
  12. #define SPRITE_DYING      2
  13.  
  14. // S T R U C T U R E S ///////////////////////////////////////////////////////
  15.  
  16. typedef struct pcx_header_typ
  17.         {
  18.         char manufacturer;
  19.         char version;
  20.         char encoding;
  21.         char bits_per_pixel;
  22.         int x,y;
  23.         int width,height;
  24.         int horz_res;
  25.         int vert_res;
  26.         char ega_palette[48];
  27.         char reserved;
  28.         char num_color_planes;
  29.         int bytes_per_line;
  30.         int palette_type;
  31.         char padding[58];
  32.  
  33.         } pcx_header, *pcx_header_ptr;
  34.  
  35.  
  36. typedef struct pcx_picture_typ
  37.         {
  38.         pcx_header header;
  39.         RGB_color palette[256];
  40.         char far *buffer;
  41.  
  42.         } pcx_picture, *pcx_picture_ptr;
  43.  
  44.  
  45. typedef struct sprite_typ
  46.         {
  47.         int x,y;            // position of sprite
  48.         int x_old,y_old;    // old position of sprite
  49.         int width,height;   // dimensions of sprite in pixels
  50.         int anim_clock;     // the animation clock
  51.         int anim_speed;     // the animation speed
  52.         int motion_speed;   // the motion speed
  53.         int motion_clock;   // the motion clock
  54.  
  55.         char far *frames[MAX_SPRITE_FRAMES]; // array of pointers to the images
  56.         int curr_frame;                      // current frame being displayed
  57.         int num_frames;                      // total number of frames
  58.         int state;                           // state of sprite, alive, dead...
  59.         char far *background;                // whats under the sprite
  60.         void far *extra_data;                // an auxialliary pointer to more
  61.                                              // data if needed
  62.         } sprite, *sprite_ptr;
  63.  
  64.  
  65. // E X T E R N A L S /////////////////////////////////////////////////////////
  66.  
  67. // G L O B A L S  ////////////////////////////////////////////////////////////
  68.  
  69. extern unsigned int sprite_width;
  70. extern unsigned int sprite_height;
  71.  
  72. // P R O T O T Y P E S ///////////////////////////////////////////////////////
  73.  
  74. void PCX_Init(pcx_picture_ptr image);
  75.  
  76. void PCX_Load(char *filename, pcx_picture_ptr image,int enable_palette);
  77.  
  78. void PCX_Delete(pcx_picture_ptr image);
  79.  
  80. void PCX_Show_Buffer(pcx_picture_ptr image);
  81.  
  82. void Sprite_Init(sprite_ptr sprite,int x,int y,int ac,int as,int mc,int ms);
  83.  
  84. void Sprite_Delete(sprite_ptr sprite);
  85.  
  86. void PCX_Grab_Bitmap(pcx_picture_ptr image,
  87.                      sprite_ptr sprite,
  88.                      int sprite_frame,
  89.                      int grab_x, int grab_y);
  90.  
  91. void Behind_Sprite(sprite_ptr sprite);
  92.  
  93. void Erase_Sprite(sprite_ptr sprite);
  94.  
  95. void Draw_Sprite(sprite_ptr sprite);
  96.  
  97. unsigned char Get_Pixel(int x,int y);
  98.  
  99. int Sprite_Collide(sprite_ptr sprite_1, sprite_ptr sprite_2);
  100.  
  101.