Simple method yet with pleasant results. Nice work.
I modified your code slightly, structurally more than anything. It's a little shorter and in a function now.
REM =========================
REM Author: Derek Darkly
REM Edited by: Phaelax
REM =========================
createHeightmap(5003, 20, 500, 1000, 2000, 4, 40)
repeat
cls
if spacekey() and flag=0 then createHeightmap(5003, 20, 500, 1000, 2000, 4, 40) : flag = 1
if spacekey() = 0 then flag = 0
if lower$(inkey$())="s" then save image "heightmap_"+str$(rnd(10000))+".png", 5003:backdrop off:print "...image saved!":wait 1000:backdrop on
paste image 5003,(screen width()/2)-(image width(5003)/2),(screen height()/2)-(image height(5003)/2)
set cursor 0,0
print "SPACEKEY TO REDRAW"
print "S=SAVE .PNG"
until escapekey()
end
rem ////////////////////////////////////////////////////////////////////////////////////
rem img: image ID used to create heightmap image
rem maxCracks: max number of lines to start
rem white/grey/black pass: how much of the color to daub
rem stroke: how far the pixel can travel per pass
rem alpha: transparency for clones (too much will negate blur effect)
rem ////////////////////////////////////////////////////////////////////////////////////
function createHeightmap(img, maxCracks, whitePass, greyPass, blackPass, stroke, alpha)
local img_stone1 = 5000
local img_stone2 = 5001
local pos = 1
local neg = -1
dim crackX(maxCracks)
dim crackY(maxCracks)
dim pass(3)
pass(1) = whitePass : pass(2) = greyPass : pass(3) = blackPass
rem Make stone
for y = 0 to 265
for x = 0 to 265
c = rnd(99)+1
dot x, y, rgb(c,c,c)
next x
next y
rem Make the white, grey, black passes
for p = 1 to 3
for c = 1 to maxCracks
crackX(c) = rnd(255)
crackY(c) = rnd(255)
next
for pass = 1 to whitePass
for c = 1 to maxCracks
col = 200+rnd(45)
dot crackX(c), crackY(c), rgb(col, col, col)
inc crackX(c), rnd(stroke)-rnd(stroke)
inc crackY(c), rnd(stroke)-rnd(stroke)
next c
next pass
next p
get image img_stone1, 0, 0, 265, 265
sprite img_stone1, 0, 0, img_stone1
hide sprite img_stone1
clone sprite img_stone1, img_stone2
set sprite alpha img_stone2, alpha
hide sprite img_stone2
cls
paste sprite img_stone1, 0, 0
paste sprite img_stone2, 0, neg
paste sprite img_stone2, pos, neg
paste sprite img_stone2, pos, 0
paste sprite img_stone2, pos, pos
paste sprite img_stone2, 0, pos
paste sprite img_stone2, neg, pos
paste sprite img_stone2, neg, 0
paste sprite img_stone2, neg, neg
rem get new image
if image exist(img) then delete image img
get image img, 4, 4, 260, 260, 1
rem free resources
delete image img_stone1
delete sprite img_stone1
delete sprite img_stone2
undim crackX()
undim crackY()
undim pass()
endfunction
"I like offending people, because I think people who get offended should be offended." - Linus Torvalds