예제 #1
0
 @Override
 public void update() {
   for (int i = 0; i < getAllEntities().size(); i++) {
     final AbstractEntity e = getAllEntities().get(i);
     e.update();
     if (!e.isCollisionAsleep()) {
       for (int j = i + 1; j < getAllEntities().size(); j++) {
         final AbstractEntity other = getAllEntities().get(j);
         if (other != e) {
           if (other.isColliding(e)) {
             e.collisionWith(other);
             other.collisionWith(e);
           }
         }
       }
     }
     if (e.isAffectedByGravity()) {
       if (!e.isCollisionAsleep()) {
         e.applyForce(getGravityForce());
       }
     }
     if (e.isDead()) {
       getAllEntities().remove(i);
       i--;
     }
   }
   getMapViewport().centerX(player.getX());
   getMapViewport().lockFrame(getMap());
   background.update();
   background.viewportMoved(getMapViewport().getX(), getMapViewport().getY());
   background1.update();
   background1.viewportMoved(getMapViewport().getX(), getMapViewport().getY());
 }