1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
print "Bouncing Ball Animation v2 - without gosub or goto"
rem set up initial position for ball, and its speed
x = 10
y = 10
r = 10
xinc = 5
yinc = 4
while true
x = x + xinc
y = y + yinc
rem This is where we check for collisions with the wall
if y > 280 then yinc = -yinc : sound(440, 50)
if x > 280 then xinc = -xinc : sound(440, 50)
if x < 14 then xinc = -xinc : sound(440, 50)
if y < 14 then yinc = -yinc : sound(440, 50)
rem clear the screen, then draw the ball
clg
call drawBall(x,y,r)
end while
subroutine drawBall(x,y,r)
color black
circle x, y, r
end subroutine
|