/usr/share/doc/basic256/examples/ballaccel.kbs is in basic256 0.9.6.69a-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | print "Using Newton's laws to make the ball bounce realistically"
rem set up initial ball position and speed
x = 20
y = 100
r = 10
yvel = -1.0
xvel = 1.10
yacc = .0098
fastgraphics
loop1:
clg
rem change the downward velocity according to the acceleration
yvel = yvel + yacc
rem calculate new position
y = y + yvel
x = x + xvel
rem check for collisions
if y > 289 then yvel = -0.9 * yvel : y = 289 : xvel = xvel * 0.9
if x > 285 then xvel = -xvel : x = 285
if x < 10 then xvel = -xvel : x = 10
rem draw the ball
color darkblue
rect 0,0,300,300
gosub drawBall
if xvel * xvel < 0.0001 then end
goto loop1
drawBall:
color darkgray
circle x, y, r
color gray
circle x, y, r - 2
refresh
return
|