sync on: sync rate 60
set display mode 1024,768,32
 
dim particle#(200,6)
dim numparticles(0)
dim lifespan(0)
 
numparticles(0) = 200
lifespan(0) = 100
 
gosub make_texture
for id= 1 to numparticles(0)
   make_drops(id)
   make_splash(id+numParticles(0))
next id
 
make matrix 1,500,500,50,50
fog on
fog color rgb(0,0,129)
fog distance 50
 
cam_pos_x#=250
cam_pos_z#=250
 
ink rgb(255,255,255),0
 
do
   set cursor 0,0
   print "use W,S and the mouse to move"
   print "fps: ",screen fps()
   speed#=(keystate(17)=1)-(keystate(31)=1)
   cam_pos_x#=newxvalue(cam_pos_x#,cam_ang_y#,speed#/5)
   cam_pos_z#=newzvalue(cam_pos_z#,cam_ang_y#,speed#/5)
 
   cam_ang_y#=cam_ang_y#+mousemovex()
   cam_ang_x#=cam_ang_x#+mousemovey()
 
   position camera cam_pos_x#,5,cam_pos_z#
   rotate camera wrapvalue(cam_ang_x#),wrapvalue(cam_ang_y#),0
   updatepsystem(cam_pos_x#,cam_pos_z#)
sync
loop
 
make_texture:
   ink rgb(255,255,255),0
   circle 50,50,49
   ink rgb(100,100,100),0
   circle 50,50,50
   circle 50,50,48
   get image 1,0,0,101,101
return
 
function make_splash(id)
   make object plain id,1,1
   xrotate object id,90
   texture object id,1
   ghost object on id
endfunction
 
function make_drops(id)
   make object box id,0.05,1,0.05
   ghost object on id
endfunction
 
function updatepsystem(emitterx#,emitterz#)
  for t= 1 to numparticles(0)
    if object position y(t)>0.5
      position object t,object position x(t),object position y(t)-0.4,object position z(t)
      updatesplash(t+numParticles(0))
    else
      newsplash(t+numParticles(0),object position x(t),object position z(t))
      position object t,emitterx#+rnd(800)/10.0-40,10+rnd(5),emitterz#+rnd(800)/10.0-40
    endif
  next t
endfunction
 
function updatesplash(t)
    if particle#(t,0)>0
      particle#(t,0)=particle#(t,0)-2
      scale object t,90-particle#(t,0),90-particle#(T,0),100
    else
      hide object t
      show=0
    endif
endfunction
 
function newsplash(t,emitterx#,emitterz#)
      particle#(t,0)=lifespan(0)/5*4+rnd(lifespan(0)/5)
      position object t,emitterx#,0,emitterz#
      scale object t,0,0,100
      show object t
endfunction