home *** CD-ROM | disk | FTP | other *** search
- import com.next.gt.Actor;
- import com.next.gt.Gamelication;
- import java.awt.Image;
-
- public class Asteroid extends Actor {
- public static final int SMALL_SIZE = 0;
- public static final int MEDIUM_SIZE = 1;
- public static final int LARGE_SIZE = 2;
- int size;
- String name;
-
- Asteroid(Gamelication var1, Asteroid var2, String var3, int var4) {
- String[] var5 = new String[]{"S", "M", "L", "G"};
- super.owner = var1;
- this.size = var4;
- this.name = var3;
- if (var4 == 2) {
- super.x = Math.random() * (double)512.0F;
- super.y = Math.random() * (double)512.0F;
- super.velocity_x = (double)((int)Gamelication.randBetween((double)0.5F, (double)1.5F) * 2 - 1) * Gamelication.randBetween((double)8.0F, (double)32.0F);
- super.velocity_y = (double)((int)Gamelication.randBetween((double)0.5F, (double)1.5F) * 2 - 1) * Gamelication.randBetween((double)8.0F, (double)32.0F);
- } else {
- super.x = var2.x;
- super.y = var2.y;
- super.velocity_x = var2.velocity_x * Gamelication.randBetween(0.6, 1.4);
- super.velocity_y = var2.velocity_y * Gamelication.randBetween(0.6, 1.4);
- }
-
- Image var6 = super.owner.getImage(super.owner.getCodeBase(), "images/" + var3 + var5[var4] + ".gif");
- ((Actor)this).setImage(var6, 4, 32);
- super.currentFrame = (int)Gamelication.randBetween((double)0.0F, (double)super.numFrames);
- }
-
- public void explode() {
- if (this.size == 0) {
- Explosion var1 = new Explosion(super.owner, this);
- super.owner.actorManager.addActor(var1);
- } else {
- super.owner.play(super.owner.getCodeBase(), "sounds/explode1.au");
- }
-
- if (this.size == 2) {
- for(int var2 = 0; var2 < 2; ++var2) {
- super.owner.actorManager.addActor(new Asteroid(super.owner, this, this.name, 1));
- ((Boinkaroids)super.owner).addOneBadGuy();
- }
- } else if (this.size == 1) {
- for(int var3 = 0; var3 < 2; ++var3) {
- super.owner.actorManager.addActor(new Asteroid(super.owner, this, this.name, 0));
- ((Boinkaroids)super.owner).addOneBadGuy();
- }
- }
-
- super.owner.scoreManager.addToScore((2 - this.size) * 200 + 100);
- super.owner.actorManager.removeActor(this);
- ((Boinkaroids)super.owner).removeOneBadGuy();
- }
-
- protected void collideWithActor(Actor var1) {
- String var2 = var1.getClass().getName();
- if (var2.equals("Bullet") || var2.equals("Ship")) {
- this.explode();
- }
-
- }
- }
-