home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / Share / Java / Gamelicator / examples / Boinkaroids / Bigoobie.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-04-20  |  2.2 KB  |  53 lines

  1. import com.next.gt.Actor;
  2. import com.next.gt.Gamelication;
  3. import java.awt.Image;
  4. import java.awt.MediaTracker;
  5.  
  6. public class Bigoobie extends Actor {
  7.    public int attackResistance = 3;
  8.  
  9.    Bigoobie(Boinkaroids var1) {
  10.       super.owner = var1;
  11.       Image var2 = super.owner.getImage(super.owner.getCodeBase(), "images/bigoobie.gif");
  12.       MediaTracker var3 = new MediaTracker(var1);
  13.       var3.addImage(var2, 0);
  14.  
  15.       try {
  16.          var3.waitForID(0);
  17.       } catch (InterruptedException var4) {
  18.       }
  19.  
  20.       super.x = Math.random() * (double)512.0F;
  21.       super.y = Math.random() * (double)512.0F;
  22.       super.velocity_x = (double)((int)Gamelication.randBetween((double)0.5F, (double)1.5F) * 2 - 1) * Gamelication.randBetween((double)16.0F, (double)48.0F);
  23.       super.velocity_y = (double)((int)Gamelication.randBetween((double)0.5F, (double)1.5F) * 2 - 1) * Gamelication.randBetween((double)16.0F, (double)48.0F);
  24.       ((Actor)this).setImage(var2, 4, 12);
  25.       super.currentFrame = (int)Gamelication.randBetween((double)0.0F, (double)super.numFrames);
  26.    }
  27.  
  28.    public void explode() {
  29.       for(int var1 = 0; var1 < 2; ++var1) {
  30.          super.owner.actorManager.addActor(new Goobie(super.owner, this));
  31.          ((Boinkaroids)super.owner).addOneBadGuy();
  32.       }
  33.  
  34.       super.owner.play(super.owner.getCodeBase(), "sounds/pop.au");
  35.       super.owner.scoreManager.addToScore(500);
  36.       super.owner.actorManager.removeActor(this);
  37.       ((Boinkaroids)super.owner).removeOneBadGuy();
  38.    }
  39.  
  40.    protected void collideWithActor(Actor var1) {
  41.       String var2 = var1.getClass().getName();
  42.       if (var2.equals("Bullet") || var2.equals("Ship")) {
  43.          if (--this.attackResistance < 0) {
  44.             this.explode();
  45.             return;
  46.          }
  47.  
  48.          super.owner.play(super.owner.getCodeBase(), "sounds/futility.au");
  49.       }
  50.  
  51.    }
  52. }
  53.