I have written two Java applets that draw mazes, MazeApplet and MazeIcon.
The first draws larger mazes with a number of shapes while the later is
optimized to make smaller ones for use as an icon or decorative border on
a web page.
I invite you to use them and tell me what you think via the mail
link on the left side of the page. If you don't know how to put an
applet on your page, check out
this great tutorial.
MazeIcon
The MazeIcon applet draws a maze in a small area, suitable for use
on a webpage as an icon or horizontal or vertical border. Several
parameters allow the user to choose the shape of the tiles in the maze,
display the solution, change the various colors of the maze, link it to
a URL, or have it periodically draw a new maze.
Here are some of the components to MazeIcon you can download and use as you wish:
- JavaBoutique has a
.ZIP file of all sources, classes, the .jar, and sample HTML
to show how to use MazeIcon (similar to the table below).
- Here is my local copy of the .ZIP file. Please use this
if you have problems with the link above.
- Here's the source to MazeTile,
the base class to set up mazes of a given shape.
- Here's the source to MazeIcon,
the applet which actually draws the maze.
- Finally (not really a download),
click here
to see MazeIcon's page at the
Java Applet Rating Service (www.jars.com).
I am in the process of putting a package together for
MazeApplet for
downloading. Once I have the finishing touches, I will post it here
and at JavaBoutique.
The table below shows
various ways MazeIcon can be used.
|
|
This is the MazeIcon set up with the
default color settings, used as a link icon. The solution is not
shown, but can be toggled on with a right-click. The maze only redraws
on a refresh of the whole screen. Here is the HTML to make it work:
<applet archive="MazeIcon.jar"
code=MazeIcon.class
width=50 height=50>
<param name=href value=
"http://KevinHaw.com/MazeApplet.php">
<param name=alt value= "Click for
Kevin's Maze Page">
</applet> |
|
|
Here is a flashier version, turning
on the solution and using a refresh to draw the eye. Here's the HTML:
<applet archive="./compiled_java/MazeIcon.jar"
code=MazeIcon.class
width=50 height=50>
<param name=bgColor value="33CCFF">
<param name=fgColor value="000000">
<param name=solution value="on">
<param name=solColor value="FFFF00">
<param name=refresh value="2">
<param name=href value=
"http://KevinHaw.com/
/MazeApplet.php">
<param name=alt value="Click for
Kevin's Maze Page">
</applet> |
|
|
Here is an icon with the solution locked on, using
the diamond tile shape.
<applet archive="./compiled_java/MazeIcon.jar"
code=MazeIcon.class
width=50 height=50>
<param name=bgColor value="FFCCCC">
<param name=fgColor value="000000">
<param name=tileShape
value="diamond">
<param name=solution
value="on">
<param name=href value=
"http://KevinHaw.com/
/MazeApplet.php">
<param name=alt value= "Click for
Kevin's Maze Page">
</applet> |
|
|
Here is an example of hex shaped
tiles. The HTML is
<applet archive="./compiled_java/MazeIcon.jar"
code=MazeIcon.class
width=70 height=50>
<param name=bgColor value="009900">
<param name=fgColor value="FFFF00">
<param name=tileShape value="hex">
<param name=href value=
"http://http://KevinHaw.com/
/MazeApplet.php">
<param name=alt value="Click for
Kevin's Maze Page">
</applet> |
|
Here's MazeIcon used as a simple horizontal border with square tiles.
Solution has been turned on so it can be toggled off with a right-click.
Use this HTML:
<applet archive="./compiled_java/MazeIcon.jar" code=MazeIcon.class width=500
height=30>
<param name=fgColor value="000000">
<param name=solution value="toggleOn">
<param name=alt value="A Border">
</applet> |
|
Here's hex shaped tiles with an eye grabbing refresh.
<applet archive="./compiled_java/MazeIcon.jar" code=MazeIcon.class width=500
height=50>
<param name=tileShape value="hex">
<param name=bgColor value="FF6600">
<param name=fgColor value="000000">
<param name=solColor value="FFFFFF">
<param name=solution value="on">
<param name=alt value="Another Border...">
<param name=refresh value="3">
</applet> |
MazeApplet
MazeApplet is a java applet that builds mazes based on
various shaped tiles. The user can select the tile from the
pulldown menu.
Here are the basic instructions:
- Click through the maze to try to solve it (from start to finish).
The trail you pass will be marked. You can backtrack just by
clicking on a tile you already hit. When finished (clicking on "end"),
you will be told your time.
- Use the "New Maze" button to draw a maze.
- Use the "Solve" button to get the solution.
- Select the shape of the maze from the pulldown menu.
If you're interested in the JAVA source, it uses
two classes: MazeTile,
the general class to set up mazes, and
MazeApplet, which actually draws the maze as requested
on the web page.
Please EMAIL me any comments or check out my homepage.
MazeApplet
Improvements
Naturally, this is a work in progress. Here are some refinements
I'm planning for MazeApplet and/or MazeIcon:
-
Add a webpage explaining the algorithm.
-
Variable start and finish labels. Being able to pass GIFs for icons
and and the search cursor (see "animate solution", below) would be neat,
too.
-
Support "skip mazes." A teacher I know indicates that she uses mazes
with numbers placed in some of the cells. The kids (second graders)
have to count by fives or tens or whatever, tracing the path to the next
number in the sequence.
-
An "animate solution" to show the solution search, using a dedicated thread
and a sleep delay so a viewer can see the action.. Perhaps a GIF
of a mouse would be a neat cursor for that one. A flag to draw a
new maze once the old one is solved and a flag for search speed as applet
parameters would be needed. .