EasyManua.ls Logo

Commodore 64 - Page 73

Commodore 64
176 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Line 80 adds the direction factor to X. Line90 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 far 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.
~; ~~~ELl~2~ ~OI~~(RND(1)*1000), 166~E~ COO!C)
27 NEXTL
85 IF PEEK(1024 + X + 40*¥) = 166 THEN DX = -OX:
GOTO 80
105 IF PEEK(1024 + X + 40*¥) = 166 THEN = -O¥:
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 bali's direction if so.
66

Table of Contents

Other manuals for Commodore 64

Related product manuals