Classic Computer Magazine Archive COMPUTE! ISSUE 41 / OCTOBER 1983 / PAGE 72

Moving Maze

Matt Giwer

Can you maneuver through "Moving Maze" while fighting time and avoiding the relentless pursuit of the Rover? Impossible? Try it and see. Written for the Atari with joystick, versions are included for the unexpanded VIC (joystick optional) and the 64 with joystick.

During a stop for refueling on an out-of-the-way planet, you meet a mysterious old man who offers you the key to a fantastic treasure buried deep within a mountain. Many have tried to get to it, but all have been stopped by the unspeakable Rover of the Maze. The old man has the master control to a moving maze which guards the treasure. With his dying gasp he puts it in your hand. It looks like an antique Atari joystick. "Push the button," he says, "and you will control the maze." Never being one to pass up an adventure, you start off toward the mountain.

When you get there you find yourself on one side of a slowly moving maze. Every once in a while the dark red Rover passes your way. If you push the button on the joystick, the maze speeds up; if you release the button, the maze slows down. Armed with that secret you enter the maze. To get the treasure you must move as far as you can to the right side of the screen.

Game Movement

"Moving Maze" uses Player/Missile Graphics with string manipulation. The heart of the game is the technique in lines 2210 and 2217. This routine scrolls the dimensioned PM$ RAM that is devoted to Players 1, 2, and 3. In this game the vertical yellow lines that form the maze are these players. The speed is controlled by lines 2400 and 2410, where the scrolling is increased or decreased with each pass through the loop.

You move vertically and horizontally with a joystick. The difference in the two motions is that you can move horizontally only one increment at a time. This is controlled by setting and unsetting the flag (F1) in lines 2300, 2301, and 2305, and is necessary due to the speed with which the program executes and the lack of sensitivity of the Atari joystick. Without this flag, it is too easy to move two steps at once and crash into a wall.

Hitting a maze wall costs you one life and sends you back to the start. If the Rover runs over you, it costs you two lives (but sometimes you will be lucky and lose only one and not be sent back to the beginning). You have five lives to lose. Your final score will be 300 points, less one point per second it takes you to get through, plus 100 points for each life you have left when you finish. The maximum score is 800 points, but it is impossible to achieve. A good score is 750.

A ship is about to enter the maze in the VIC version of "Moving Maze."

Obstacles

The first difficulty is maneuvering through the walls of the maze, which are set up in the subroutine at the 5000 lines. Note that in line 55 the PM$ was not cleared to all blanks but was set to 146. This turned on bits 1, 4, and 7, which are those corresponding to 2, 16, and 128, respectively. Thus their sum, 146, is put into all of the string characters. In lines 5000 through 5040I set some of these lines to other combinations of 2, 16, and 128, specifically, 18, 130, and 144. This sets up a random series of openings in the lines. However, since this is random, there may never be an opening in some walls, so lines 5050, 5060, and 5070 create such openings. Line 5073 puts blanks into the Missile and Player 0 pages, and lines at 5080 read in the shapes for Player 0 and the Rover which are the combination of the four missiles. Player 0 has two shapes, the normal playing shape and the explosion shape.

The next difficulty is avoiding the Rover, who sweeps the corridors of the maze. Its movement is not totally random, however. In the routine at 5200, the range of the random variable for the Rover depends upon your location in the maze. If you are outside, all corridors are equally likely. However, the farther you get into the maze, the less "choice" the Rover has. When you are in the last corridor, the Rover roams only the last two corridors. Thus, the closer you get to exiting the maze, the more likely the Rover is to attack you in that corridor. Since the Rover (the computer) knows where you are, it can attack you more frequently when you are closest to winning. The Rover is not a typical adversary.

Colliding with the maze wall is handled in the 5100 lines. This routine writes in the explosion shape, provides an audio effect, decreases the lives, does some housekeeping, and then puts the player back to the beginning with the original shape. The 5400 lines handle being run over by the Rover.

Other Game Features

