home *** CD-ROM | disk | FTP | other *** search
/ The Amiga Game Guide / AmigaGameGuide_CD.iso / Amiga / PD-Games / DogFight! / Sources.lha / DogFight!_class9.h < prev    next >
C/C++ Source or Header  |  1994-05-21  |  7KB  |  192 lines

  1. /********************************************************************
  2. ×××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××
  3. ##
  4. ##      DogFight!_class.h
  5. ##
  6. ## Defines Fighters, Shots, Coords, and functions on these objects.
  7. ##
  8. ## V0.6 28-FEB-94
  9. ##
  10. ×××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××
  11. *********************************************************************/
  12.  
  13. #include <string.h>
  14. #include <stddef.h>
  15. #include <intuition/intuition.h>
  16. #include <libraries/mathffp.h>
  17.  
  18. #include <clib/graphics_protos.h>
  19. #include <clib/intuition_protos.h>
  20. #include <clib/mathffp_protos.h>
  21. #include <clib/mathtrans_protos.h>
  22. #include <clib/alib_protos.h>
  23.  
  24. #include <proto/intuition.h>
  25. #include <proto/graphics.h>
  26. #include <proto/mathffp.h>
  27. #include <proto/mathtrans.h>
  28.  
  29. extern ULONG scrn_left, scrn_right, scrn_top, scrn_bottom;
  30. extern struct TextAttr topaz8;
  31. extern struct IntuiText PLT[];
  32. extern const int slow[];
  33. extern const int medium[];
  34. extern const int fast[];
  35. extern const int shotspeed[];
  36. extern int game_speed;
  37. extern BOOL vulnerability;
  38.  
  39. /******************************************
  40. ×××××××××××××××××××××××××××××××××××××××××××
  41.         The COORD class handles all of our
  42.         screen positioning, and is screen
  43.         size sensitive (assuming we set the
  44.         correct variables in the DogFight!.h)
  45.         It handles inc/decrementing (movement),
  46.         wraparound, and keeps track of the
  47.         position in floating point.
  48. ×××××××××××××××××××××××××××××××××××××××××××
  49. ******************************************/
  50.  
  51. class COORD {
  52.         public:
  53.                 float xinc, yinc;
  54.                 float fx, fy;
  55.                 int x, y;
  56.  
  57.                 COORD();
  58.  
  59.                 void inc();
  60.                 //      Increment the coords and check for
  61.                 //      wraparound.
  62.  
  63.                 int dist(COORD);
  64.                 //      Returns the distance between itself
  65.                 //      and the supplied coordinate.
  66.  
  67.                 void set_f(float, float);
  68.  
  69. };
  70.  
  71. /******************************************
  72. ×××××××××××××××××××××××××××××××××××××××××××
  73.         Our SHOT class.  Since Jets don't
  74.         collide, this is the only way to shoot
  75.         down enemy craft =-).
  76. ×××××××××××××××××××××××××××××××××××××××××××
  77. ******************************************/
  78.  
  79. class SHOT {
  80.         COORD c, old_c;                         // Coords for location
  81.         float dir;                                              // direction of travel
  82.         int dist;                                               // dist-ance travelled
  83.  
  84.         void erase(struct RastPort *);
  85.         void draw(struct RastPort *);
  86.  
  87.         public:
  88.                 int underway;                                   // underway if active
  89.  
  90.                 SHOT();
  91.                 void bang(COORD, float, int);
  92.  
  93.                 void move(struct RastPort *);
  94.                 //      Responsible for erasing, repositioning,
  95.                 //      and redrawing the shot, as well
  96.                 //      as checking to see if the shot has moved
  97.                 //      it's maximum range.
  98.                 //      See FIGHTER::move().
  99.  
  100.                 BOOL collide(COORD);
  101.                 //      Check for collision with the supplied
  102.                 //      coordinate.
  103.                 //      Returns TRUE if collision, and if so,
  104.                 //      stops shot.
  105.  
  106.                 void stop();
  107. };
  108.  
  109. /******************************************
  110. ×××××××××××××××××××××××××××××××××××××××××××
  111.         The Jet class.
  112.         We have:
  113.         * 3 coordinates for double-
  114.         buffering (to remember where we _were_),
  115.         * dir for direction, in rads (bleh!)
  116.         * turnrad for rate of turn
  117.         * 2 flags (rf&lf) for remembering in
  118.         which direction we're turning
  119.         * explosions for how big and long we
  120.         explode
  121.         * color to identify the Jet
  122.         * speed for how fast the Jet is
  123.         * deadtime to keep track of how long
  124.         we have to go before we're resurected
  125.         * txt for our Jet identification number.
  126.         * alive for whether we've been shot
  127.         * in_play to tell if the Jet is being
  128.         used
  129.         * killscore for how many jets we've
  130.         shot down
  131.         * and our very own SHOT.
  132. ×××××××××××××××××××××××××××××××××××××××××××
  133. ******************************************/
  134.  
  135. class FIGHTER {
  136.         COORD c, old_c;                                         // where to draw and erase
  137.         float dir, turnrad;                                     // direction and turn radius
  138.         BOOL rf, lf;                                                    // if turning right or left
  139.         int explosions, deadtime;                       // counters for non-flight time =-)
  140.         int color, speed;                                               // color and speed of the Jet
  141.         struct IntuiText *txt;                          // the Jet's ID number
  142.         BOOL shootable;                                         // starttime invulnerability
  143.  
  144.         void draw(struct RastPort *);
  145.         void draw_explode(struct RastPort *);
  146.  
  147.         public:
  148.                 BOOL alive, in_play;                            // if alive, or even in game
  149.                 int killscore;                                          // number of enemy kills
  150.                 SHOT shot;                                                      // the (renewable) missile
  151.  
  152.                 void erase(struct RastPort *);
  153.                 //      Quick erase of the fighter shape.
  154.                 //      It would be better to erase just the
  155.                 //      shape instead of a block fill, but
  156.                 //      it takes too long.
  157.  
  158.                 void move(struct RastPort *);
  159.                 //      Responsible for erasing, calculating
  160.                 //      the new position, and drawing the Jet
  161.                 //      in the supplied RastPort.  Assumes that
  162.                 //      we're double buffered; IE, that we're
  163.                 //      drawing on exactly two screens (hence
  164.                 //      the c, old_c, and oold_c coordinates).
  165.                 //      Also calls the explosion routines if
  166.                 //      the Jet is in the process of dying.
  167.  
  168.                 void init(int, int);
  169.                 //      Set up Jet values.
  170.                 //      - 'a' is the player number,
  171.                 //      - 'perf' is the Jet type option set in
  172.                 //      the prefs window.
  173.                 //      Player1 (a=0) starts in the upperleft
  174.                 //      screen corner, Player2 (a=1) in the
  175.                 //      upperright, etc.
  176.                 //      perf=0 means the Jet is not in play,
  177.                 //      perf=1 is a compromise Jet, etc.
  178.  
  179.                 void right();
  180.                 void left();
  181.                 void fire();
  182.  
  183.                 BOOL collide(SHOT *);
  184.                 //      Checks to see if the Jet has collided
  185.                 //      with the supplied SHOT.
  186.  
  187.                 void resurect(int, int);
  188.                 //      Keeps the Jet out of play for a
  189.                 //      certain amount of time (deadtime loops),
  190.                 //      and then starts him up again.
  191. };
  192.