print "Bouncing Ball Animation"

rem set up initial position for ball, and its speed
x = 10
y = 10
r = 10
xinc = 5
yinc = 4

moveBall:
  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
  gosub drawBall 
  goto moveBall 

drawBall:
  color black
  circle x, y, r
  return