home *** CD-ROM | disk | FTP | other *** search
/ Java 1.2 How-To / JavaHowTo.iso / 3rdParty / Gamelication / examples / Boinkaroids / RCS / Bigoobie.java,v < prev    next >
Encoding:
Text File  |  1998-04-19  |  4.5 KB  |  248 lines

  1. head    1.3;
  2. access;
  3. symbols;
  4. locks; strict;
  5. comment    @# @;
  6.  
  7.  
  8. 1.3
  9. date    98.04.19.17.36.50;    author mds1274;    state Exp;
  10. branches;
  11. next    1.2;
  12.  
  13. 1.2
  14. date    98.04.15.16.21.41;    author mds1274;    state Exp;
  15. branches;
  16. next    1.1;
  17.  
  18. 1.1
  19. date    98.04.10.17.53.49;    author jgh8962;    state Exp;
  20. branches;
  21. next    ;
  22.  
  23.  
  24. desc
  25. @@
  26.  
  27.  
  28. 1.3
  29. log
  30. @*** empty log message ***
  31. @
  32. text
  33. @/**
  34. *
  35.  * Bigoobie.java
  36.  * @@author    Mark G. Tacchi (mtacchi@@next.com) 
  37.  * @@version    0.8
  38.  * Mar 18/1996
  39. *
  40. * A Bigoobie transparent shell containing two orbiting goobies.  They take
  41.  * a number of hits and then pop.
  42.  *
  43.  * Bigoobies harm ships and bullets harm Bigoobies.
  44.  *
  45. */
  46.  
  47. import java.lang.Math;
  48. import com.next.gt.*;
  49.  
  50. public class Bigoobie extends Actor {
  51.     //
  52.     // This actor has to be hit this many times before dying.
  53.     //
  54.     public int attackResistance= 3;
  55.   
  56. Bigoobie(Boinkaroids theOwner) {
  57.     super();
  58.     java.awt.Image            theImage;
  59.     java.awt.MediaTracker        tracker;
  60.     owner= theOwner;
  61.   
  62.     theImage = owner.getImage(owner.getCodeBase(), "images/bigoobie.gif");
  63.     tracker = new java.awt.MediaTracker(theOwner);
  64.     tracker.addImage(theImage, 0);
  65.     
  66.     try{
  67.         tracker.waitForID(0);
  68.     } 
  69.     catch (InterruptedException e) {}
  70.     
  71.     x= (Math.random()*512);
  72.     y= (Math.random()*512);
  73.     velocity_x= (double)((int)Gamelication.randBetween(0.5,1.5)*2 - 1) * Gamelication.randBetween(16.,48.);
  74.     velocity_y= (double)((int)Gamelication.randBetween(0.5,1.5)*2 - 1) * Gamelication.randBetween(16.,48.);
  75.     setImage (theImage, 4, 12);
  76.     currentFrame= (int)Gamelication.randBetween(0, numFrames);
  77.  
  78. } /*Bigoobie()*/
  79.  
  80.  
  81. /**
  82.  * Explode goobie.
  83.  */
  84. public void explode()
  85. {
  86.     //
  87.     //  free the 2 goobies
  88.     //
  89.     for (int i= 0; i<2; i++) {
  90.         owner.actorManager.addActor(new Goobie(owner, this));
  91.         ((Boinkaroids)owner).addOneBadGuy();
  92.     } /*next_i*/
  93.  
  94.     //
  95.     // play explode sound
  96.     //
  97.     owner.play(owner.getCodeBase(), "sounds/pop.au");
  98.   
  99.     //
  100.     // give credit for hitting me, increase score
  101.     //
  102.     owner.scoreManager.addToScore(500);
  103.   
  104.     //
  105.     // i'm dead, i should schedule to be removed
  106.     //
  107.     owner.actorManager.removeActor(this);
  108.   
  109.     //
  110.     // tell the Gamelication that there is one less bad guy
  111.     //
  112.     ((Boinkaroids)owner).removeOneBadGuy();    
  113. } /*explode*/
  114.  
  115.  
  116. /**
  117.  * Handle collision with an actor.
  118.  */
  119. protected void collideWithActor (Actor theActor){
  120.     String theActorClassName= theActor.getClass().getName();
  121.     if (theActorClassName.equals("Bullet") ||
  122.             theActorClassName.equals("Ship") ) {
  123.         if (--attackResistance<0) {
  124.             explode();
  125.         }
  126.         else {
  127.             owner.play(owner.getCodeBase(), "sounds/futility.au");
  128.         }
  129.     } /*endif*/ 
  130. } /*collideWithActor*/
  131.  
  132. } /*Bigoobie*/
  133. @
  134.  
  135.  
  136. 1.2
  137. log
  138. @*** empty log message ***
  139. @
  140. text
  141. @d59 1
  142. a59 1
  143.         ((Boinkaroids)owner).badGuyCount++;
  144. d80 1
  145. a80 1
  146.     ((Boinkaroids)owner).badGuyCount--;    
  147. @
  148.  
  149.  
  150. 1.1
  151. log
  152. @Initial revision
  153. @
  154. text
  155. @a14 1
  156. //import java.applet.Applet;
  157. a15 1
  158.  
  159. d19 4
  160. a22 4
  161.   //
  162.   // This actor has to be hit this many times before dying.
  163.   //
  164.   public int    attackResistance= 3;
  165. d25 4
  166. a28 1
  167.   super();
  168. d30 5
  169. a34 10
  170.  java.awt.Image            theImage;
  171.   java.awt.MediaTracker        tracker;
  172.  
  173.   owner= theOwner;
  174.   
  175.   theImage = owner.getImage(owner.getCodeBase(), "images/bigoobie.gif");
  176.   tracker = new java.awt.MediaTracker(theOwner);
  177.  
  178.   tracker.addImage(theImage, 0);
  179.   try{
  180. d36 9
  181. a44 7
  182.   } 
  183.   catch (InterruptedException e) {}
  184.   x= (Math.random()*512);
  185.   y= (Math.random()*512);
  186.   velocity_x= (double)((int)Gamelication.randBetween(0.5,1.5)*2 - 1) * Gamelication.randBetween(16.,48.);
  187.   velocity_y= (double)((int)Gamelication.randBetween(0.5,1.5)*2 - 1) * Gamelication.randBetween(16.,48.);
  188.   setImage (theImage, 4, 12);
  189. a45 2
  190.   currentFrame= (int)Gamelication.randBetween(0, numFrames);
  191.  
  192. a48 1
  193.  
  194. d54 7
  195. a60 7
  196.   //
  197.   //  free the 2 goobies
  198.   //
  199.   for (int i= 0; i<2; i++) {
  200.     owner.actorManager.addActor(new Goobie(owner, this));
  201.    ((Boinkaroids)owner).badGuyCount++;
  202.   } /*next_i*/
  203. d62 4
  204. a65 4
  205.   //
  206.   // play explode sound
  207.   //
  208.   owner.play(owner.getCodeBase(), "sounds/pop.au");
  209. d67 4
  210. a70 4
  211.   //
  212.   // give credit for hitting me, increase score
  213.   //
  214.   owner.scoreManager.addToScore(500);
  215. d72 4
  216. a75 4
  217.   //
  218.   // i'm dead, i should schedule to be removed
  219.   //
  220.   owner.actorManager.removeActor(this);
  221. d77 4
  222. a80 5
  223.   //
  224.   // tell the Gamelication that there is one less bad guy
  225.   //
  226.   ((Boinkaroids)owner).badGuyCount--;
  227.       
  228. a83 2
  229.  
  230.  
  231. d87 11
  232. a97 14
  233. protected void collideWithActor (Actor theActor)
  234. {
  235.   String theActorClassName= theActor.getClass().getName();
  236.   
  237.   if (theActorClassName.equals("Bullet") ||
  238.       theActorClassName.equals("Ship") ) {
  239.       if (--attackResistance<0) {
  240.          explode();
  241.       }
  242.       else {
  243.           owner.play(owner.getCodeBase(), "sounds/futility.au");
  244.       }
  245.   } /*endif*/
  246.   
  247. @
  248.