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