Ejemplo n.º 1
0
  /**
   * Animate the movement of the game map
   *
   * @param dir
   * @param speed
   * @param run
   */
  public void animate(final int dir, final int speed, final boolean run) {
    // remember move dir and
    int mod = 1;
    if (run) {
      mod = 2;
    }
    switch (dir) {
      case Location.DIR_NORTH:
        // animate map
        ani.start(0, 0, MapConstants.STEP_X * mod, -MapConstants.STEP_Y * mod, speed);
        break;
      case Location.DIR_NORTHEAST:
        // animate map
        ani.start(0, 0, 0, -MapConstants.TILE_H * mod, speed);
        break;
      case Location.DIR_EAST:
        // animate map
        ani.start(0, 0, -MapConstants.STEP_X * mod, -MapConstants.STEP_Y * mod, speed);
        break;
      case Location.DIR_SOUTHEAST:
        // animate map
        ani.start(0, 0, -MapConstants.TILE_W * mod, 0, speed);
        break;
      case Location.DIR_SOUTH:
        // animate map
        ani.start(0, 0, -MapConstants.STEP_X * mod, MapConstants.STEP_Y * mod, speed);
        break;
      case Location.DIR_SOUTHWEST:
        // animate map
        ani.start(0, 0, 0, MapConstants.TILE_H * mod, speed);
        break;
      case Location.DIR_WEST:
        // animate map
        ani.start(0, 0, MapConstants.STEP_X * mod, MapConstants.STEP_Y * mod, speed);
        break;
      case Location.DIR_NORTHWEST:
        // animate map
        ani.start(0, 0, MapConstants.TILE_W, 0, speed);
        break;
      default:
        animationFinished(false);
    }
    // start separate Elevation animation
    final int fromElevation = elevation;
    elevation = World.getMap().getElevationAt(World.getPlayer().getLocation());
    if (elevation != fromElevation) {
      levelAni.start(0, -fromElevation, 0, -elevation, speed);
    }

    // adjust Z-order after update
    if (World.getAvatar() != null) {
      readd(World.getAvatar());
    }
  }
Ejemplo n.º 2
0
 /**
  * Move the map origin to a new location
  *
  * @param location
  */
 public void setLocation(final Location location) {
   // origin.setSC(location.scX, location.scY, 0);
   origin.set(location);
   ani.stop();
   final Avatar avatar = World.getAvatar();
   if (avatar != null) {
     avatar.animationFinished(false);
   }
   elevation = World.getMap().getElevationAt(origin);
   dX = 0;
   dY = 0;
   dL = -elevation;
   Camera.getInstance().markEverythingDirty();
 }