The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Games::Maze::SVG::Manual - Manual for the Games::Maze::SVG modules.

PURPOSE

The Games::Maze::SVG module supports the creation of 2-dimensional mazes in an SVG format suitable for printing or playing interactively. This module use the Games::Maze module to perform the actual work of creating the mazes.

HISTORY

During the middle of 2004, my son was extremely interested in mazes. We could not get enough mazes for him to solve. As a Perl programmer, I decided there must be some way to generate mazes and went to CPAN. I found Games::Maze. I printed a few pages of these mazes, and he was happy.

Unfortunately, the ASCII-based maze was not really satisfying for me. So I wrote code to convert the output of Games::Maze to SVG. This made much nicer looking mazes. I worked for a while to make the lines look better and to vary the corners to generate mazes that looked even better.

But the mazes were still missing something. So, I added the scripting support that would make the maze playable. I wrapped an HTML form around the generation program to allow it to be launched from the web.

I made this version available on my website. A friend of mine made some suggestions for individual visual changes that I incorporated. The design of the code did not change much during the next year. It was still a quick hacked wrapper around Games::Maze without much flexibility.

A year later, a comment on the SVG Developers mailing list made me dust off the code with an eye towards making a legitimate Perl module out of it. When I began looking at the code again, I realized that the original had been more of a hack than I remembered. The new version still could use some significant cleanup, but I am much happier with the overall design.

SYNOPSIS

  use Games::Maze::SVG;

  my $maze = Games::Maze::SVG->new( 'Rect', wallform => 'roundcorners' );

  my $svgout = $maze->to_string();

OVERVIEW

The Games::Maze::SVG module can produce interactive or non-interactive mazes in SVG of three basic shapes. The shape of the maze is determined by the first parameter. This parameter is a string with one of the following values:

Rect

A maze with a rectangular overall shape and rectangular hallways.

RectHex

A maze with a rectangular overall shape and hallways made from hexagonal cells.

Hex

A maze with a hexagonal overall shape and hallways made from hexagonal cells.

The mazes can be further configured using a set of named parameters that follow the shape parameter. Most of these parameters are independent of the shape chosen. In addition, the mazeparams parameter supports passing parameters directly to the internal Games::Maze object which is used to create the maze.

CONSTRUCTOR PARAMETERS

The following describes the parameters supported by the Games::Maze::SVG constructor.

crumb

String describing the breadcrumb style. Legal values are dash, dot, line, and none. The default value is dash. The different styles are:

dash

A dashed line alternating 5 pixels on and 3 pixels off.

dot

A dotted line with 2 pixel dots 6 pixels apart.

line

A solid line one pixel wide.

none

No breadcrumb path.

wallform

String naming the wall format. Legal values depend on which shape is selected.

dir

Directory in which to find the ecmascript for the maze interactivity. Should either be relative, or in URL form. The default value is 'scripts/'.

interactive

This parameter determines if the maze will be interactive. If the value of the parameter is true (1), the appropriate scripting and support is written into the SVG. If the parameter is omitted or false, no interactive support is provided.

cols

The number of columns used in creating the maze. Default value is 12.

rows

The number of rows used in creating the maze. Default value is 12.

startcol

The column where the entry is found. Default value is random.

endcol

The column where the exit is found. Default value is random.

The wallform parameter has different legal values depending on the shape of the maze.

Rect

The rectangular maze supports the following wall forms:

straight

All walls are straight and all corners are simple right angles.

round

All corners are rounded, both inside and out of the maze.

roundcorners

Only outside corners are rounded.

bevel

All corners are beveled to give a somewhat less square appearance.

The default wallform for the Rect maze shape is straight.

RectHex

The RectHex maze shape supports the following wallforms:

straight

This form gives ordinary hexagonal cells throughout the maze. This is also the default wall form.

round

All corners are rounded, both inside and out of the maze.

roundcorners

Only corners are rounded, not Ys.

Hex

The Hex maze shape supports the following wallforms:

straight

This form gives ordinary hexagonal cells throughout the maze. This is also the default wall form.

round

All corners are rounded, both inside and out of the maze.

roundcorners

Only corners are rounded, not Ys.

INTERACTIVITY

The interactive forms of the mazes have a somewhat different appearance and contain an ECMAscript-driven interface that allows the player to move a little sprite throughout the maze. The interactive maze has a control panel to the left with a set of controls and help text to describe how to play the game. The non-interactive version is missing this extra panel.

The sprite is moved around the maze using the arrow keys. If any crumb style besides none has been chosen, a trail is left behind the sprite to see where it has been.

There are two sets of buttons on the control panel. The three buttons along the top are labelled Begin, Save, and Back. The first starts or restarts the game. The Save button saves the current location so that you can easily return to it. The Back button returns to the last saved position. The positions are stored in a stack so that you can save and restore multiple times, in multiple places through the maze.

The second set of buttons supports moving the maze in each of the four directions. The center button restores the original position. These buttons are useful any time the maze is bigger than can be displayed by the current viewer. This is particularly useful when using the Adobe SVG viewer in a browser. It is quite easy to make a maze that is larger than the displayable area on the screen. Unfortunately, there does not appear to be an easy way to determine how big the displayable area is. This functionality allows you to move the maze around so that you can see where you are going.

PROBLEMS

When playing the maze on Batik's Squiggle viewer, the arrow keys also move the entire SVG image. You can restore the image to its original position by pressing Ctrl-T.