set display mode 1680,1050,32
sync on : sync rate 60
`autocam off
`512 176
ink rgb(0,0,0)
```````````````````
num=15
dim a1#(num)
dim b1#(num)
dim af1#(num)
dim bf1#(num)
dim af2#(num)
dim bf2#(num)
dim a2#(num)
dim b2#(num)
dim detx#(8)
dim dety#(8)
dim detx2#(15)
dim dety2#(15)
dim at#(num)
dim bt#(num)
dim oldx#(num)
dim oldy#(num)
detx#(0)=0.0
dety#(0)=-1.0
detx#(1)=-1.0
dety#(1)=-1.0
detx#(2)=-1.0
dety#(2)=0.0
detx#(3)=-1.0
dety#(3)=1.0
detx#(4)=0.0
dety#(4)=1.0
detx#(5)=1.0
dety#(5)=1.0
detx#(6)=1.0
dety#(6)=0.0
detx#(8)=0.0
dety#(8)=-1.0
detx#(8)=1.0
dety#(8)=-1.0
a=0
for f=0 to 14 step 2
detx2#(f)=detx#(a) `detx#(f)*2.0
dety2#(f)=dety#(a)`dety#(f)*2.0
detx2#(f+1)=0.5*(detx#(a)+detx#(a+1)) `detx#(f)*2.0
dety2#(f+1)=0.5*(dety#(a)+dety#(a+1))
inc a
next f
dim cols(15)
c=128
for f=0 to 15
cols(f)=rgb(255,255,c+f)
next f
a=0
for f=0 to num
a1#(f)=10+rnd(1600)
b1#(f)=10+rnd(980)
a$="0.4"+str$(a)
a#=val(a$)
inc a,2
af1#(f)=a#
af2#(f)=a#
`if rnd(1)=0 then a#=-a#
bf1#(f)=a#
bf2#(f)=a#
a2#(f)=rnd(359)
next f
dim gop(num)
````````````````
op=1
`````````````````````````````````
do
cls
for f=0 to num
oldx#(f)=a1#(f)
oldy#(f)=b1#(f)
a1#(f)=a1#(f)+af1#(f)
b1#(f)=b1#(f)+bf1#(f)
if a1#(f)>1670 or a1#(f)<10 then af1#(f)=-af1#(f)
if b1#(f)>1000 or b1#(f)<10 then bf1#(f)=-bf1#(f)
a=a1#(f)
b=b1#(f)
ink cols(f)
FilledCircle( a,b,40)
next f
````````````````````````````````````
`goto miss
ink rgb(222,222,222)
`sync
for f=0 to num
a#=a1#(f)
b#=b1#(f)
t=0
`dec gop(f):if gop(f)>-1 then goto plop
lopp:
x#=a#+43*sin(t*22.5)
y#=b#+43*cos(t*22.5)
ff=0
x=x#
y=y#
`box x,y,x+2,y+2
p=point(x,y) and 0xfe
if p>0
`if oldx#(f)>0.0 then a1#(f)=oldx#(f):b1#(f)=oldy#(f):oldx#(f)=0.0:oldy#(f)=0.0
ff=1
`gop(f)=1
p=p-128
`p1#=af1#(f)
`at#(p)=-p1#*0.3 `this amount of energy is transferred to the ball hit
at#(f)=at#(f)+detx2#(t)*0.5
`af1#(p)=p1#*r#
bt#(f)=bt#(f)+dety2#(t)*0.5
`bf1#(f)=p1#*r#
`bt#(p)=p1#*0.3 `this amount of energy is transferred to the ball hit
`bf1#(f)=p1#*r#
endif
`if ff>0 then goto plop
` then af1#(f)=detx#(t):bf1#(f)=bf1#(f)+dety#(t):`goto ttt
inc t:if t<16 then goto lopp
plop:
next f
for f=0 to num
af1#(f)=af1#(f)+(at#(f)*0.23)
bf1#(f)=bf1#(f)+(bt#(f)*0.23)
at#(f)=0.0
bt#(f)=0.0
next f
`fade bitmap 0,9
`paste image 1,0,20,1
miss:
inc delay
`ink rgb(0,200,0)
`text 20,20,str$(a)+" "+a$+" "+str$(f)
op=-op
`if op>0 then gosub saver
sync
loop
`````````````````````````````````````````````````
`````````````````````````````````````
loader:
a$="000000"+str$(fram):a$=right$(a$,6)
b$="E:\frames14\pinball_"+a$+".png"
load image b$,999,1
inc fram:`if fram>66 then fram=1
return
loader2:
a$="000000"+str$(fram3):a$=right$(a$,5)
b$="E:\frames4\"+a$+".bmp"
load image b$,998,1
inc fram3:`if fram>66 then fram=1
return
saver:
sv$="000000"
inc fra:if fra>2400 then end
sv1$=str$(fra):sv$=sv$+sv1$
sv$=right$(sv$,5)
fil$="I:\frames12\":fil$=fil$+sv$+".bmp"
get image 2000,0,0,1680,1050,1
save image fil$,2000
return
function FilledCircle( CX as integer, CY as integer, R as integer )
local x as integer
local y as integer
local i as integer
local s as integer
` Precalculate the square of the radius - this is the hypotenuse
i=R*R
` Calculate the size of the central square
s=R*0.70710678 : ` this number is sin(45)
` Draw it
box CX-s, CY-s, CX+s+1, CY+s+1
s=s+1
` Loop through the bit we have not yet drawn
for y=s to R
x=sqrt( i-(y*y) )
` Draw top and bottom
box CX-x, CY-y, CX+x+1, CY-y+1
box CX-x, CY+y, CX+x+1, CY+y+1
` Draw left and right
box CX-y, CY-x, CX-y+1, CY+x+1
box CX+y, CY-x, CX+y+1, CY+x+1
next y
endfunction