Esempio n. 1
0
  @Override
  public void reset() throws Exception {
    // if the maze exits we will change the location to the start of the maze
    if (getGame().getLabyrinth() != null && getGame().getLabyrinth().getMaze() != null) {
      // assign maze start location as our current
      super.setCol(getGame().getLabyrinth().getMaze().getStart());
      super.setRow(getGame().getLabyrinth().getMaze().getStart());
    } else {
      // we will start at (0, 0)
      super.setCol(0);
      super.setRow(0);
    }

    // the target will be the current location
    setTarget(getCol(), getRow());

    if (hasIsometric()) {
      // set a default animation
      setAnimationKey(AnimationKey.IsometricEastStand);

      // assign the dimension
      setDimensions(DEFAULT_DIMENSION_ISOMETRIC);

      // position player
      super.setX((GamePanel.WIDTH / 2) + (Labyrinth.WIDTH_ISOMETRIC / 2));
      super.setY((GamePanel.HEIGHT / 2) - (Labyrinth.HEIGHT_ISOMETRIC / 4));
    } else {
      // set a default animation
      setAnimationKey(AnimationKey.TopDownEastStand);

      // assign the dimension
      setDimensions(DEFAULT_DIMENSION_TOP_DOWN);

      // position player
      super.setX((GamePanel.WIDTH / 2));
      super.setY((GamePanel.HEIGHT / 2));
    }

    // we will not be moving
    super.setDX(VELOCITY_NONE);
    super.setDY(VELOCITY_NONE);
  }
Esempio n. 2
0
  @Override
  public void render(final Canvas canvas) throws Exception {
    // if the location is not on the screen we won't need to render
    if (getX() + getWidth() < 0 || getX() > GamePanel.WIDTH) return;
    if (getY() + getHeight() < 0 || getY() > GamePanel.HEIGHT) return;

    // get location
    final double x = getX();
    final double y = getY();

    // offset location
    super.setX(x - (getWidth() / 2));
    super.setY(y - (getHeight() / 2));

    // render animation
    super.render(canvas);

    // restore location
    super.setX(x);
    super.setY(y);
  }