示例#1
0
  // Should be named updatePosition -Sam
  @Override
  public void update(int xMovement, int yMovement, long elapsed) {
    if (xMovement == 0 && yMovement == 0) {
      currentlyMoving = false;
    } else {
      location.incrementX(
          Math.round(xMovement * elapsed * StaticVar.entitySpeed * stats.getMovement()));
      location.incrementY(
          Math.round(yMovement * elapsed * StaticVar.entitySpeed * stats.getMovement()));

      if (yMovement > 0) yMovement = 1;
      else if (yMovement < 0) yMovement = -1;

      xMovement /= 26;

      changeDirection(xMovement, yMovement);
      currentlyMoving = true;
    }
  }
示例#2
0
  public void dropItems() {
    Iterator<TakeableItem> iter = inventory.getItems().iterator();
    while (iter.hasNext()) {
      TakeableItem item = iter.next();
      int xLoc = location.getX();
      int yLoc = location.getY() + 100;
      item.setLocation(new Location(xLoc, yLoc));
      item.setDisplay(true);
      iter.remove();
    }

    iter = equipment.getItems().iterator();
    while (iter.hasNext()) {
      TakeableItem item = iter.next();
      int xLoc = location.getX();
      int yLoc = location.getY() + 100;
      item.setLocation(new Location(xLoc, yLoc));
      item.setDisplay(true);
      iter.remove();
    }
  }