MazezaM is a data driven puzzle game - where each level is defined with a very small set of data.
Here's the script for level 1 - Humble Origins, with the level data loader from the ZX BASIC program.
Code: Select all
#########
+ $ $ *
# $ $$ #
#########
@LOADMAZE: REM ** load mazes **
RESTORE 2+@MAZEDATA +4*(mazeno-1)
READ n$,c$,w,h,lx,rx
FOR i = 1 TO h
READ a$(i)
NEXT i
LET l=INT ((32-w)/2)
LET t=INT ((24-h)/2)
LET r=32-l-w
RETURN
n$ is the level name, in this case "Humble Origins"
c$ is the author's name, which is just thrown away on ZX Spectrum, non-existent on other ports
w is the width of the play area, excluding bricks (# characters), in this case 7
h is the height of the play area, or number of active rows, in this case 2
lx is the row number on which the player enters from the left, in this case 1
rx is the row number on which the player exits to the right, in this case also 1
a$(1 ...n) is the array which holds the individual rows, here there are 2
The variables l,t and r just help with placement, for l is left side column count, r is right side column count, and t is rows above and below.
Here is the same data set as seen by C/CPP
Code: Select all
switch (mazenumber)
{
case 1:
LevelName=(char *) "Humble Origins";w=7;h=2;
lx=1;rx=1;
a[1]= (char *) " # # ";
a[2]= (char *) " # $& ";
break;
...
case 42:
LevelName= (char *) "The Beast";w=10;h=7;lx=1;rx=1;
a[1]= (char *) " # $& # ";
a[2]= (char *) "# # $%& $&";
a[3]= (char *) " # # # ";
a[4]= (char *) " $& $& $%&";
a[5]= (char *) " # # # # ";
a[6]= (char *) " $& # $%& ";
a[7]= (char *) " # $%& # ";
break;
}
From a programming standpoint, the source is a great introduction to data driven software. Once you have presentation and code logic functions in place, it's just throw more definitions at it to get more levels.
Please visit http://www.hirudov.com, which is Ventzislav Tzvetkov's collection of MazezaM ports with source code for each and make your own conclusion.