Type in your first game One of the most important features of the CPC464 is its ability to do a lot with only a minimum of programming effort. The programs in this issue demonstrate this facet of the system, and this version of the well known ‘breakout' style of game manages to fit all the essential features into a single page listing. There's even a comprehensive range of sounds to support the visual activity. The cursor keys or joystick control the bat that runs along the bottom of the screen. Stop the ‘ball' (it's actually a square, but you could chose another character. Line 300 sets up the bat with character 233. Commentary - 10-60 Set up the constants for the program. The sound tone and volume envelopes and mode.
- 70-130 Draws the new opening screen.
- 140-150 Draw the ‘bat'.
- 160-190 Every time a life is lost (ie you miss the ball and it drops off the bottom of the display) this section generates a random entry for the next ball.
- 200-320 The main program loop. It ‘Undraws' the ball (by overprinting the old position with a space), then draws the new position. The routine also spots the boundaries and produces an appropriate noise -and increments the score when the topline is eaten away.
Subroutines - 330-350 This provides the ‘end of a life' condition if you miss the ball in 240.
- 360-380 This routine, called from 220, scans the keyboard or joystick to move the bat.
- 390 Called from the midst of 260, this routine erases the block that has been hit by the ball by replacing it with a space character.
- 400-410 When the lives reach zero (line 330), this re-initialises the life count and score before restarting at line 60.
- 420 The score update routine, called from 260, 270 or 280, depending on which block has been knocked from the ‘wall'.
|