I needed a fast way of making reasonably realistic terrain for my racing game, so I made a generator. It makes 8X8 256X256 .BMPS that look acceptable in 15 mins with a viewer. For all you GIMMEH TEH CODEZ people, here it is:
randomize timer() : sync on
sync : print "The only way to quit this app is using" : print "the ESC button." : print "Heightmaps are saved to C:\ISLAND," : print "created if it does not exist." : sync : wait 5000
print "Making arrays for data storage..." : sync : dim landheight#(2047,2047) : dim radius(36000) : print "-Done" : sync : print "Adding cliffs..." : sync
radius = 700+rnd(68*2) : orradius = radius
for a=0 to 36000 : if a > 30000 : radius = curvevalue(orradius-1+rnd(2),radius,4500) : else : inc radius,2-rnd(4) : endif
if radius > 995 : radius = 995 : endif : if radius < 640 : radius = 640 : endif : radius(a)=radius
for b=0 to 2048 : x# = 1024+(sin(a*0.01)*b) : y# = 1024+(cos(a*0.01)*b) : if x# < 0 or x# > 2047 or y# < 0 or y# > 2047 : b=2048 : else : if b => radius : landheight#(int(x#),int(y#))=32 : else landheight#(int(x#),int(y#))=64 : endif : endif
next b : inc timed : if timed = 360 : print a/360.0 : sync : timed = 0 : endif : if escapekey() : end : endif : next a
print "-Done" : sync : renderpreview() : print "Making mountains..." ; : sync
for mountains=1 to 512 : size = 5+rnd(250)
repeat : xbase = rnd(1536)+256 : ybase = rnd(1536)+256 : if sqrt(((1024-xbase)^2)+((1024-ybase)^2)) < radius(int(wrapvalue(-atanfull(1024-xbase,1024-ybase))*100)) : yes = 1 : else : yes = 0 : endif : until yes = 1
for angle = 0 to 3600 : for distance = 1 to size : landheight#(int(xbase + sin(angle*0.1)*distance),int(ybase + cos(angle*0.1)*distance))=landheight#(int(xbase + sin(angle*0.1)*distance),int(ybase + cos(angle*0.1)*distance))+0.25 : if timer() > oldtimer+500 : print mountains/5.12 : sync : oldtimer = timer() : endif : next distance : next angle : sync : if escapekey() : end : endif : next mountains
print "-Done" : sync : renderpreview() : print "Running landscape through IMPACT filter..." : sync
for passes = 1 to 16 : for x=1 to 2046 : for y=1 to 2046 : landheight#(x,y)=((landheight#(x-1,y)+landheight#(x+1,y)+landheight#(x,y-1)+landheight#(x-1,y+1))/4)+(rnd(25)*0.1)-1.25 : next y : if timer() > oldtimer+500 : print "PASS";passes;": ";((x*y)/41943.04) : sync : oldtimer = timer() : endif : next x : if escapekey() : end : endif : next passes
print "-Done" : sync : renderpreview() : Print "Converting to PNGS and saving as 128x128 chunks..." : sync
if path exist("c:\island")=0 then make directory "c:\island"
for x=0 to 15 : for y=0 to 15 : cls : inc cursored : set cursor 1,192 : print x ; ":" ; y : for x2 = 0 to 127 : for y2 = 0 to 127 : col# = landheight#((x*128)+x2,(y*128)+y2) : dot x2,y2,rgb(col#,col#,col#) : next y2 : next x2 : get image 1,0,0,127,127,1
if file exist("c:\island\ISLAND" + str$(cursored) + ".PNG")=0 : delete file "c:\island\ISLAND" + str$(cursored) + ".BMP" : endif : save image "c:\island\ISLAND" + str$(cursored) + ".PNG",1
sync : if escapekey() : end : endif : next y : next x : end
function renderpreview() : for x=0 to 7 : for y=0 to 7 : for x2=0 to 15 : for y2=0 to 15 : dot 257+((x*16)+x2),(y*16)+y2,rgb(landheight#((x*256)+(x2*16),(y*256)+(y2*16)),landheight#((x*256)+(x2*16),(y*256)+(y2*16)),landheight#((x*256)+(x2*16),(y*256)+(y2*16))) : next y2 : next x2 : next y : next x : endfunction
EDIT: all the code is now there