The routine at line 5700 handles the timing and scoring for the game. Line 5700 calculates the number of seconds since the internal clock in registers 18, 19, and 20 was reset. When the game first comes on, it has measured the time since the GRAPHICS 0 call in line 30018, which resets them automatically. These are reset within the game in line 5790. Register 20 is read first and reset last since it changes the fastest. This method also gives the most accurate time measurement.

Line 5710 determines the score, and the second statement in that line requires that you complete the maze to get any score at all. Therefore, winning requires completing the maze and moving your player to the right. The rest of the lines are resets for a new game.

Finally, the data for the player, the Rover, and the explosion are in lines 10000-10020.

The string manipulation technique in this game uses scrolling to good advantage. It permits the user to control the speed of the motion and to employ it in the game as an additional control variable. This adds complexity and requires more than a little getting used to in order to play the game well.

The technique also permits a very compact game. The program requires a bit over 5K and, when running, well under 10K. Further, I made no use of the unused 2K in PM$ but rather DIMensioned another array B$ for convenience. As to the power of this technique, it would be difficult to find another game using full P/M graphics in single-line resolution with as much motion and challenge that uses so little RAM. This is why I urge you to examine and master the technique.

"Moving Maze," Atari version.

VIC Notes

Marc Sugiyama Programming Assistant

The VIC version of "Moving Maze" (Program 2) uses the same game layout as the Atari version, but the rules of the game have been changed. Whenever you run into a wall or the Rover, you are sent back to the beginning of the maze, without exception. You maneuver through the maze using the I, J, K, and M keys or a joystick. Pressing the space bar or the fire button on the joystick causes the maze to speed up, but you lose one point every time the maze moves. You cannot move while the joystick button or the space bar is depressed. When you complete a maze, another will appear, but the openings in the walls will be smaller. The game ends when you lose all five lives.

Moving Maze uses up almost all of the memory of an unexpanded VIC, so do not enter any extra spaces or REMs. Also, the program will not handle VIC's floating memory, so remove any expansion memory cartridges.

Guide your shuttle through the maze. 64 version

64 Notes

Eric Brandon, Programming Assitant

The Commodore 64 version of "Moving Maze" has been renamed "Shuttle Escape," since it has a space shuttle theme.

Shuttle Escape plays much like the other versions. The main difference is that a quantity called FUEL has been added to the game. You begin with 2000 fuel units which you lose at the rate of 60 units each second whether the shuttle is moving or not. If you touch a wall or one of the roving droids, you lose 100 units each 1/60 second. When you have run out of fuel, the game is over. Fortunately, you can refill your tanks by reaching the right-hand side of the screen.

If you want to stop the game for a moment, just hold down the SHIFT key. If you want to stop the game for a longer period of time, use SHIFT LOCK.

You can speed up the movement of the walls by holding down the fire button on the joystick. This won't make gaps appear any sooner, but it will speed up any gaps that are already there. The penalty is that while the fire button is down, your fuel disappears twice as fast.

Programming Shuttle Escape revealed some interesting problems. The first is that sparkle–little specks of snow–appears on the screen. Usually this causes no difficulty, but when you try to use the VIC-II's sprite-background collision detection register, it turns out that sprites can collide with sparkle!

What this meant to Shuttle Escape was that occasionally, for no apparent reason, the shuttle would "collide" and you would lose 100 fuel units. Since moving the character set eliminates sparkle, it was relocated to $3000.

Another quirk of the 64 is that the VIC-II chip can look at only 16K of memory at a time. When you turn on your machine, it is looking at the first 16K block from $0000–$3FFF. It was decided to leave it there for simplicity. This meant that the sprite data, the relocated character set, and the entire BASIC program all had to be squeezed into 16K. Because of this memory limitation, when the machine language creates a character set at $3000, it destroys the DATA statements in the program. Fortunately, the DATA statements are no longer needed since they have already been POKEd into memory.

Because running the program will destroy it, be sure that when you type it in, you SAVE it before you try to RUN.