my eyes are blurry staring at these waves... I can't even tell if it looks like water anymore...
to me it looks like a top-down view of the ocean from very high... not what I am going for... still don't know how to do all those thing in previous post....
Code: Select all
dim shared as ushort watermap1(400,400), watermap2(400,400)
dim shared as ubyte waterMask(400,400)
Type mouse
As Integer res
As Integer x, y, wheel, clip
Union
buttons As Integer
Type
Left:1 As Integer
Right:1 As Integer
middle:1 As Integer
End Type
End Union
End type
dim as mouse m
screenres 600,600,32
Dim image As Any Ptr = ImageCreate( 400, 400, RGB(0,0,0) )
randomize timer
' set the basic level of the watermaps
for i as integer = 2 to 399
for j as integer = 2 to 399
watermap1(i,j) = 0
watermap2(i,j) = 0
pset image, (i,j), rgb(10,40,130) 'water
next j
next i
' make some 'land' circles
for r as integer = 1 to 5
dim as integer size = 30 + rnd*30
dim as integer x = rnd*396+2
dim as integer y = rnd*396+2
circle image, (x, y),size, rgb(127,106,0),,,,F
circle image, (x, y),size, rgb(255,0,0)
next r
' make some 'land' squares
for r as integer = 1 to 5
dim as integer size = 30 + rnd*30
dim as integer x = rnd*396+2
dim as integer y = rnd*396+2
line image, (x,y) - step(size,size), rgb(127,106,0), bf
line image, (x,y) - step(size,size), rgb(255,0,0), b
next r
' put in border
line image, (0, 0) - (399,399), rgb(255,0,0), b
line image, (1, 1) - (398,398), rgb(255,0,0), b
line image, (3, 3) - (396,396), rgb(255,0,0), b
' put in some initial rain drops
for r as integer = 1 to 50
dim as integer x = rnd*396+2
dim as integer y = rnd*396+2
if point(x,y, image) = rgb(10,40,130) then ' if water, then....
watermap1(rnd*396+2, rnd*396+2) = 32000
end if
next r
cls
put (100,100),image, pset
' main loop
do
' put in some 'edge' disturbances
' for r as integer = 1 to 1
' watermap1(rnd*396+2, 2) = 32000
' watermap1(rnd*396+2, 398) = 32000
' watermap1(2, rnd*396+2) = 32000
' watermap1(398, rnd*396+2) = 32000
' next r
'
screenlock
put (100,100),image, pset
' emit entire coastline...one big wave
' if rnd > .9 then
' for i as integer = 3 to 396
' for j as integer = 3 to 396
' dim as integer col = point(i+100,j+100)
' if col = rgb(255,0,0) then
' watermap1(i,j) = 0
' watermap1(i-2,j) = 0
' watermap1(i+2,j) = 0
' watermap1(i,j-2) = 0
' watermap1(i,j+2) = 0
' 'if rnd > .99 then
' if point(i-2+100,j+100) = rgb(10,40,130) then watermap1(i-2,j) = 15000 + rnd* 15000
' if point(i+2+100,j+100) = rgb(10,40,130) then watermap1(i+2,j) = 15000 + rnd* 15000
' if point(i+100,j-2+100) = rgb(10,40,130) then watermap1(i,j-2) = 15000 + rnd* 15000
' if point(i+100,j+2+100) = rgb(10,40,130) then watermap1(i,j+2) = 15000 + rnd* 15000
' 'end if
' end if
' next j
' next i
' end if
' place some random shore emitters....
for i as integer = 3 to 396
for j as integer = 3 to 396
dim as integer col = point(i+100,j+100)
if col = rgb(255,0,0) then
watermap1(i,j) = 0
watermap1(i-2,j) = 0
watermap1(i+2,j) = 0
watermap1(i,j-2) = 0
watermap1(i,j+2) = 0
if rnd > .98 then
if point(i-2+100,j+100) = rgb(10,40,130) then watermap1(i-2,j) = (18 + rnd* 10) * 1000
if point(i+2+100,j+100) = rgb(10,40,130) then watermap1(i+2,j) = (18 + rnd* 10) * 1000
if point(i+100,j-2+100) = rgb(10,40,130) then watermap1(i,j-2) = (18 + rnd* 10) * 1000
if point(i+100,j+2+100) = rgb(10,40,130) then watermap1(i,j+2) = (18 + rnd* 10) * 1000
end if
end if
next j
next i
' propogate waves....
dim as single decay = 1
for i as integer = 1 to 398
for j as integer = 1 to 398
dim as integer col = point(i+100,j+100)
if col = rgb(10,40,130) then ' if water, then....
dim as short l = watermap1(i-1,j)
dim as short r = watermap1(i+1,j)
dim as short u = watermap1(i,j-1)
dim as short d = watermap1(i,j+1)
dim as single floater = (l + r + u + d) / 2 - watermap2(i,j)
if floater < decay then
watermap2(i,j) = decay
else
if floater > 32000 then
watermap2(i,j) = 32000
else
watermap2(i,j) = floater - decay
end if
end if
end if
next j
next i
for i as integer = 1 to 399
for j as integer = 1 to 399
if point(100+i,100+j) = rgb(10,40,130) then ' if water, then....
dim as single floater = watermap2(i,j) / 32000
pset(100+i, 100+j), rgb(10+(100*floater),40+(100*floater),130)
end if
next j
next i
screenunlock
' swap arrays
for i as integer = 1 to 399
for j as integer = 1 to 399
swap watermap1(i,j), watermap2(i,j)
next j
next i
m.res = GetMouse( m.x, m.y, m.wheel, m.buttons, m.clip )
'locate 3,3 : print m.left
if m.left = 1 then
if m.x > 105 and m.x < 495 and m.y > 105 and m.y < 495 then
watermap1(m.x-100,m.y-100) = 32000
end if
end if
sleep 1
loop until inkey = chr(27)
end