October 2013 41
this test can be downloaded from the article link, along
with the example game; file name is GAME_DIAG.BAS.
How the Game Works
Once you have tested the components of the circuit,
you will want to load the example game for the project.
The game is entitled DEFLEC TO. This BASIC program
serves as an example as to how easy it is to program this
The game begins in the ready to start mode with a
red game paddle moving back and forth until you press
the center button. After pressing the center button, a ball
descends at some random angle toward the bottom of the
display as shown in Figure 9.
The incoming ball can be deflected by positioning
your paddle using the left and right buttons. If you miss
the incoming ball, a MISS sound occurs and you must
press the center button again to initiate the next ball. If
you deflect the ball, it returns upward at an appropriate
angle back toward the top of the display.
As the balls get deflected, it turns on the pixel that
gets struck as it hits the boundary. If the ball strikes a tile
that has already been lit, the ball gets deflected and
returns as the ball in play. The game
is won after lighting all the tiles
across the top.
You may want to rewrite the
program so that you must keep the
last ball in play until you strike the
last tile or you lose all of the seven
previously turned on tiles.
I have broken down some of the
key elements of the game design in
hopes that it may help you to
understand the program better. The
specific named ports that tie to the
rows and columns of the display have
been symbolized to make
programming easier. The primary
routine in the game is the player
paddle position. Figure 10 illustrates
the seven positions the paddle can
be in during game play.
The program sets paddle
positioning as the primary event, and
polls the left and right direction
buttons between the start of all other
events. A variable used to represent
the symbol XPOS is incremented or
decremented with each push of the
buttons tied to ports C. 2 and C. 3. If
XPOS = 1, row R7 and R8 are held
low and column C1 is toggled to
light the leftmost paddle position. For
the incoming balls, fixed diagonal or vertical lighting
subroutines are jumped to randomly whenever the center
button connected to the port C. 3 is pressed.
■ FIGURE 9.
Shot of a