Commodore VIC-20 User Manual page 75

Hide thumbs Also See for VIC-20:
Table of Contents

Advertisement

Play with this program a little. By changing the number in line
80 from an 81 to another character code, you can change the
ball to any other character. If you change either DX or DY to 0,
the ball will bounce straight instead of diagonally.
Now we can add a little more intelligence to this program. So
far the only thing we check for is the X and Y values getting out
of bounds for the screen. Add the following lines to the
program shown above. (Just type these lines and they'll be
added automatically)
32 FORL = 1TO10
35 POKE 7680 + INT (RND (1) *506), 102
37 NEXT
155 IF PEEK (7680+ X + 22*Y) = 102 THEN DX = -DX: DY = -DY:
POKE 36876, 180: GOTO 110
Lines 32 to 37 put 10 gray characters on the screen in random
positions. Line 155 checks ("PEEKs") to see if the ball is about
to bounce into a grey block, and reverses the ball's direction if
so.
See Appendices H and I for more information on animation.
65

Advertisement

Table of Contents
loading

Table of Contents