Never knew a water effect could be this easy. Click the mouse to drag through the water.
+ Code Snippetsync on
rem load image "brick.bmp",1
lock pixels
box 0,0,256,256,rgb(0,0,100),rgb(0,0,100),rgb(0,0,100),rgb(0,0,100)
for x=0 to 255 step 32
for y=0 to 255 step 32
ink rgb(rnd(255),rnd(255),rnd(255)),0
box x,y,x+25,y+25
next y
next x
unlock pixels
get image 1,0,0,256,256
make memblock from image 1,1
dim heights(257,257,1)
dim pos(256,256)
for x=1 to 256
for y=1 to 256
pos(x,y)=12+(((y-1)*256)+x-1)*4
next y
next x
global cur=0
global old=1
cls 0
do
mx=mousex()
my=mousey()
if mouseclick()>=1 and mx>=0 and mx<=255 and my>=0 and my<=255 then heights(mx+1,my+1,cur)=-300*mouseclick()
if rnd(4)=0 then heights(rnd(255)+1,rnd(255)+1,cur)=-400
updateheights()
updateimage()
sync
loop
function updateheights()
for x=1 to 256
for y=1 to 256
heights(x,y,old)=(((heights(x+1,y,cur)+heights(x-1,y,cur)+heights(x,y+1,cur)+heights(x,y-1,cur)) div 2)-heights(x,y,old))*0.995
next y
next x
old=1-old
cur=1-cur
endfunction
function updateimage()
lock pixels
adr=get pixels pointer()+2564
for y=1 to 256
for x=1 to 256
xoff=(heights(x+1,y,cur)-heights(x-1,y,cur)) >>4
yoff=(heights(x,y+1,cur)-heights(x,y-1,cur)) >>4
x2=((x+xoff-1) mod 256 )+1 : y2=((y+yoff-1) mod 256 )+1
*adr=memblock dword(1,pos(x2,y2))+100
inc adr,4
next x
inc adr,1536
next y
unlock pixels
endfunction