home *** CD-ROM | disk | FTP | other *** search
/ Chip Hitware 7 B / CHIP_HITWARE_7B.iso / Gry / Orbit / src / waypoint.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-08-19  |  1.8 KB  |  105 lines

  1. /*
  2.  
  3. ORBIT, a freeware space combat simulator
  4. Copyright (C) 1999  Steve Belczyk <steve1@genesis.nred.ma.us>
  5.  
  6. This program is free software; you can redistribute it and/or
  7. modify it under the terms of the GNU General Public License
  8. as published by the Free Software Foundation; either version 2
  9. of the License, or (at your option) any later version.
  10.  
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with this program; if not, write to the Free Software
  18. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  19.  
  20. */
  21.  
  22. #include "orbit.h"
  23.  
  24. /*
  25.  *  Routines to implement waypoints
  26.  */
  27.  
  28. InitWaypoints()
  29. /*
  30.  *  Reset waypoints
  31.  */
  32. {
  33.     int w;
  34.  
  35.     nwaypoints = 0;
  36.     player.waypoint = (-1);
  37.  
  38.     for (w=0; w<NWAYPOINTS; w++)
  39.     {
  40.         waypoint[w].pos[0] = 0.0;
  41.         waypoint[w].pos[1] = 0.0;
  42.         waypoint[w].pos[2] = 0.0;
  43.     }
  44. }
  45.  
  46. AddWaypoint (v)
  47. double v[3];
  48. /*
  49.  *  Define a new waypoint
  50.  */
  51. {
  52.     if (nwaypoints == NWAYPOINTS)
  53.     {
  54.         Log ("AddWaypoint: Too many waypoints.  Increase NWAYPOINTS in orbit.h");
  55.         return;
  56.     }
  57.  
  58.     Vset (waypoint[nwaypoints].pos, v);
  59.     nwaypoints++;
  60. }
  61.  
  62. NextWaypoint()
  63. /*
  64.  *  Advance to next waypoint
  65.  */
  66. {
  67.     if (nwaypoints == 0) return;
  68.  
  69.     if (player.waypoint == (-1))
  70.     {
  71.         player.waypoint = 0;
  72.         return;
  73.     }
  74.  
  75.     player.waypoint++;
  76.  
  77.     if (player.waypoint == nwaypoints)
  78.     {
  79.         player.waypoint = (-1);
  80.         return;
  81.     }
  82. }
  83.  
  84. PrevWaypoint()
  85. /*
  86.  *  Back to previous waypoint
  87.  */
  88. {
  89.     if (nwaypoints == 0) return;
  90.  
  91.     if (player.waypoint == 0)
  92.     {
  93.         player.waypoint = (-1);
  94.         return;
  95.     }
  96.  
  97.     if (player.waypoint == (-1))
  98.     {
  99.         player.waypoint = nwaypoints - 1;
  100.         return;
  101.     }
  102.  
  103.     player.waypoint--;
  104. }
  105.