Exemple #1
0
  /**
   * Changes the position of an entity on the map, by specifying the coordinates of its origin
   * point.
   *
   * @param entity an entity
   * @param x x coordinate of the origin point
   * @param y y coordinate of the origin point
   * @throws MapException if the coordinates are not multiple of 8
   */
  public void setEntityPosition(MapEntity entity, int x, int y) throws MapException {
    entity.setPositionInMap(x, y);
    entity.updateImageDescription();

    setChanged();
    notifyObservers();
  }
Exemple #2
0
  /**
   * Changes the direction of an entity.
   *
   * @param entity the entity to change the direction
   * @param direction the new direction
   * @throws MapException if this entity has no direction
   */
  public void setEntityDirection(MapEntity entity, int direction) throws MapException {

    int oldDirection = entity.getDirection();

    if (direction != oldDirection) {

      entity.setDirection(direction);
      entity.updateImageDescription();

      setChanged();
      notifyObservers();
    }
  }