Game Map
"; //now we start building the table //now we want to add an extra row at the top that just shows the coordinate numbers //across the top of the map. echo ""; //we start a row, and add an extra blank column to offset the //coordinate numbers added over the map (so 0 starts over the first W in the map) for ($i = 0; $i <= $mapwidth; $i++) //now we want to draw numbers for the width of the map echo ""; //this shows the numbers in a column echo ""; //that's the end of this row, we now have all the numbers across the top of the map //now it's time to start drawing the map for ($i = 0; $i <= $mapheight; $i++) //we want to draw the entire height { echo ""; //each row in the map starts off with a number as well echo ""; //so we can tell which coordinate it's at //now we want to draw what's in that part of the map for the entire width for ($j = 0; $j <= $mapwidth; $j++) { if ($x == $i && $y == $j && $map[$i][$j] != "T") //if this is not treasure echo ""; //and the character is standing here //draw the C instead of what's on the map //and make it show up green else if ($x == $i && $y == $j && $map[$i][$j] == "T") //this is the treasure echo ""; //and the character is standing here //draw the C instead of what's on the map //and make it show up green else echo ""; //this is just a lonely map space, show whatever it is } echo ""; } //now our table is done, we can end it, and under that //we'll show the coordinates of the character so we can //tell what spot they're inside of the map numerically echo "
$i
$iCC" . $map[$i][$j] . "

"; echo "Your coordinates are: ($x, $y)"; echo "
"; } //we're only going to show the map //if they decide they want to cheat... if ($_GET['showmap']) { //call our custom draw map function //make sure we pass it all the parameters we need drawMap($_SESSION['x'], $_SESSION['y'], $maze, 6, 4); } ?> Pits of Doom
Welcome to my little text action game. This is a really simple game. You're standing in a maze and you can move in four directions, up, down, left and right. One of the four squares has a magical treasure chest on it. Beware! You only get one guess to find the treasure chest!! If you guess wrong you'll fall into the pit of doom and die...

How will you move?
or you can cheat and display the map... Game Over!"; ?>