backdrop on
color backdrop 0
sync on
sync rate 0
hide mouse
Global width = 640
Global height = 480
type particle
x as float
y as float
vx as float
vy as float
f as float
g as float
color as dword
endtype
amount = 3000
dim rain(amount) as particle
for t = 1 to amount
rain(t).x = rnd(width)
rain(t).y = rnd(height)
rain(t).color = rgb(0,0,255)
next t
ballsize = 20
ballr2# = ballsize*ballsize
repeat
lock pixels
for t = 1 to amount
oldx = rain(t).x
oldy = rain(t).y
rain(t).x = rain(t).x + rain(t).vx*rain(t).f
rain(t).y = rain(t).y + rain(t).vy*rain(t).f + rain(t).g
if rain(t).g < 5 then rain(t).g = rain(t).g + 0.01
if rain(t).f > 0
rain(t).f = rain(t).f - 0.1
else
rain(t).f = 0
endif
rem if rain hits ball
if ((rain(t).x-mousex())^2 + (rain(t).y-mousey())^2) <= ballr2#
x# = (rain(t).x - mousex())/10.0
y# = (rain(t).y - mousey())/10.0
rain(t).vx = x#
rain(t).vy = y#
rain(t).f = 4
endif
if rain(t).y >= height OR rain(t).y <= 0 OR rain(t).x >= width OR rain(t).x <= 0
rain(t).x = rnd(width)
rain(t).y = 1
rain(t).vx = 0
rain(t).vy = 0
rain(t).g = 0
rain(t).color = rgb(rnd(255),rnd(255),rnd(255))
`rain(t).color = rgb(0,0,255)
endif
angle = wrapvalue(atanfull(oldx-rain(t).x,oldy-rain(t).y))
pDot(rain(t).x,rain(t).y,rain(t).color)
sa# = sin(angle)
ca# = cos(angle)
for i = 1 to 11
x = rain(t).x + sa#*i
y = rain(t).y + ca#*i
c = 255-i*21
pDot(x,y,rgb(c,c,c))
next i
next t
unlock pixels
circle mousex(), mousey(),ballsize
sync
until spacekey()
function frictionDirection#(f as float)
if f > 0 then exitfunction 1
if f < 0 then exitfunction -1
endfunction 0
REM function borrowed from Coding Fodder's Rain code
function pDot(x as integer, y as integer, color_value as dword )
if x > 0 and x < width and y > 0 and y < height
start = get pixels pointer()
repeat_number = get pixels pitch()
bits_per_pixel = bitmap depth(num)/8
pointer = start + y*repeat_number + x*bits_per_pixel
*pointer = color_value
endif
endfunction
PETA - People for the Eating of Tasty Animals