Rem Project: WaterPhysics
Rem Created: 23/05/2003 19:42:37
sync on
Rem Initialize Light
color backdrop rgb(0,0,0)
make light 1
position light 1,200,30,0
point light 1,0,0,0
color light 1,RGB(255,255,255)
SET LIGHT RANGE 1, 10000
make light 2
position light 2,-40,30,0
point light 2,0,0,0
color light 2,RGB(255,255,255)
SET LIGHT RANGE 1, 10000
hide light 0
Rem Initialize Transformation Arrays
dim Buffer1#(100,100)
dim Buffer2#(100,100)
For x = 0 to 100
For y = 0 to 100
Buffer1#(x,y)=0
next y
next x
Rem Setup Camera
set camera range 1,100000
autocam off
position camera 0,250,-450
point camera 0,0,0
set camera fov 50
Rem Create WaterMatrix
load image "water.jpg",1
make matrix 1,500,500,100,100
position matrix 1,-250,0,-250
prepare matrix texture 1,1,1,1
set matrix 1,0,1,1,1,1,0,1
ghost matrix on 1
Rem Main Loop
do
gosub _processdrops
gosub _processwater
if escapekey() then exit
update matrix 1
sync
Text 140,30,"Written in DBPro by Reda Borchardt"
Text 140,50,"LMB & RMB for waves ---- visit www.open-dna.com"
Text 140,70,"Hold Shift key for pudding effect"
loop
end
Rem Water Physics Subroutines
_processwater:
for x=1 to 99
for y=1 to 99
Buffer2#(x,y) = (Buffer1#(x-1,y) + Buffer1#(x+1,y) + Buffer1#(x,y+1) + Buffer1#(x,y-1)) / 2.1-Buffer2#(x,y)
if shiftkey()=1
Buffer2#(x,y) = Buffer2#(x,y) / 1.19
else
Buffer2#(x,y) = Buffer2#(x,y) / 1.01
endif
next y
next x
gosub _altermatrix
gosub _swapbuffer
return
_swapbuffer:
For x = 0 To 99
For y = 0 To 99
temp1# = Buffer1#(x,y)
temp2# = Buffer2#(x,y)
Buffer1#(x,y) = temp2#
Buffer2#(x,y) = temp1#
Next y
Next x
Return
_altermatrix:
For i = 0 To 99
For j = 0 To 99
set matrix height 1,i,j,buffer2#(i,j)
Next j
Next i
return
_processdrops:
if mouseclick()=1
For i = 15 To 20
For j = 25 To 30
buffer2#(i,j)=0.1
Next j
Next i
text 20,20,"Left Click"
endif
if mouseclick()=2
For i = 70 To 75
For j = 60 To 65
buffer2#(i,j)=0.01
Next j
Next i
text 20,30,"Right Click"
endif
return
thats from a guy called Reda - should help you out a bit