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

  1. #ifndef lint
  2. static    char    sccsid[] = "@(#)create_eship.c 1.1 92/05/28 SMI" ;
  3.     /* from create_eship.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 generates the graphic description of an enemy fighter
  12.  *
  13.  */
  14.  
  15.  
  16. #include <stdio.h>
  17. #include <math.h>
  18. #include "graphics.h"
  19. #include "dstar.h"
  20. #include "object_types.h"
  21. #include "line_object.h"
  22. #include "bsp_object.h"
  23.  
  24. extern    int    debug_level ;
  25.  
  26.  
  27.  
  28.  
  29. /* these routines create a description for an enemy fighter */
  30.  
  31.  
  32. void
  33. init_fighter1(index)
  34.     int    index ;
  35. {
  36.  
  37. static    XYZF    fighter_1[] = {
  38. #include "fighter1_line.h"
  39.     } ;
  40.  
  41. #include "fighter1_bsp.h"
  42.  
  43.     Object_Desc    *desc1, *desc2 ;
  44.  
  45.     desc1 = (Object_Desc *) malloc(sizeof(Object_Desc)) ;
  46.     desc2 = (Object_Desc *) malloc(sizeof(Object_Desc)) ;
  47.  
  48.     if(desc1 && desc2)
  49.     {
  50.       descriptions[index] = desc1 ;
  51.  
  52.       desc1->thresh = 100.0*100.0 ;
  53.       desc1->next = desc2 ;
  54.       desc1->type = LINE_DRAWING ;
  55.       desc1->first = (caddr_t) fighter_1 ;
  56.  
  57.       desc2->thresh = 0.0 ;
  58.       desc2->next = NULL ;
  59.       desc2->type = BSP_TREE ;
  60.       desc2->first = (caddr_t) &FIGHTER1_TOP ;
  61.     }
  62.     else
  63.     {
  64.       perror("init_enemy_ship: malloc:") ;
  65.       exit(1) ;
  66.     }
  67. }
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74. void
  75. init_fighter2(index)
  76.     int    index ;
  77. {
  78.  
  79. static    XYZF    fighter_2[] = {
  80. #include "fighter2_line.h"
  81.     } ;
  82.  
  83. #include "fighter2_bsp.h"
  84.  
  85.     Object_Desc    *desc1, *desc2 ;
  86.  
  87.     desc1 = (Object_Desc *) malloc(sizeof(Object_Desc)) ;
  88.     desc2 = (Object_Desc *) malloc(sizeof(Object_Desc)) ;
  89.  
  90.     if(desc1 && desc2)
  91.     {
  92.       descriptions[index] = desc1 ;
  93.  
  94.       desc1->thresh = 100.0*100.0 ;
  95.       desc1->next = desc2 ;
  96.       desc1->type = LINE_DRAWING ;
  97.       desc1->first = (caddr_t) fighter_2 ;
  98.  
  99.       desc2->thresh = 0.0 ;
  100.       desc2->next = NULL ;
  101.       desc2->type = BSP_TREE ;
  102.       desc2->first = (caddr_t) &FIGHTER2_TOP ;
  103.     }
  104.     else
  105.     {
  106.       perror("init_enemy_ship: malloc:") ;
  107.       exit(1) ;
  108.     }
  109. }
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116. void
  117. init_missile(index)
  118.     int    index ;
  119. {
  120.  
  121. static    XYZF    missile[] = {
  122. #include "missile_line.h"
  123.     } ;
  124.  
  125.     Object_Desc    *desc1 ;
  126.  
  127.     desc1 = (Object_Desc *) malloc(sizeof(Object_Desc)) ;
  128.  
  129.     if(desc1 != NULL)
  130.     {
  131.       descriptions[index] = desc1 ;
  132.  
  133.       desc1->thresh = 0.0 ;
  134.       desc1->next = NULL ;
  135.       desc1->type = LINE_DRAWING ;
  136.       desc1->first = (caddr_t) missile ;
  137.     }
  138.     else
  139.     {
  140.       perror("init_missile: malloc:") ;
  141.       exit(1) ;
  142.     }
  143. }
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150. /* this routine creates an enemy ship */
  151.  
  152. Object *
  153. create_enemy_ship(index,posn,forward,up,right,delta,speed)
  154.     int    index ;
  155.     Pt3d    *posn, *forward, *up, *right, *delta ;
  156.     float    speed ;
  157. {
  158.     Object    *object = &objects[index] ;
  159.  
  160.     object->id = -1 ;
  161.     strcpy(object->name,"robot") ;
  162.     object->score = 0 ;
  163.     object->class = OBJ_PLAYER ;
  164.     object->status = OBJ_ACTIVE ;
  165.     object->flags = LASER_FLAG ;
  166.     object->Posn = *posn ;
  167.     object->Forward = *forward ;
  168.     object->Up = *up ;
  169.     object->Right = *right ;
  170.     object->Delta = *delta ;
  171.     object->Pointing = *forward ;
  172.     object->Speed = speed ;
  173.     object->description = FIGHTER1_DESC ;
  174.  
  175.     return ;
  176. }
  177.