Challenge:
Version:
(Version B)
Winner?:
No
Code Snippet:
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 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) <= 100 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(200,200,rnd(55)+200) 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) for i = 1 to 6 x = rain(t).x + sin(angle)*i y = rain(t).y + cos(angle)*i pDot(x,y,rgb(0,0,255-i*30)) next i next t unlock pixels circle mousex(), mousey(),10 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