File: ballanim_2.kbs

package info (click to toggle)
basic256 2.0.99.10-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,888 kB
  • sloc: cpp: 17,185; yacc: 4,025; lex: 1,466; java: 1,091; sh: 39; xml: 33; makefile: 20
file content (26 lines) | stat: -rw-r--r-- 608 bytes parent folder | download | duplicates (4)
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