ch.aplu.jgamegrid
Class GGMaze

java.lang.Object
  extended by ch.aplu.jgamegrid.GGMaze

public class GGMaze
extends java.lang.Object

This class creates a random maze in a two-dimensional grid of cells. The maze has one entry and one exit cell and one pass (no cycles).
For details about the algorithm used to create the maze, please consult the book 'Creating Mobile Games' by Carol Hamer, from where the code is copied with acknowledgment to the autor.


Constructor Summary
GGMaze(int width, int height)
          Creates a new random maze with given number of horizontal an vertical cells.
 
Method Summary
 Location getExitLocation()
          Returns the location of the exit cell.
 Location getStartLocation()
          Returns the location of the entry cell.
 boolean isWall(Location location)
          Returns true, if the cell with given cell location is a wall
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GGMaze

public GGMaze(int width,
              int height)
Creates a new random maze with given number of horizontal an vertical cells.

Parameters:
width - the number of horizontal cells (must be odd)
height - the number of vertical cells (must be odd)
Method Detail

getStartLocation

public Location getStartLocation()
Returns the location of the entry cell.

Returns:
the location of the cell where to enter into the maze

getExitLocation

public Location getExitLocation()
Returns the location of the exit cell.

Returns:
the location of the cell where to leave the maze

isWall

public boolean isWall(Location location)
Returns true, if the cell with given cell location is a wall

Parameters:
location - the location of the requested cell
Returns:
true, if the cell is a wall; false, if it is a gangway