Package Tree Index Deprecated About |
| Prev Class | Next Class | Frames | No Frames |
| Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
Class HarderMaze4D
- MouseListener, Runnable
public class HarderMaze4D
extends Applet
implements MouseListener, Runnable
Program allowing player to navigate a four dimensional labyrinth. This
program draws a board sized to what is specified in its parameters or in the
default values if parameters are not given; it may therefore be larger or
smaller than the applet window that it is put in.
This program is a Java re-implementation of a maze originally written by
Jonathan Hayward in eighth grade, in Apple ][ BASIC, and re-implemented in C
during undergraduate studies. It retains a classic style of graphics and
the original algorithms and basic data structures, but adds a recursive
solvability verifier, configurability in invocation that was impossible
under previous implementations, and a point-and-click interface. The
applet may be seen at
http://JonathansCorner.com/etc/maze/;
it was slashdotted within a week of going online.
This is presented as a code sample for:
Jonathan Hayward
jonathan.hayward@pobox.com
Dimensions are as follows:
Within squares:
^
Y|
+->
X
Between squares:
^
Z|
+->
W
This is disanalogous, but gives the most obvious place to the fourth
(spatial) dimension after the first three dimensions have been assigned
their usual letters. Therefore, I am keeping it that way.
Thanks to my father, John Hayward, for help with an AWT bug, James
Holt for a bugfix and additional code to address bug which manifested in
larger mazes, and Darren Edmonds for pointers on how to update the
MouseEvent handling.
void | drawBoard()- Draw the board on the screen.
|
void | init()- Initializations performed when the applet is created.
|
void | mouseClicked(MouseEvent theEvent)- Process a mouse click to see if it is corresponds to a legal move,
and, if so, make that move.
|
void | mouseEntered(MouseEvent theEvent)- Respond appropriately to the mouse cursor entering the component.
|
void | mouseExited(MouseEvent theEvent)- Respond appropriately to the mouse cursor exiting the component.
|
void | mousePressed(MouseEvent theEvent)- Respond appropriately to the mouse button being pressed.
|
void | mouseReleased(MouseEvent theEvent)- Respond appropriately to the mouse button being released.
|
void | paint(Graphics g)- This method is called when the display is to be painted.
|
void | run()- Display a success message for two seconds before generating a new
maze.
|
void | update(Graphics g)- This applet method is called to update the contents of the
screen.
|
serialVersionUID
public static final long serialVersionUID
- 0L
drawBoard
public void drawBoard()
Draw the board on the screen.
init
public void init()
Initializations performed when the applet is created.
mouseClicked
public void mouseClicked(MouseEvent theEvent)
Process a mouse click to see if it is corresponds to a legal move,
and, if so, make that move. A legal move is one that takes to a space
adjacent to his present space in hyperspace (not necessarily on the
board).
mouseEntered
public void mouseEntered(MouseEvent theEvent)
Respond appropriately to the mouse cursor entering the component. At
present, this does nothing.
mouseExited
public void mouseExited(MouseEvent theEvent)
Respond appropriately to the mouse cursor exiting the component. At
present, this does nothing.
mousePressed
public void mousePressed(MouseEvent theEvent)
Respond appropriately to the mouse button being pressed. At
present, this does nothing.
mouseReleased
public void mouseReleased(MouseEvent theEvent)
Respond appropriately to the mouse button being released. At
present, this does nothing.
paint
public void paint(Graphics g)
This method is called when the display is to be painted.
run
public void run()
Display a success message for two seconds before generating a new
maze. This is done in a separate thread because if it is done in the
mouse event handler, the screen is not updated until the end of the two
seconds, where it flashes, subliminal message style.
update
public void update(Graphics g)
This applet method is called to update the contents of the
screen.
Package Tree Index Deprecated About |