Package br.com.ema.maze.factory

Source Code of br.com.ema.maze.factory.MazeNearbyUpdater

/**
*
*/
package br.com.ema.maze.factory;

import br.com.ema.maze.components.Maze;
import br.com.ema.maze.components.MazeSpace;
import br.com.ema.maze.enums.Direction;

/**
* @author Emanuel Cruz Rodrigues -> emanuelcruzrodrigues@gmail.com
*
*/
public class MazeNearbyUpdater {

  public void updateNearby(Maze maze) {
    int height = maze.getHeight();
    int width = maze.getWidth();
   
    for (int y = 0; y < height; y++) {
      for (int x = 0; x < width; x++) {
        MazeSpace space = maze.getSpace( x, y );
        if (space != null){
          space.addNearbySpace(maze.getSpace(x, y-1), Direction.NORTH);
          space.addNearbySpace(maze.getSpace(x, y+1), Direction.SOUTH);
          space.addNearbySpace(maze.getSpace(x+1, y), Direction.EAST);
          space.addNearbySpace(maze.getSpace(x-1, y), Direction.WEST);
        }
      }
    }
  }

 
}
TOP

Related Classes of br.com.ema.maze.factory.MazeNearbyUpdater

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.