Maze.pm - Simple rectangular mazes

 

NAME

Maze.pm - Simple rectangular mazes


AUTHOR

David M. Chess, chess@theogeny.com


SYNOPSIS

  use strict;
  use Maze;
  srand();      # The module doesn't do any seeding itself

  # create a simple maze, twelve corridors high and eight wide
  my $maze = new Maze(12,8);

  # Display it as ASCII art
  print $maze->display_ascii();

  # Or as a bunch of IMG tags (images in ../gifs/)
  my $tags = $maze->display_html("../gifs/");


HISTORY

  2000/12/18 - First release version, 1.00
  2000/12/19 - Allow specifying where the images are, 1.01


Creating a new object


my $maze = new Maze($height,$width);

returns a new maze object of the given height and width (in ``corridor'' units).


Rendering the maze


print $maze->display_ascii();

returns a string representing the maze as a primitive bit of ASCII art, as in:

 *--*--*--*--*  *
 |              |
 *  *--*--*--*  *
 |  |     |     |
 *--*  *  *  *--*
 |     |        |
 *  *--*--*--*--*


print $maze->display_html($gif_prefix);

returns a string representing the maze as a bunch of HTML ``IMG'' tags.

The tags returned will reference images called ``post.gif'' (used for the ``posts'' where walls come together), ``vwall.gif'' (a vertical wall), ``hwall.gif'' (a horizontal wall), ``vopen.gif'' (a vertical open space, where there isn't a wall), ``hopen.gif'' (a horizontal open space, where there isn't a wall), and ``hall.gif'' (the open areas between potential walls). All image names will be prefixed with the given prefix, if given.

post.gif, vwall.gif and vopen.gif should all be the same width. hall.gif, hwall.gif and hopen.gif should all be the same width. post.gif, hwall.gif and hopen.gif should all be the same height. hall.gif, vwall.gif and vopen.gif should all be the same height.

Got all that?

 

   Maze.pm - Simple rectangular mazes