include "window.inc"
Window "Raindrops" ,640,480,2
sys_mode=4

sys x[500], y[500], z[500] 
sys i,r,g,b,rr,pic, drop 
'pic = LoadBmp "images/rainbow",0
drop= LoadBmp "images/mydrop",0

'Raindrops

For i=0 To 500
x[i] = Rand(0,640)
y[i] = Rand(0,460)
z[i] = Rand(1,3)
Next

'Rainbow

sys rx[5000],ry[5000],rc[5000],ri,rs
ri=1
while ri<5000
rx=rand(-320,320)
ry=rand(-320,320)
rr=hypot(rx,ry)
if rr>260 and rr<300 and ry<0
  rx[ri]=rx+320
  ry[ri]=ry+400
  rs=(rr-260)*6
  r=rs 'red
  g=240-abs(rs-128) 'green
  b=240-rs 'blue
  rc[ri]=r+g*256+b*65536
  ri++
end if
wend

'scene falling raindrops

While AscKey=0 and WinExit=0
ClsColor 100,180,180
'ClsColor 0,0,0

for i=1 to 5000
  pixel rx[i]-1,ry[i]-1,rc[i]
  pixel rx[i]+1,ry[i]+1,rc[i]
next

For i=0 To 500
y[i] = y[i] + z[i]
if y[i] >480
   x[i] = Rand(0,649)
   y[i] = Rand(0, 1)
   z[i] = Rand(1,3)
End if
SetBmp drop,x[i],y[i],16,16,0
Next
Events
FlipBuffer
Wend
WinEnd