예제 #1
0
 /**
  * updates all objects.
  *
  * @param elapsed time elapsed since latest update
  */
 public final void update(final float elapsed) {
   for (GameObject object : gameObjects) {
     if (!object.remove()) {
       object.update(elapsed);
     }
   }
 }
 /**
  * Check how much overlap there is on the right side of the rectangle.
  *
  * @param other rectangle of other object.
  * @return amount of overlap.
  */
 public final float overlapRight(GameObject other) {
   float overlap = 0;
   if (collidesWith(other) && getRight() <= other.getRight()) {
     overlap = getRight() - other.getLeft();
   }
   return overlap;
 }
 /**
  * Check how much overlap there is on the bottom side of the rectangle.
  *
  * @param other rectangle of other object.
  * @return amount of overlap.
  */
 public final float overlapBottom(GameObject other) {
   float overlap = 0;
   if (collidesWith(other) && getBottom() >= other.getBottom()) {
     overlap = other.getTop() - getBottom();
   }
   return overlap;
 }
 /**
  * Check if there is overlap of rectangles.
  *
  * @param other rectangle of other object.
  * @return true if overlap, else false.
  */
 public final boolean collidesWith(GameObject other) {
   return getBody().overlaps(other.getBody());
 }