home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / alt / sources / 2611 / control_ship.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-11-23  |  1.4 KB  |  90 lines

  1. #ifndef lint
  2. static    char    sccsid[] = "@(#)control_ship.c 1.1 92/05/28 SMI" ;
  3.     /* from control_ship.c 1.3 90/07/23 SMI */
  4. #endif
  5.  
  6. /*
  7.  * Copyright (c) 1986 by Sun Microsystems, Inc.
  8.  */
  9.  
  10. /*
  11.  * this file contains specific control stuff:
  12.  *
  13.  * control_ship()
  14.  *    read control inputs and act accordingly
  15.  *
  16.  */
  17.  
  18.  
  19. #include <stdio.h>
  20. #include <math.h>
  21. #include "graphics.h"
  22. #include "dstar.h"
  23. #include "object_types.h"
  24.  
  25.  
  26.  
  27. extern    int    debug_level ;
  28.  
  29.  
  30.  
  31.  
  32. /****
  33.  *
  34.  * read control inputs, update ship's position/velocity/"up" vectors
  35.  *
  36.  ****/
  37.  
  38.  
  39. control_ship()
  40. {
  41.     Pt3d    new_delta ;
  42.  
  43.     /* read mouse input */
  44.  
  45.     if(!auto_pilot)
  46.     {
  47.       new_delta.x = VIEWSCALE*(Mouse_ax - .5) ;
  48.       new_delta.y = VIEWSCALE*(Mouse_ay - .5) ;
  49.  
  50.       adjust_vector(Me,&new_delta) ;
  51.  
  52.       if(mouse_control)
  53.         Me->Delta = new_delta ;
  54.       else
  55.       {
  56.         Me->Delta.x = 0.0 ;
  57.         Me->Delta.y = 0.0 ;
  58.       }
  59.  
  60.       if(Middle_But)
  61.         Me->flags |= LASER_FLAG ;
  62.       else
  63.         Me->flags &= ~LASER_FLAG ;
  64.  
  65.       if(Side_9)
  66.         Me->Delta.z = -ROLL_RATE ;
  67.       else if (Side_10)
  68.         Me->Delta.z = ROLL_RATE ;
  69.       else
  70.         Me->Delta.z = 0.0 ;
  71.     }
  72.     else
  73.     {
  74.       auto_control(Me, AUTO_RANGE, MAX_TURN, MAX_SLEW) ;
  75.       if(Middle_But)
  76.         Me->flags |= LASER_FLAG ;
  77.  
  78.       if(Side_9)
  79.         Me->Delta.z = -0.3 ;
  80.       else if (Side_10)
  81.         Me->Delta.z = 0.3 ;
  82.       else
  83.         Me->Delta.z = 0.0 ;
  84.     }
  85.  
  86.     /* transform delta from ship coords to universal coords */
  87.  
  88.     adjust_vectors(Me) ;
  89. }
  90.