digrach

detectProjectileCollisionWithAlien

May 27th, 2014
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.75 KB | None | 0 0
  1. public void detectProjectileCollisionWithAlien() {
  2.         // Required.
  3.         for (int x = 0; x < alienList.length; x ++ ) {
  4.             Alien currentAlien = alienList[x];
  5.  
  6.             if (currentAlien != null) {
  7.  
  8.                 Iterator<Projectile> itr = projectileList.iterator();
  9.                 while(itr.hasNext()) {
  10.                     Projectile p = itr.next();
  11.  
  12.                     if (p.getCurrentX() + p.getWidth() >= currentAlien.getCurrentX()
  13.                             && p.getCurrentX() <= currentAlien.getCurrentX() + currentAlien.getWidth()
  14.                             &&
  15.                             p.getCurrentY() + p.getHeight() >= currentAlien.getCurrentY()
  16.                             && p.getCurrentY() <= currentAlien.getCurrentY() + currentAlien.getHeight()) {
  17.  
  18.                         itr.remove();
  19.                         alienList[x] = null;
  20.                         updatePlayerScore();
  21.                         break;
  22.                     }
  23.  
  24.                 }
  25.  
  26.             }
  27.  
  28.         }
  29.  
  30.     }
Advertisement
Add Comment
Please, Sign In to add comment