/**
   * Initializes the map with player at starting position
   *
   * @param s
   * @param startX
   * @param startY
   */
  public void start(Map m, int startX, int startY) {
    start();

    map = m;

    // player is handled like npc so then npcs can see it in collision
    leader.setMap(map);
    leader.move(startX, startY);
  }
 /** Moves leader to a new location */
 public void moveTo(int x, int y) {
   // only move there if it's a valid location
   leader.move(x, y);
   if (leader.getX() == x && leader.getY() == y) {
     currentTerrain = map.getTerrain(x, y);
     if (currentTerrain != null) encounterNum += currentTerrain.getRate();
     if (encounterNum > 100)
       if (currentTerrain.getFormations().size() > 0) {
         encounterNum = 0;
         Formation f = currentTerrain.getRandomFormation();
         Engine.getInstance().changeToBattle(f, currentTerrain.getBackground());
       }
     // interact with event if stepped on
     if (map.getEventMap().get(x + " " + y) != null) map.getEventMap().get(x + " " + y).interact();
   }
 }
 /** Starts/Resets the basics of a map */
 public void start() {
   e = Engine.getInstance();
   encounterNum = 0;
   leader = new NPC();
   leader.setWalkSprite(e.getParty().get(leaderIndex).getMapSelf());
   currentTerrain = null;
   activeNPC = null;
   setNextState();
 }
 /**
  * Handles key input
  *
  * @param evt
  */
 @Override
 public void keyPressed(KeyEvent evt) {
   if (!leader.isWalking()) state.handleKeyInput(evt);
 }