The code below, uses Marching Squares algorithm using Lerp / Noise.
link to the Noise plugin here
https://forum.thegamecreators.com/thread/189861
Try changing various values eg. rez = 0.5
sync on : sync rate 60 : sync
backdrop off
rez as integer
rez = 10
cols as integer
rows as integer
increment as float
increment = 0.1
zoff as float
zoff = 0.0
noise as float
xoff as float
yoff as float
set display mode 640,480,32
width = screen width()
height = screen height()
noise# = 0.1
cols = 1 + width / rez
rows = 1 + height / rez
dim field#(cols,rows)
For i = 0 to cols
For j = 0 to rows
field#(i,j) = 0.0
next j
next i
do
cls rgb(127,127,127)
xoff = 0.0
For i = 0 to cols
inc xoff,increment
yoff = 0.0
For j = 0 to rows
`field#(i,j) = SIMPLEX NOISE 3D(3,0.5,0.2,xoff, yoff, zoff)
`field#(i,j) = rnd(2)
`field#(i,j) = SIMPLEX NOISE 3D(1.0,0.75,0.51,xoff, yoff, zoff)
field#(i,j) =fn noise 3d(xoff, yoff, zoff)
`field#(i,j) = simplex scaled 3d( 1, 1.0, 0.02, 0.0, 3.0, xoff, yoff, zoff )
`field#(i,j) = simplex scaled 2d( 3, 1.0, 0.01, 0.0, 255.0,xoff, yoff )
inc yoff, increment
next j
next i
inc zoff,0.02
For i = 0 to cols - 1
For j = 0 to rows - 1
x = i * rez
y = j * rez
state = getState(ceil(field#(i,j)),ceil(field#(i + 1,j)),ceil(field#(i + 1,j + 1)),ceil(field#(i,j + 1)) )
a_val# = field#(i,j) + 1
b_val# = field#(i + 1,j) + 1
c_val# = field#(i + 1,j + 1) + 1
d_val# = field#(i,j + 1) + 1
v = make vector2(1)
amt# = (1 - a_val#) / (b_val# - a_val#)
`a.x = lerp(x, x + rez, amt#)
`a.y = y
set vector2 1, lerp2(x, x + rez, amt#), y
v = make vector2(2)
amt# = (1 - b_val#) / (c_val# - b_val#)
`b.x = x + rez
`b.y = lerp(y, y + rez, amt#)
set vector2 2, x + rez, lerp2(y, y + rez, amt#)
v = make vector2(3)
amt# = (1 - d_val#) / (c_val# - d_val#)
`c.x = lerp(x, x + rez, amt#)
`c.y = y + rez
set vector2 3, lerp2(x, x + rez, amt#), y + rez
v = make vector2(4)
amt# = (1 - a_val#) / (d_val# - a_val#)
`d.x = x
`d.y = lerp(y, y + rez, amt#)
set vector2 4, x, lerp2(y, y + rez, amt#)
a=1 : b=2 : c=3 : d=4
select (state)
Case 1
dLine(c, d)
endcase
Case 2
dLine(b, c)
endcase
Case 3
dLine(b, d)
endcase
Case 4
dLine(a, b)
endcase
Case 5
dLine(a, d)
dLine(b, c)
endcase
Case 6
dLine(a, c)
endcase
Case 7
dLine(a, d)
endcase
Case 8
dLine(a, d)
endcase
Case 9
dLine(a, c)
endcase
Case 10
dLine(a, b)
dLine(c, d)
endcase
Case 11
dLine(a, b)
endcase
Case 12
dLine(b, d)
endcase
Case 13
dLine(b, c)
endcase
Case 14
dLine(c, d)
endcase
endselect
next j
next i
sync
loop
wait key
end
function getState(a, b, c, d)
r = a * 8 + b * 4 + c * 2 + d * 1
endfunction r
function dLine(v1, v2)
line x vector2(v1),y vector2(v1),x vector2(v2),y vector2(v2)
endfunction
Function Lerp2(p1#,p2#,i#)
r# = p1#*(1-i#)+p2#*i#
EndFunction r#