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.15.01; 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
- @/**
- *
- * Asteroid.java
- * @@author Mark G. Tacchi (mtacchi@@next.com)
- * @@version 0.8
- * Mar 11/1996
- *
- * A generic Asteroid class which handles varying sizes of asteroids. Images
- * should have filenames with corresponding S, M, L, and G appended to them
- * (example asteroidM.gif).
- * This Actor collides with Bullets and Ships. It is responsible for creating
- * an explosion object.
- *
- */
-
-
- import java.lang.Math;
-
- import com.next.gt.*;
-
- public class Asteroid extends Actor {
-
- //
- // Size of the Asteroid.
- //
- public static final int SMALL_SIZE= 0,
- MEDIUM_SIZE= 1,
- LARGE_SIZE= 2;
- int size;
-
- //
- // The filename prefix.
- //
- String name;
-
- Asteroid(Gamelication theOwner, Asteroid explodee, String theName, int theSize) {
- super();
-
- String[] theImageName= {"S", "M", "L", "G"};
- java.awt.Image theImage;
-
- owner= theOwner;
- size= theSize;
- name= theName;
-
- if (theSize==LARGE_SIZE) {
- x= (Math.random()*512);
- y= (Math.random()*512);
- velocity_x= (double)((int)Gamelication.randBetween(0.5,1.5)*2 - 1) * Gamelication.randBetween(8.,32.);
- velocity_y= (double)((int)Gamelication.randBetween(0.5,1.5)*2 - 1) * Gamelication.randBetween(8.,32.);
- }
- else {
- x= explodee.x;
- y= explodee.y;
- velocity_x= explodee.velocity_x * Gamelication.randBetween(0.6,1.4);
- velocity_y= explodee.velocity_y * Gamelication.randBetween(0.6,1.4);
-
- }
- theImage = owner.getImage(owner.getCodeBase(), "images/" +theName + theImageName[theSize] + ".gif");
- setImage (theImage, 4, 32);
- currentFrame= (int)Gamelication.randBetween(0, numFrames);
- } /*Asteroid()*/
-
-
- /**
- * Explode asteroid.
- */
- public void explode()
- {
- Explosion anExplosion;
-
- //
- // create explosion if smallest asteroid
- //
- if (size==SMALL_SIZE) {
- anExplosion= new Explosion(owner, this);
- owner.actorManager.addActor(anExplosion);
- }
- else {
- owner.play(owner.getCodeBase(), "sounds/explode1.au");
- }
-
- //
- // split off into smaller bits
- //
- if (size==LARGE_SIZE) {
- for (int i=0; i<2; i++) {
- owner.actorManager.addActor(new Asteroid(owner, this, name,
- MEDIUM_SIZE));
- ((Boinkaroids)owner).addOneBadGuy();
- } /*next_i*/
- }
- else if (size==MEDIUM_SIZE) {
- for (int i=0; i<2; i++) {
- owner.actorManager.addActor(new Asteroid(owner, this, name,
- SMALL_SIZE));
- ((Boinkaroids)owner).addOneBadGuy();
- } /*next_i*/
- }
-
- //
- // give credit for hitting me, increase score
- //
- owner.scoreManager.addToScore((2-size) * 200 + 100);
-
- //
- // 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*/
-
- } /*Asteroid*/
- @
-
-
- 1.2
- log
- @*** empty log message ***
- @
- text
- @d90 1
- a90 1
- ((Boinkaroids)owner).badGuyCount++;
- d97 1
- a97 1
- ((Boinkaroids)owner).badGuyCount++;
- d114 1
- a114 1
- ((Boinkaroids)owner).badGuyCount--;
- @
-
-
- 1.1
- log
- @Initial revision
- @
- text
- @d16 1
- a16 1
- //import java.applet.Applet;
- d23 5
- a27 5
- //
- // Size of the Asteroid.
- //
- public static final int SMALL_SIZE= 0,
- MEDIUM_SIZE= 1,
- d29 1
- a29 1
- int size;
- d31 4
- a34 4
- //
- // The filename prefix.
- //
- String name;
- d37 1
- a37 1
- super();
- d39 2
- a40 2
- String[] theImageName= {"S", "M", "L", "G"};
- java.awt.Image theImage;
- d42 3
- a44 3
- owner= theOwner;
- size= theSize;
- name= theName;
- d46 11
- a56 11
- if (theSize==LARGE_SIZE) {
- x= (Math.random()*512);
- y= (Math.random()*512);
- velocity_x= (double)((int)Gamelication.randBetween(0.5,1.5)*2 - 1) * Gamelication.randBetween(8.,32.);
- velocity_y= (double)((int)Gamelication.randBetween(0.5,1.5)*2 - 1) * Gamelication.randBetween(8.,32.);
- }
- else {
- x= explodee.x;
- y= explodee.y;
- velocity_x= explodee.velocity_x * Gamelication.randBetween(0.6,1.4);
- velocity_y= explodee.velocity_y * Gamelication.randBetween(0.6,1.4);
- d58 4
- a61 6
- }
- theImage = owner.getImage(owner.getCodeBase(), "images/" +theName + theImageName[theSize] + ".gif");
- setImage (theImage, 4, 32);
-
- currentFrame= (int)Gamelication.randBetween(0, numFrames);
-
- a64 1
-
- d70 1
- a70 1
- Explosion anExplosion;
- d72 10
- a81 11
- //
- // create explosion if smallest asteroid
- //
- if (size==SMALL_SIZE) {
- anExplosion= new Explosion(owner, this);
- owner.actorManager.addActor(anExplosion);
- }
- else {
- owner.play(owner.getCodeBase(), "sounds/explode1.au");
- }
-
- d83 17
- a99 8
- //
- // split off into smaller bits
- //
- if (size==LARGE_SIZE) {
- for (int i=0; i<2; i++) {
- owner.actorManager.addActor(new Asteroid(owner, this, name, MEDIUM_SIZE));
- ((Boinkaroids)owner).badGuyCount++;
- } /*next_i*/
- d101 4
- a104 7
- }
- else if (size==MEDIUM_SIZE) {
- for (int i=0; i<2; i++) {
- owner.actorManager.addActor(new Asteroid(owner, this, name, SMALL_SIZE));
- ((Boinkaroids)owner).badGuyCount++;
- } /*next_i*/
- }
- d106 4
- d111 4
- a114 15
- //
- // give credit for hitting me, increase score
- //
- owner.scoreManager.addToScore((2-size) * 200 + 100);
-
- //
- // 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).badGuyCount--;
-
- a117 1
-
- d121 6
- a126 3
- protected void collideWithActor (Actor theActor)
- {
- String theActorClassName= theActor.getClass().getName();
- a127 5
- if (theActorClassName.equals("Bullet") ||
- theActorClassName.equals("Ship") ) {
- explode();
- } /*endif*/
-
- @
-