Play project
Mars8's itch.io pageCompressed Bytes used
973
Source Code (OPTIONAL)
u=0
v=0
function hcell(i0,j0,d,m,s,a)
i1=(i0+d)&(s-1)
j1=(j0+d)&(s-1)
m00=m[j0][i0]
m01=m[j0][i1]
m10=m[j1][i0]
m11=m[j1][i1]
e=d/2
im=i0+e
jm=j0+e
m[j0][im]=.5*(m01+m00+(rnd(a)-.5*a))
m[jm][i0]=.5*(m10+m00+(rnd(a)-.5*a))
m[jm][im]=.25*(m00+m11+(rnd(a)-.5*a)+m10+m01+(rnd(a)-.5*a))
end
function hmap(m,s,a)
d=s
while d>1 do
for j=0,s-1,d do
for i=0,s-1,d do
hcell(i,j,d,m,s,a)
end
end
a=a*a
d=d/2
end
end
function lmap(lm,hm,s,lu,lv,lw)
for j=0,s-1 do
for i=0,s-1 do
h00=hm[j][i]
h01=hm[j][(i+1)%s]
h10=hm[(j+1)%s][i]
nu=h01-h00
nv=h10-h00
nw=sqrt(1-nu*nu-nv*nv)
lm[j][i]=min(1,max(nu*lu+nv*lv+nw*lw))
end
end
end
function _init()
hm={}
lm={}
for i=0,127 do
hm[i]={}
lm[i]={}
end
hm[0][0]=.5
hmap(hm,128,.925)
li=sqrt(1/3)
lmap(lm,hm,128,10*li,10*li,li)
palt(0,false)
pal({[0]=0,0,-16,-16,-12,-12,4,4,-7,-7,9,9,10,10,-9,-9},1)
pal({[0]=0,0,0,-16,-16,-12,-12,4,4,-7,-7,9,9,10,10,-9},2)
poke(0x5f5f,0x10)
memset(0x5f70,0b01010101,16)
end
function _draw()
cls(4)
i0=0
i1=1
for j=0,6 do
rectfill(0,64-i0,128,64-i1,13-j)
i0=i1
i1=i1<<1
end
for i=-64,63,1 do
k0=nil
for j=-160,-32,10 do
t=-w/j
if t>0 then
du=t*i
dv=t<<6
im=u+du-.5
jm=v+dv-.5
i0=im\1
j0=jm\1
i1=i0+1
j1=j0+1
h00=hm[j0&127][i0&127]
h01=hm[j0&127][i1&127]
h10=hm[j1&127][i0&127]
h11=hm[j1&127][i1&127]
h1=(j1-jm)*((i1-im)*h00+(im-i0)*h01)+(jm-j0)*((i1-im)*h10+(im-i0)*h11)
l00=lm[j0&127][i0&127]
l01=lm[j0&127][i1&127]
l10=lm[j1&127][i0&127]
l11=lm[j1&127][i1&127]
l1=(j1-jm)*((i1-im)*l00+
(im-i0)*l01)+
(jm-j0)*((i1-im)*l10+
(im-i0)*l11)
k1=j+(h1<<4)/t
if k0 and
k0<k1 and
k1>=-96 then
for k=k0,k1 do
l=((k1-k)*l0+(k-k0)*l1)/(k1-k0)
pset(64+i,32-k,l<<4)
end
end
l0=l1
k0=k1
end
end
end
end
function _update()
if btn(0) then
u=u-.5
end
if btn(1) then
u=u+.5
end
if btn(2) then
v=v+.5
end
if btn(3) then
v=v-.5
end
um=u-.5
vm=v-.5
u0=um\1
v0=vm\1
u1=u0+1
v1=v0+1
h00=hm[v0&127][u0&127]
h01=hm[v0&127][u1&127]
h10=hm[v1&127][u0&127]
h11=hm[v1&127][u1&127]
h=(v1-vm)*((u1-um)*h00+(um-u0)*h01)+(vm-v0)*((u1-um)*h10+(um-u0)*h11)
w=(h+1)<<4
end
Leave a comment
Log in with itch.io to leave a comment.
Comments
I love voxelspace, great job !
Much appreciated. Your implementation looks amazing and runs remarkably fast too.
Well, what can I say mate ...as a PICO-8 tribute, looks spot-on! ๐
You've managed to push P8 to the edge and all the while keeping it to <1K ?!
Awesome work. Those commutes deffo paid off! ๐
Thank you Paul, great compliment coming from the absolute master of PICO-8 tributes! the trick is 10fps, just don't tell anyone ;-)