home *** CD-ROM | disk | FTP | other *** search
/ Java 1.2 How-To / JavaHowTo.iso / 3rdParty / Gamelication / examples / Boinkaroids / Explosion.java < prev    next >
Encoding:
Java Source  |  1998-04-20  |  1.1 KB  |  57 lines

  1. /**
  2.  *
  3.  * Explosion.java
  4.  * @author    Mark G. Tacchi (mtacchi@next.com) 
  5.  * @version    0.8
  6.  * Mar 12/1996
  7.  *
  8.  * A simple explosion Actor.
  9.  *
  10. */
  11.  
  12. import java.awt.Graphics;
  13. import com.next.gt.*;
  14.  
  15. public class Explosion extends Actor {
  16.   
  17. Explosion(Gamelication theOwner, Actor explodee) {
  18.     super();
  19.     java.awt.Image        theImage;
  20.     java.awt.MediaTracker    tracker;
  21.   
  22.     owner= theOwner;
  23.  
  24.     //
  25.     // play explosion sound
  26.     //
  27.     owner.play(owner.getCodeBase(), "sounds/explode1.au");
  28.   
  29.     //
  30.     // load the image
  31.     //
  32.     theImage= owner.getImage(owner.getCodeBase(), "images/explosions.gif");
  33.   
  34.     //
  35.     // set up key variables
  36.     //
  37.     setImage (theImage, 60, 60, 4, 16);
  38.     x= (explodee.x - (width - explodee.width)/2.0);
  39.     y= (explodee.y - (height - explodee.height)/2.0);
  40.     velocity_x= explodee.velocity_x;
  41.     velocity_y= explodee.velocity_y;
  42.   
  43. } /*Explosion()*/
  44.  
  45.  
  46. /**
  47.  * Calculates the current frame.  Flip through frames sequentially
  48.  * and die when completed.
  49.  */
  50. public void calculateCurrentFrame() {
  51.     if (++currentFrame>=numFrames) {
  52.         owner.actorManager.removeActor(this);
  53.     } /*endif*/
  54. } /*calculateCurrentFrame*/
  55.  
  56. } /*Explosion*/
  57.