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 41 42 43 44 45 46
|
print "Generate BASIC256 icon"
graphsize 512, 512
rem set up initial ball position and speed
x = 20 * graphheight / 300
y = 100 * graphheight / 300
r = 20
rw = 3
yvel = -1.0 * graphheight / 300
xvel = 1.10 * graphwidth / 300
yacc = .0098 * graphwidth / 300
fastgraphics
color darkblue
rect 0,0,graphwidth, graphheight
loop1:
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 > graphheight - r - 1 then yvel = -0.9 * yvel : y = graphheight - r - 1 : xvel = xvel * 0.9
if x > graphwidth - r - 1 then xvel = -xvel : x = graphwidth - r - 1
if x < r then xvel = -xvel : x = r
rem draw the ball
gosub drawBall
if xvel * xvel < 0.0001 then
refresh
end
end if
goto loop1
drawBall:
color darkgray
circle x, y, r
color gray
circle x, y, r - rw
if rand < .01 then refresh
return
|