Pseudo 3D terrain generation in a realtively small amount of code.

I highly ecourage playing around with the numbers here, particularly the values for the circfill call towards the end of the cartridge, some really interesting results can emerge!

Cartridge code (1171 chars):

cls()
size=64
for x=0,size-1 do
 for y=0,size-1 do
  pset(x,y,3+rnd(9))
 end
end
x=rnd(size)
y=rnd(size)
?"press ❎ to stop generation",8,120,7
::★::
x=mid(0,x+rnd(2)-1,size)
y=mid(0,y+rnd(2)-1,size)
avg=pget(x,y)
avg+=pget(x+1,y)
avg+=pget(x-1,y)
avg+=pget(x,y+1)
avg+=pget(x,y-1)
if (btn(❎)) memcpy(0x0,0x6000,128*128) goto ⌂
pset(x,y,avg/5)
goto ★
function ____________built_in_functions()
end
::⌂::
function _init()
 cls(12)
 pal(1,1)
 pal(2,13)
 pal(3,15)
 pal(4,3)
 pal(5,11)
 pal(6,5)
 pal(7,6)
 for i=8,15 do
  pal(i,7)
 end
end
rot=0
function _update()
 if (btn(0)) rot+=0.01
 if (btn(1)) rot-=0.01
end

function _draw()
 cls(12)
 spr_rot(0,0,size,64,64,rot)
 ?"cpu: "..(flr(stat(1)*100)/100).."/1",1,1,1
 ?"⬅️/➡️ rotate view",60,1
 ?"press 🅾️ to generate a new map",4,120
 if (btn(🅾️))run()
end

sz=size/2
w=sqrt(sz^2*2)

function spr_rot(sx,sy,swh,dx,dy,rot)
  local s=sin(rot)
  local c=cos(rot)
  local _b=s*s+c*c
  local size = sz
  for y=-w,w do
    for x=-w,w do
      local ox=(s*y+c*x)/_b+size
      local oy=(-s*x+c*y)/_b+size
      local col=sget(ox+sx,oy+sy)
      if col>0 then
       circfill(dx+x,16+dy+y/2-col,1,col)
      end
    end
  end
end