home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / source / apilot.lha / APilot / APilot_Opt / common.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-12-12  |  6.9 KB  |  148 lines

  1. /***************************************************************************
  2.  *
  3.  * common.h -- Common structures needed in several files.
  4.  *
  5.  *-------------------------------------------------------------------------
  6.  * Authors: Casper Gripenberg  (casper@alpha.hut.fi)
  7.  *          Kjetil Jacobsen  (kjetilja@stud.cs.uit.no)    
  8.  *
  9.  */
  10.  
  11. #ifndef __COMMON_H__
  12. #define __COMMON_H__
  13.  
  14. #include "defs.h"
  15. #include "map.h"
  16. #include "prefs.h"
  17.  
  18. /* Force use of new variable names to help prevent errors  */
  19. #define INTUI_V36_NAMES_ONLY
  20.  
  21. /* Use lowest non-obsolete version that supplies the functions needed. */
  22. #define INTUITION_REV 39
  23. #define GRAPHICS_REV  39
  24.  
  25. struct Coordinates {
  26.   int x;
  27.   int y;
  28. };
  29.  
  30. typedef struct _AFuelPod {
  31.   struct _AFuelPod *next;
  32.   struct Coordinates mapos;    /* Map coordinates for this fuelpod.         */
  33.   struct Coordinates pos;      /* Position of center of fuelpod.            */
  34.   int    fuelcount;          
  35.   int    p_fuel[MY_BUFFERS];   /* For double buffering...                   */
  36.   int    fuel;                 /* Amount of fuel left in this fuelpod.      */
  37. } AFuelPod;
  38.  
  39. typedef enum { C_UP, C_DN, C_LF, C_RG, C_NONE } cdir_t;
  40. typedef enum { INACTIVE, ACTIVE, DEAD } cstate_t;
  41.  
  42. typedef struct _ACannon {
  43.   struct   _ACannon *next;
  44.   struct   Coordinates mapos;  /* Map coordinates for this cannon.          */
  45.   struct   Coordinates pos;    /* Position of center of cannon.             */
  46.   cdir_t   cdir;               /* Cannon direction.                         */
  47.   cstate_t cstate;             /* Cannon state.                             */
  48.   int    deadcount;            /* For how many frames will this c. be dead  */
  49.   int    firedelay;            /* How many frames before next shot.         */
  50. } ACannon;  
  51.  
  52. typedef enum { EXPLOSION, BULLET, EXHAUST, CANNON_SHOT } ptype;
  53. typedef enum { RED, BLUE, WHITE } col_t;
  54.  
  55. typedef struct _APoint {
  56.   struct _APoint *next;      /* Next & prev point in chain                */
  57.   struct _APoint *prev;      
  58.   struct Coordinates p_pos[MY_BUFFERS];  /* Prev. point positions         */
  59.   struct Coordinates pos;    /* Current point position                    */
  60.   ptype  type;               /* Type of point.                            */
  61.   col_t  color;              /* Color of point.                           */
  62.   BOOL   draw_it;            /* True if this point is inside scrn limits  */
  63.   int    mass;               /* Mass, used in collisions.                 */
  64.   int    xcount;
  65.   int    ycount;
  66.   int    xvel;
  67.   int    yvel;
  68.   int    life;               /* Point life, decreases every frame         */
  69.   UWORD drawn;               /* The bits in this variable tells us in     */
  70.                              /* which buffers this point has been drawn   */
  71.                              /* so that we can remove it later.           */
  72.   cdir_t lastmap;            /* For better collision detection on cannons.*/
  73.   struct Coordinates lpos;   /* Used in conjunction with lastmap.         */
  74. } APoint;
  75.  
  76. typedef enum { NO, YES, LEFT, RIGHT } turn_t;
  77.  
  78. typedef struct _AShip {
  79.   struct   _AShip *next;       /* Next & prev ship in chain                 */
  80.   struct   _Aship *prev;
  81.   int      shapesize;          /* How many points in shape                  */
  82.   struct   Coordinates *shape; /* Defines the shape                         */
  83.   struct   Coordinates *currc; /* Rotated coordinates                       */
  84.   struct   Coordinates **prevc;/* Previous coordinates for double-buffering */
  85.   struct   Coordinates pos;    /* Current position                          */
  86.   struct   Coordinates p_pos[MY_BUFFERS];  /* For double-buffering          */
  87.   struct   Coordinates base;   /* Base position in real coordinates.        */
  88.   BOOL     s_drawn[MY_BUFFERS];       /* For double-buffering...(ship)      */
  89.   BOOL     draw_it;            /* Used for non-local ships.                 */
  90.   int      mass;               /* Mass, used in collisions.                 */
  91.   BOOL     fueling;            /* True when ship is fueling from a fuelpod. */
  92.   AFuelPod *fpod;              /* The pod we are currently fueling from.    */
  93.   BOOL     f_drawn[MY_BUFFERS];       /* Double buffering..aagh.(fuelline)  */ 
  94.   struct   Coordinates fuell[MY_BUFFERS];  /* The fuelline is stored here.  */
  95.   int      fuel;               /* Gots to have fuel to move.                */
  96.   int      fuelcount;          /* Used with integer math.                   */
  97.   int      status;             /* What this player is doing right now.      */
  98.   int      xcount;             /* Counters for position incr/decr           */ 
  99.   int      ycount;
  100.   int      xvel;               /* Velocity x-dir                            */
  101.   int      yvel;               /* Velocity y-dir                            */
  102.   BOOL     local;              /* Ship is controlled from this computer?    */
  103.   BOOL     shields;            /* True if shields are up.                   */
  104.   BOOL     fireing;            /* True if fireing                           */
  105.   int      bul_life;           /* Bullet life                               */
  106.   int      buldist;            /* Distance for bullets from ship center     */
  107.   int      fw_nbul;            /* Number of forward bullets                 */
  108.   int      bw_nbul;            /* Number of backward bullets                */
  109.   BOOL     thrusting;          /* True if thrusting                         */
  110.   int      exhcount;           /* How many particles/thrust sequence < 5    */
  111.   int      exhwidth;           /* Width of the exhaust                      */
  112.   int      exhdist;            /* Distance for exhaust from ship center     */
  113.   int      exhlife;            /* How many frames the avg. 'fume' will live */                
  114.   int      power;              /* Thrust power                              */
  115.   turn_t   turning;            /* Is the ship turning?.                     */ 
  116.   int      rotspeed;           /* Rotation speed                            */
  117.   int      angle;              /* Ship angle in degrees                     */
  118. } AShip;
  119.  
  120. typedef struct _ABase {
  121.   struct _ABase *next;
  122.   struct Coordinates mapos;    /* Map coordinates of this base.            */
  123.   AShip  *owner;               /* Owner of this base.                      */
  124. } ABase;
  125.  
  126. /*
  127.  * This will be a common structure in most of the files, through this
  128.  * structure all important game parameters can then be accessed.
  129.  */
  130. typedef struct _AWorld {
  131.   int       Width, Height;     /* Width and height of our world.           */
  132.   int       gravity; 
  133.   AShip     *players;
  134.   ABase     *bases;
  135.   APoint    *points;
  136.   ACannon   *cannons;
  137.   AFuelPod  *fuelpods;
  138.   MAP_Point **map_points;
  139.   /*---- Local stuff after this ----*/
  140.   UWORD     framerate;      /* Current framerate */
  141.   AShip     *local_ship;
  142.   BOOL      hudon;          /* True everytime the hud should be turned on. */
  143.   struct    Coordinates p_sv[MY_BUFFERS]; /* Prev. speed vector positions  */
  144.   struct    BitMap *shld_bm;              /* Bitmap of shield.             */
  145. } AWorld;
  146.  
  147. #endif
  148.