|
-
Senior Member
Well, there's two techniques you can use here.
The technique I use can be exhibited here:
http://krazydad.com/fungames.php
and here:
http://krazydad.com/bestiary/
I use a recursive algorithm (called "hunt and kill") which builds the maze using random numbers. Although the different mazes on my site look different, they are all built with the same algorithm (I use the same #include file for each of my mazes).
Using this system, each time the script is run, you get a different maze. Although the mazes on display on my site tend to be fairly geometrical in look, it is possible to use curvy lines and more irregular shapes (my 'adjustable maze' uses some randomness in the line drawing) - the only requirement is that the space that the maze is in consist of a network of nodes, in which each node is connected to the surrounding nodes by a single path, such as a wall (as in a piece of graph paper or a honeycomb). The maze is made by removing the walls that connect nodes.
When an object moves thru the maze, the datastructure already knows where the paths are, so you don't have to do any collision tests - you just only allow movement along legal paths.
However, this method requires a lot of programming. A good website that describes this type of maze-creation algorithm is here:
http://www.astrolog.org/labyrnth/algrithm.htm
The second method is to use a scanned hand-drawn maze (or draw it in flash) and then use hitTest() to do collision checks when an object travels thru the maze. The good thing about this method is that it is easier to get a more organic looking maze, however there are drawbacks. The maze is always the same, and it is difficult to get the hitTest() based code to work properly - if an object moves too quickly it may jump over a wall.
Last edited by jbum; 10-22-2004 at 07:05 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|