Maze Game: Sample Program
0403b.pl.txt
#
# This is a code snippet show a response to the right arrow (kr)
# It varies from the previous example in that it checks where the
# player is in the maze before allowing movement.
# A similar (modified appropriately) snippet has to be used for
# each arrow key.
#
if($key eq "kr") {
if ($maze[$Y][$X+1] ne "#") {
$X++;
if ($maze[$Y][$X] eq "P") {
$NumberOfLivesIHave--;
}
if ($maze[$Y][$X] eq "T") {
$NumberOfLivesIHave++;
}
}
}
Last updated: 20120225-13:22