File: ballanim.kbs

package info (click to toggle)
basic256 0.9.6.69a-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 26,304 kB
  • sloc: cpp: 7,778; yacc: 926; lex: 575; sh: 21; makefile: 7
file content (26 lines) | stat: -rw-r--r-- 547 bytes parent folder | download | duplicates (6)
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"

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