home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1997 October / PCO1097.ISO / FilesBBS / FREI / MCII.EXE / GameObjectMover.class (.txt) < prev    next >
Encoding:
Java Class File  |  1996-10-03  |  2.8 KB  |  119 lines

  1. import java.util.Enumeration;
  2. import java.util.Vector;
  3.  
  4. class GameObjectMover extends Thread {
  5.    int rate;
  6.    MissileCommando parent;
  7.  
  8.    GameObjectMover(int var1, MissileCommando var2) {
  9.       this.rate = var1;
  10.       this.parent = var2;
  11.    }
  12.  
  13.    public void run() {
  14.       while(true) {
  15.          this.parent.repaint();
  16.  
  17.          try {
  18.             Thread.sleep((long)this.rate);
  19.          } catch (Exception var1) {
  20.             return;
  21.          }
  22.  
  23.          this.checkCollisions();
  24.          this.removeZombies();
  25.       }
  26.    }
  27.  
  28.    void checkCollisions() {
  29.       Enumeration var1 = this.parent.shots.elements();
  30.       Enumeration var2 = this.parent.bases.elements();
  31.  
  32.       while(true) {
  33.          Shot var3 = var1.hasMoreElements() ? (Shot)var1.nextElement() : null;
  34.          Base var4 = var2.hasMoreElements() ? (Base)var2.nextElement() : null;
  35.          if (var3 == null && var4 == null) {
  36.             return;
  37.          }
  38.  
  39.          Enumeration var5 = this.parent.missiles.elements();
  40.  
  41.          while(var5.hasMoreElements()) {
  42.             Missile var6 = (Missile)var5.nextElement();
  43.             if (var3 != null && var6.collision(var3.x, var3.y, ((Explosion)var3).currentSize())) {
  44.                this.parent.destroyMissile(var6);
  45.             }
  46.  
  47.             if (var4 != null && ((GameObject)var4).alive() && var6.collision(var4.x, var4.y, var4.w, var4.h)) {
  48.                this.parent.destroyBase(var4, var6);
  49.             }
  50.          }
  51.  
  52.          Enumeration var10 = this.parent.mrvs.elements();
  53.  
  54.          while(var10.hasMoreElements()) {
  55.             MRV var7 = (MRV)var10.nextElement();
  56.             if (var3 != null && var7.collision(var3.x, var3.y, ((Explosion)var3).currentSize())) {
  57.                this.parent.destroyMRV(var7);
  58.             }
  59.  
  60.             if (var4 != null && ((GameObject)var4).alive() && var7.collision(var4.x, var4.y, var4.w, var4.h)) {
  61.                this.parent.destroyBase(var4, var7);
  62.             }
  63.          }
  64.  
  65.          Enumeration var11 = this.parent.bombs.elements();
  66.  
  67.          while(var11.hasMoreElements()) {
  68.             Bomb var8 = (Bomb)var11.nextElement();
  69.             if (var3 != null && var8.collision(var3.x, var3.y, ((Explosion)var3).currentSize())) {
  70.                this.parent.destroyBomb(var8);
  71.             } else if (var4 != null && ((GameObject)var4).alive() && var8.collision(var4.x, var4.y, var4.w, var4.h)) {
  72.                this.parent.destroyBomb(var8);
  73.             } else if (var8.y > 268) {
  74.                this.parent.destroyBomb(var8);
  75.             }
  76.          }
  77.  
  78.          Enumeration var12 = this.parent.bombDebris.elements();
  79.  
  80.          while(var12.hasMoreElements()) {
  81.             BombDebris var9 = (BombDebris)var12.nextElement();
  82.             if (var4 != null && ((GameObject)var4).alive() && var9.collision(var4.x + var4.w / 2, var4.y + var4.h / 2, var4.w)) {
  83.                this.parent.destroyBase(var4, var9);
  84.             }
  85.          }
  86.       }
  87.    }
  88.  
  89.    void removeZombies(Vector var1) {
  90.       Enumeration var2 = var1.elements();
  91.  
  92.       while(var2.hasMoreElements()) {
  93.          GameObject var3 = (GameObject)var2.nextElement();
  94.          if (!var3.alive()) {
  95.             if (var3 instanceof Missile) {
  96.                Missile var4 = (Missile)var3;
  97.                if (var4.splitme) {
  98.                   for(int var5 = 0; var5 < 3; ++var5) {
  99.                      this.parent.createMissile((int)var4.x, (int)var4.y, var4.speed);
  100.                   }
  101.                }
  102.             }
  103.  
  104.             var1.removeElement(var3);
  105.          }
  106.       }
  107.  
  108.    }
  109.  
  110.    void removeZombies() {
  111.       this.removeZombies(this.parent.missiles);
  112.       this.removeZombies(this.parent.mrvs);
  113.       this.removeZombies(this.parent.bombs);
  114.       this.removeZombies(this.parent.shots);
  115.       this.removeZombies(this.parent.explosions);
  116.       this.removeZombies(this.parent.bombDebris);
  117.    }
  118. }
  119.