Javascript mazes

Back to other software page.

Would you like a solvable maze on your web page? Of course not. Who really would? But if you would...

 
size=9
size=10
size=12
size=14
size=18
size=24
size=36
size=72
 
Click on 2 points in any maze to find the unique path between those points.
 
Try out a larger maze.

I created a small JavaScript file that will place one or more mazes on your page. All you need to do is:

  1. Copy sillysotmaze.js and a few small graphics files to your server. These filese are in this this zip file.
  2. Include a reference to sillysotmaze.js in your section
    <SCRIPT language=JavaScript src="sillysotmaze.js"></SCRIPT>
  3. Create a named <div> section with a specified size and a syle of position:absolute or position:relavite. You can use any name and any sizes. The actual maze may be slightly larger than the size of the <div> because the maze size is rounded up to the nearest multiple of the grid size you specify later.
    <div id=m1 style="position:relative;width:150;height:150;border:2px black solid"></div>
  4. At the end of your page, call the createMaze(...) method passing the name of the <div> and a grid size in pixels (>9) for the maze.
    <script>  createMaze("m1",18); </script>
     
  5. As you can see, you can have any number of mazes on the screen. This script requires a recent browser like FireFox or IE6. I haven't tested it on any other browsers. The script doesn't check the browser level so you may want to check for document.getElementById and DOM functionality in your startup script. The script uses:

    1. Object oriented JavaScript including classes and inner classes.
    2. Document Object Model (DOM) methods to create, position and delete elements on the screen.

    Note that refreshing a large maze can take a while. This is not because creating the maze takes a long time. It is actually because of the browser cleaning up the old maze (deleting the old page elements and doing JavaScript garbage collection).

    (c) Copyright 2004, SillySot Software, All Rights Reserved

    This software is distributed without warranty of any kind.