|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--Maze
A maze. Holds the maze layout, the finish location and the current player location. The maze is three dimensions, but acts like a two dimensional maze if the Z dimension has a size of 1. Each cell contains a bitmap representing which exits are available from that cell. The exits are known as XPL,XMI,YPL,YMI,ZPL,ZMI representing a plus and minus direction exit in each of the 3 dimensions. The maze is created such that adjoining cells share openings so that the "doorway" is two directional. There are no exits around the outside of the maze. The finish is just a designated cell.
Fields inherited from interface MazeModel |
MARK,
WALLS,
XMI,
XPL,
YMI,
YPL,
ZMI,
ZPL |
Constructor Summary | |
Maze(Coordinate3D size)
Contruct a new maze with the given dimensions. |
|
Maze(int xdim,
int ydim,
int zdim)
Contruct a new maze with the given dimensions. |
Method Summary | |
void |
addMazeListener(MazeListener l)
Add a MazeListener. |
static int |
count(int val)
Count how many open walls there are in the cell value. |
void |
create()
Create a random maze. |
static String |
directionString(byte direction)
Get a String representation of the given direction. |
protected void |
fireChange()
Fire a change in the maze. |
static Coordinate3D |
forward(Coordinate3D c,
byte direction)
Move between cells in a maze. |
Coordinate3D |
getCurrent()
Get the current player co-ordinate. |
Coordinate3D |
getFinish()
Get the maze finish cell location. |
Coordinate3D |
getSize()
Get the size of this maze. |
byte |
grid(Coordinate3D c)
Get the given cell walls and status. |
byte |
grid(int x,
int y,
int z)
Get the given cell walls and status. |
static byte |
invert(byte value)
Return the opposite direction. |
boolean |
isMarked(Coordinate3D position)
Check if the given cell has an "I've been here" marker. |
boolean |
isOpen(Coordinate3D current,
byte direction)
Check and see if movement is possible. |
void |
removeMazeListener(MazeListener l)
Remove a MazeListener. |
void |
setCurrent(Coordinate3D current)
Set the current player co-ordinate. |
void |
setFinish(Coordinate3D finish)
Set where the finish cell is. |
void |
setMark(Coordinate3D position,
boolean mark)
Put or remove a "I've been here" marker in a cell. |
void |
setRandomFinish()
Make a random finish location. |
Stack |
solve(Coordinate3D start)
Solve the maze from a given start position. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Constructor Detail |
public Maze(int xdim, int ydim, int zdim)
xdim
- The x dimension of the maze.ydim
- The y dimension of the maze.zdim
- The z dimension of the maze. Use 1 for a 2D maze.public Maze(Coordinate3D size)
size
- The 3D size of the maze.Method Detail |
public Coordinate3D getSize()
public void setMark(Coordinate3D position, boolean mark)
position
- The cell position.mark
- True to place a mark, False to remove a mark.public byte grid(int x, int y, int z)
x
- The x co-ordinate.y
- The y co-ordinate.z
- The z co-ordinate.public byte grid(Coordinate3D c)
c
- The 3D co-ordinate of the desired cell.public void setFinish(Coordinate3D finish)
finish
- The 3D co-ordinate of the end of the maze.public void setRandomFinish()
public Coordinate3D getFinish()
public Coordinate3D getCurrent()
public void setCurrent(Coordinate3D current)
current
- The 3D co-ordinate of the player in the maze.public boolean isMarked(Coordinate3D position)
position
- The 3D co-ordinate of the cell to check.public static String directionString(byte direction)
direction
- One of MazeModel.XMI,XPL,YMI,YPL,ZMI,ZPL.public static final int count(int val)
val
- The internal value representing the cell.public void create()
public static byte invert(byte value)
value
- One of XPL,XMI,YPL,YMI,ZPL,ZMI.public static Coordinate3D forward(Coordinate3D c, byte direction)
c
- The 3D co-ordinate to start from.direction
- The direction to go, one of XPL,XMI etc.public boolean isOpen(Coordinate3D current, byte direction)
current
- The 3D co-ordinate to start from.direction
- The direction to go, one of XPL,XMI etc.public Stack solve(Coordinate3D start)
start
- The 3D co-ordinate to start from.public void addMazeListener(MazeListener l)
l
- A MazeListener to listen for maze changes.public void removeMazeListener(MazeListener l)
l
- The MazeListener to remove.protected void fireChange()
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |