Birthday Game

Our anniversary game. Can you light the candle before you are blown out?

Volume 2

Number 1

March 1984

Here's your invitation to join in the celebrations

We're all having a party to mark the successful first year of The Micro User. Trouble is, no one can find a match to light the candle on the cake. Our Birthday program asks you to lend a hand.

BIRTHDAY is The Micro User's way of celebrating its first year of existence. All you have to do is to light the birthday candle at the bottom of the screen by guiding a flame from the top of the screen to the candle's wick.

To do this you steer a course between the walls, using standard movement keys.

You'll need the walls as windbreaks to shelter from the gusts of wind that threaten the flame. If they reach it, out it goes!

Watch out for those gusts. They keep on coming even if you don't move.

Worse still, some of these winds are fairly changeable. Every now and then a gust blows diagonally, cutting corners to catch the flame.

Even more devilish, they can combine, disguising two or more gusts as one.

Initially you are opposed by two gusts. But each time you're successful, you have an extra gust to face.

If you are blown out you get another go at the same level. After all, this is a birthday celebration!

If you're good enough you can keep going until you reach 20 gusts. So far we've only managed to survive 12!

This is how it works:

The program has to keep track of a lot of things — the positions of the walls (there are up to 80), the positions of the gusts (up to 20) and, of course, the position of the flame.

Constant checks have to be made to see, for example, that the gusts don't "blow down" walls.

Rather than record the x and y coordinates of each object, then check both against those of other objects. We've opted for recording positions with the formula:

position = x coordinate + 40 * y coordinate

Since in Mode 1 there are 40 characters to a row this gives each character cell on the screen a unique number, which can be quickly compared with others.

If we need the x and y coordinates we can find them with:

x coordinate = position MOD 40 y coordinate = position DIV 40

The procedure and variables description should make the rest of the game clear.

PROCEDURES

PROCinstructions [1300] prints out the instructions for the game in Mode 7.

PROCinit [1460] sets up the constants for the game, dimensions the arrays, defines characters and logical colours and sets the initial numbers of gusts (number%).

PROCsetup [200] sets the scene for each new "sheet". It calculates the number of walls needed (W%), clears out and lit, puts the candle and flame on the screen and calls procedures to place the walls and gusts.

PROCplacewalls [1070] randomly places walls on the screen. A REPEAT ... UNTIL loop ensures that no wall is placed on top of another by using FNtest.

PROCplacegusts [370] randomly places the required number of gusts on the screen using FNposition to make sure there isn't another gust too close and FNtest to avoid walls.

PROCMOVEgusts [300] uses a loop to call PROCmovegust the required number of times.

PROCmovegust [520] "intelligently" moves the gusts towards the flame by using the sign of the difference between the x coordinates, and that of the difference between the y coordinates to decide the directions horizontally and vertically the gust should move. It then picks one of these at random, occasionally allowing both — to give the dreaded diagonal movement. No movement is allowed if you run into the wall or the candle's wick (FNtest takes care of the rest of the candle!). Also, if a gust hits the flame, out is set.

PROCmoveflame [680] flushes the keyboard buffer, then quickly checks to see if any movement keys are pressed, and if the move is legal. If you're slow you miss your go. The procedure beeps, then checks to see if any gust has landed on the flame - if so out is set.

PROCmusic [860] when you light the candle this plays ... well, it's obvious isn't it?

FNtest [1220] checks to make sure a position doesn't contain a wall (using OSBYTE 135) or the bottom bits of the candle. We don't check for the wick here as we want the flame to be allowed to reach it. Gusts are prevented from blocking it within PROCmovegust [650].

FNpostion [990] makes sure that the gusts are not placed too close to each other initially.

Error Check [1580] traps the Escape key. It also prints out details of other errors you may have made.

VARIABLES

w% Number of walls.
number% Number of gusts at that flame.
light% Position of the moving flame.
flame% The position of the wick, used for checking a win.
w%( ) Holds the positions of walls.
gust%( ) Holds positions of gusts.
out Logical variable set if a gust "lands" on the flame.
lit Logical variable set if flame reaches the wick at flame%.
candle$, wall$, flame$ Strings containing the user defined character shapes plus any necessary colour changes and cursor movements.