Bugs is a simple game which I hope will show that some
good games can be written for your Atari even if you do not understand some of the more advanced programming techniques. No
player missile graphics, no VBI routines, all of the action is achieved by POKEs to the screen. By level 9 the action gets quite fast.
You play the part of a ladybird who has to harvest a whole host of aphids by collecting them into one of four 'nests' on each side of the screen. Dotted around the place are several mushroom looking things which, if you touch them, will hatch out into more aphids. These are poisonous to a degree and will sap your strength but strength can be made up by pushing the aphids right into the nests and killing them. There are some aphids which are deadly (the orange ones)
and touching these will mean instant death. These will multiply if you are not quick enough in collecting the green aphids. If your strength falls to zero, you die and you must have a certain strength ratio to progress to the next level.
In order to achieve the maximum speed possible in Basic, the main game loop has been kept short and all routines which may be needed during the course of play are at the beginning of the program. Routines which are used only once or infrequently are put at the end of the program.
Line 10 sends the program immediately to the initialisation and titles.
Line 20 Is a simple delay loop with the variable DL set at different points in the program. By putting this loop at the beginning of the program more accurate timing can be achieved.
Lines 30 - 50 maintain the score. The variable SC keeps track of the points scored by killing aphids less points deducted for hatching them out. CSC is the maximum score at any one point during the game and SCORE is only updated if the points gained exceed the maximum so far. Thus hatching an aphid puts you back a number of points and you must kill more to get to a stage where you can increase your score. STR is a measure of your strength and if this falls to 0 the program jumps to the death routine. Line 50 stops the 'attract' mode.
Lines 60 - 150 are the main subroutine to determine if the aphids you are collecting collide with anything. The variables M and M2 hold the next location to which the aphid will be pushed. If that location is a 'mushroom' then the routine
jumps to line 150 which hatches out the mushroom and decreases your score. If the aphid is going to collide with anything else (line 70) then we must determine if it is possible for the aphid to move aside. This is determined in lines 95 - 110 which search an array for all possible locations of escape. If none can be found, the program exits the loop to line 115 which kills the aphid by poking the ladybird into the aphid's position. The score is increased in line 120 and this line also resets the timer and checks to see if all the bugs have been killed. If there is room for the aphid to escape then line 105 jumps out of the loop and returns to line 75 which places the aphid at the next available blank position.
Lines 200- 255 are the main game loop. Line 200 reads the joystick and if it is not being used, moves your ladybird to a new position chosen randomly from the array MPOS. This line also contains a delay routine according to the level of the game. Line 210 determines the position you are trying to move to if the joystick is active and the following lines determine if something is in that position. Table 1 will show you which characters you might bump into and you can then see where the program branches. Line 240 contains a delay loop to set the action at a speed commensurate with current level and line 245 moves your ladybird to the next position.
Lines 500 - 580 determine bonuses and take you to the next level when all the bugs have been killed. Note that line 500 will skip the bonus and next level if you have failed to improve your score in a particular level. These lines are fairly simple and merely give you 5 bonus points for each remaining mushroom and then increase the level (LV).
Lines 600 - 665 are the death routine reached either by hitting the killer bug (line 230) or by losing all your strength (line 45). Line 600 simply pokes your position with all of the characters available
accompanied by some sound before going on to give an end of game message.
Lines 800 - 820 are the sounds used when an aphid is killed. Note that the routine is used in different ways by jumping to the beginning (line 530) or entering part way through (line 115). By
entering a subroutine at different points, one routine can serve several purposes.
Lines 900 - 930 add a new orange bug if a certain time has elapsed without killing an aphid (line 235). It simply peeks the screen to find a blank position and then pokes in the character representing the orange bug. If you want more killer bugs to appear reduce the figure 3 in line 235.
Lines 1000 - 1100 are the titles and options and are quite straightforward. Note again the sound subroutine being used at different points.
Lines 1200 - 1280 initialise things. The array ST holds the amount by
which various positions of the joystick will move your character. By reading this array in line 210 much greater speed can be achieved than by using IF ... THEN statements. MPOS holds the 8 possible positions of movement from a given point Line 1250 lowers RAMTOP to make way for the redefined character set.
Table 1 - Refer to Page 55 of the ATARI BASIC REFERENCE MANUAL
Lines 1500 - 1790 draw the surrounding border and poke in all the characters of the display. The various numbers in the loops and in the data statements are offsets from the top left position of the screen. Lines 1630 - 1660 poke in the mushrooms and lines 1700 - 1730 poke in the bugs provided that nothing already occupies the space. If it does then a blank space is found.
Lines 2000 - 2050 alter the display list to give two lines of Graphics 1 followed by 21 lines of Antic mode 4 (Graphics 12) and one line of Graphics 1. Note that the screen is switched off in line 2005 to cut out unpleasant displays.
Lines 2500 - 2595 change the character set. The routine in line 2520 to move the character set comes from Stan Ockers and is a very fast way to
move a 1K block of memory from one point to another. Four characters are redefined to give the various coloured players. There is no room here to explain how characters are made up in Antic mode 4 but if you want to do it simply and see the results immediately, get hold of the program Magic Window.