Posted: 20th Mar 2004 18:07
Never knew a water effect could be this easy. Click the mouse to drag through the water.

+ Code Snippet
sync 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


Kevil
Posted: 20th Mar 2004 19:07
Holy cow!

Nice one Kevil, this is one that'll prove very very valuable.

Posted: 20th Mar 2004 19:54
sweeeeet that is seriouusly cool, do you think that if you mapped the image onto a matrix it would look any good?
Posted: 20th Mar 2004 21:01
nice
Posted: 21st Mar 2004 1:24
Red_eye: The code first calculates the height of the surface, and then calculates refraction based on that. So if you want to do this on a matrix, you can achieve the affect by setting the height according to the calculated height (which would be faster), but you won't be able to do proper refraction on matrix like this.

Kevil
Posted: 21st Mar 2004 18:46
could u also make this one working for DBC?
it looks really cool
Posted: 23rd Mar 2004 3:02
Wow...cool code! Alas, I am a DBC user and the code will not work for me.....
Posted: 28th Mar 2004 3:19
hello huge much beautiful one, I did not know that darck basic for he could make also this without DLL external. hello thanks
Posted: 28th Mar 2004 3:22
hello if possibly someone axes an effect example flame much realistic one, type heated text, etc.

help!!! post all samples

hello thanks
Posted: 30th Mar 2004 10:58
I get the following error???



Using DBPro 1.051
Posted: 30th Mar 2004 16:40
Hmm, strange. Shouldn't happen. Maybe you're trying to load your own image, that could be the problem.

Kevil
Posted: 30th Mar 2004 23:16
*adr=memblock dword(1,pos(x2,y2))+100
i get an error here.