home *** CD-ROM | disk | FTP | other *** search
- head 1.3;
- access;
- symbols;
- locks; strict;
- comment @# @;
-
-
- 1.3
- date 98.04.19.17.36.50; author mds1274; state Exp;
- branches;
- next 1.2;
-
- 1.2
- date 98.04.15.16.27.04; author mds1274; state Exp;
- branches;
- next 1.1;
-
- 1.1
- date 98.04.10.17.53.49; author jgh8962; state Exp;
- branches;
- next ;
-
-
- desc
- @@
-
-
- 1.3
- log
- @*** empty log message ***
- @
- text
- @/**
- *
- * Goobie.java
- * @@author Mark G. Tacchi (mtacchi@@next.com)
- * @@version 0.8
- * Mar 18/1996
- *
- * A goobie is just a little green thing that lives within a transparent
- * shell until that shell pops.
- *
- * Goobies harm ships and bullets harm Goobies.
- *
- */
-
-
- import java.lang.Math;
- import com.next.gt.*;
-
- public class Goobie extends Actor {
-
- //
- // Gravity strength toward the ship.
- //
- private static double GRAVITATIONAL_PULL= 0.5;
-
-
- /**
- * Constructor
- */
- Goobie(Gamelication theOwner, Bigoobie explodee) {
- super();
- java.awt.Image theImage;
- java.awt.MediaTracker tracker;
- owner= theOwner;
-
- theImage = owner.getImage(owner.getCodeBase(), "images/goobie.gif");
- tracker = new java.awt.MediaTracker(theOwner);
- tracker.addImage(theImage, 0);
-
- try{
- tracker.waitForID(0);
- }
- catch (InterruptedException e) {}
-
- x= (int)(explodee.x - (width - explodee.width)/2.0);
- y= (int)(explodee.y - (height - explodee.height)/2.0);
- velocity_x= explodee.velocity_x * Gamelication.randBetween(0.2,1.4);
- velocity_y= explodee.velocity_y * Gamelication.randBetween(0.2,1.4);
-
- setImage (theImage);
-
- } /*Goobie()*/
-
-
- /**
- * Gravitate torwards player.
- */
- public void calculateNewPosition() {
- super.calculateNewPosition();
-
- //
- // Is the player alive?
- //
- if (((Boinkaroids)owner).player==null) return;
-
- //
- // gravitate towards player
- //
- if (x> ((Boinkaroids)owner).player.x) velocity_x-= GRAVITATIONAL_PULL;
- else velocity_x+= GRAVITATIONAL_PULL;
- if (y> ((Boinkaroids)owner).player.y) velocity_y-= GRAVITATIONAL_PULL;
- else velocity_y+= GRAVITATIONAL_PULL;
-
- } /*calculateNewPosition*/
-
-
- /**
- * Explode goobie.
- */
- public void explode(){
- //
- // play explode sound
- //
- owner.play(owner.getCodeBase(), "sounds/smack.au");
-
- //
- // give credit for hitting me, increase score
- //
- owner.scoreManager.addToScore(1000);
-
- //
- // i'm dead, i should schedule to be removed
- //
- owner.actorManager.removeActor(this);
-
- //
- // tell the Gamelication that there is one less bad guy
- //
- ((Boinkaroids)owner).removeOneBadGuy();
-
- } /*explode*/
-
-
- /**
- * Handle collision with an actor.
- */
- protected void collideWithActor (Actor theActor){
- String theActorClassName= theActor.getClass().getName();
-
- if (theActorClassName.equals("Bullet") ||
- theActorClassName.equals("Ship") ) {
- explode();
- } /*endif*/
- } /*collideWithActor*/
-
- } /*Goobie*/
- @
-
-
- 1.2
- log
- @*** empty log message ***
- @
- text
- @d99 1
- a99 1
- ((Boinkaroids)owner).badGuyCount--;
- @
-
-
- 1.1
- log
- @Initial revision
- @
- text
- @d15 1
- a15 1
- //import java.applet.Applet;
- a16 1
-
- d21 9
- a29 5
- //
- // Gravity strength toward the ship.
- //
- private static double GRAVITATIONAL_PULL= 0.5;
-
- d31 4
- a34 5
- super();
- java.awt.Image theImage;
- java.awt.MediaTracker tracker;
-
- owner= theOwner;
- d36 3
- a38 2
- theImage = owner.getImage(owner.getCodeBase(), "images/goobie.gif");
- tracker = new java.awt.MediaTracker(theOwner);
- d40 1
- a40 2
- tracker.addImage(theImage, 0);
- try{
- d42 2
- a43 2
- }
- catch (InterruptedException e) {}
- d45 4
- a48 4
- x= (int)(explodee.x - (width - explodee.width)/2.0);
- y= (int)(explodee.y - (height - explodee.height)/2.0);
- velocity_x= explodee.velocity_x * Gamelication.randBetween(0.2,1.4);
- velocity_y= explodee.velocity_y * Gamelication.randBetween(0.2,1.4);
- d50 1
- a50 1
- setImage (theImage);
- d59 1
- a59 1
- super.calculateNewPosition();
- d61 4
- a64 4
- //
- // Is the player alive?
- //
- if (((Boinkaroids)owner).player==null) return;
- d66 7
- a72 7
- //
- // gravitate towards player
- //
- if (x> ((Boinkaroids)owner).player.x) velocity_x-= GRAVITATIONAL_PULL;
- else velocity_x+= GRAVITATIONAL_PULL;
- if (y> ((Boinkaroids)owner).player.y) velocity_y-= GRAVITATIONAL_PULL;
- else velocity_y+= GRAVITATIONAL_PULL;
- a76 1
-
- d80 5
- a84 6
- public void explode()
- {
- //
- // play explode sound
- //
- owner.play(owner.getCodeBase(), "sounds/smack.au");
- d86 4
- a89 4
- //
- // give credit for hitting me, increase score
- //
- owner.scoreManager.addToScore(1000);
- d91 4
- a94 4
- //
- // i'm dead, i should schedule to be removed
- //
- owner.actorManager.removeActor(this);
- d96 4
- a99 4
- //
- // tell the Gamelication that there is one less bad guy
- //
- ((Boinkaroids)owner).badGuyCount--;
- a103 2
-
-
- d107 2
- a108 3
- protected void collideWithActor (Actor theActor)
- {
- String theActorClassName= theActor.getClass().getName();
- d110 4
- a113 5
- if (theActorClassName.equals("Bullet") ||
- theActorClassName.equals("Ship") ) {
- explode();
- } /*endif*/
-
- @
-