Commodore 64 User Manual page 76

Hide thumbs Also See for 64:
Table of Contents

Advertisement

Line 80 adds the direction factor to X. Line 90 tests to see if the ball
has reached one of the side walls, reversing the direction if there's a
bounce. Lines 100 and 110 do the same thing for the top and bottom
walls.
Line 120 sends the program back to display and moves the ball
again.
By changing the code in line 50 from 81 to another character code,
you can change the ball to any other character. If you change DX or DY
to 0 the ball will bounce straight instead of diagonally.
We can also add a little more intelligence. So for the only thing you
checked for is the X and Y values getting out of bounds for the screen.
Add the following lines to the program.
21 FOR L = 1 TO 10
25 POKE 1024 + INT(RND( 1)*1000), 166
27 NEXT L
55 IF PEEK(1024 + X + 40*Y) = 166 THEN DX _ -DX:
GOTO 80
105 IF PEEK<1024 + X + 40*Y) = 166 THEN DY = -DY:
GOTO 100
Lines 21 to 27 put 10 blocks on the screen in random positions. Lines
85 and 105 check (PEEK) to see if the ball is about to bounce into a
block, and changes the ball's direction if so.
0
0
e
0
66

Hide quick links:

Advertisement

Table of Contents
loading

Related Products for Commodore 64

Table of Contents