Shiplex Noise - Pico1k
This is a DEMO showing my attempt at simplex noise it was made for the PICO1K JAM, using pico-8. Used for large worlds.
If you found this page you were probable looking for it. Tool demo is 1020 compressed bytes.
Controls:
- ARROW KEYS : Movement
- X : Harvest/Dig Trees/Ground
- joystick controller works nicely with 8 direction (limited testing)
Highlights:
- Procedural terrain using a hybrid simplex noise function
- Seed values for repeatability
- noise function roughly 265 tokens, ~350cBytes
- Uses only 16x16 map tiles for world movement
- Plenty of space for custom locations, indoor and out
- 8 directional movement using 3 sprites being flipped around
- Prescient changes to tiles using a dictionary during map draw
I didn't know what to make or what direction to take it in 1k, I had been looking into terrain generation in Godot and wanted to try something along those line. Since simplex noise is starting to show up again, I thought I would try that. Since pico-8 doesn't really have a noise function, I'd attempt to make one. I wasn't able to fully implement a pure simplex noise function as describe in the patent that expired last year. However I was able to duct tape together a noise function that may be of use to others, and performs well enough. A table was used in a way similar to Perlin noise to maintain coherence. Maybe I'll try again after I get better with bit manipulations. Enjoy! I hope this helps someone out, or inspires a spring broad of ideas.
different new:
u={∧,░,█,ˇ,☉,⌂,😐,◆,▒}c={12,15,11,11,11,3,5,4,4}p={7,9,11,3,8,11,6,9,5} for i=1,10 do fillp()rectfill(0,0,7,7,c[i])fillp(u[i])rectfill(0,0,7,7,p[i])for a=0,7 do for b=0,7 do sset(i*8+a,b,pget(a,b))end end end fset(7,1)fset(6,1)tm=""sd="\as4i7c"x=60y=35dx=1dy=0r=0k={} function dig(o) if(o==8)k[ke(x+dx,y+dy)]=9r+=1rt()?sd if(o==6)k[ke(x+dx,y+dy)]=3?sd end function fmap(x,y)for a=0,16 do for b=0,16 do i=1n=sn((a+flr(x)-8)*.01,(b+flr(y)-8)*.01) if(n>.2)i=2 if n>.3 then i=3if(n%.01>.008)i=5 if(n%.01>.009)i=4 end if(n>.8)i=6 if(n>.9)i=7 mset(a,b,i)l=k[ke(a+x-8,b+y-8)] if(l!=nil)mset(a,b,l) end end end function _draw() if(t()<.1)rt() cls() if(btnp(❎))dig(mget(8+dx,8+dy)) fmap(x,y)map()b=btn()ix,iy=x,y a=mget(8,8)dx=(b\2%2-b%2)dy=(b\8%2-b\4%2) x+=dx if(fget(mget(8+dx,8),0))x=ix y+=dy if(fget(mget(8,8+dy),0))y=iy if(a==1)?"🐱\vf▒",65,68,4 if(a!=1)?"웃",65,66,1 w,h=64+dx*8,64+dy*8rect(w,h,w+8,h+8,7) ?"웃:"..flr(x)..":"..flr(y),8,12,4 ?"❎:"..tm if(r>0)?"\*"..r.."★" if(r>4)?"w𝘦𝘭𝘭 d𝘰𝘯𝘦" end function rt()while true do tx,ty=rnd(128)+x,rnd(128)+y if(sn(tx*.01,ty*.01)>.5)tm=ke(tx,ty)k[tm]=8 return end end function ke(x,y)return (flr(x)..":"..flr(y))end --sn noise srand(678)--seed local p={} for i=1,512 do p[i]=flr(rnd(256)) end local g={{1,1},{1,-1},{-1,1},{-1,0},{-1,-1},{1,-1},{1,-1},{1,0}} function cb(x,y,z) local t=.5-x*x-y*y if(t<0)return 0 return t^4*(g[z+1][1]*x+g[z+1][2]*y) end function sn(x,y) local g=.2113 local s=(x+y)*.366 local i,j=flr(x+s),flr(y+s) local t=(i+j)*g local x0,y0=x-(i-t),y-(j-t) local i1=0j1=1if(x0>y0)i1=1j1=0 local x1=x0-i1+g local y1=y0-j1+g local x2=x0-1+2*g local y2=y0-1+2*g local u=i&255 local v=j&255 return 70*(cb(x0,y0,p[u+p[v+1]]%8)+cb(x1,y1,p[u+i1+p[v+j1+1]]%8)+cb(x2,y2,p[u+1+p[v+2]]%8)) end
Older Code:
!!ATTENTION!! CODE USES PUNY CHARACTERS USE <CTRL-P> before CTRL-V in PICO8
for i=0,511do v=ord("\0@⁴\0アアアア\0𝘥𝘥\0アアアア\0⬆️𝘫\0アアアア\0ww\0アアアア𝘱ˇ𝘺⁵アアアア\0⬆️𝘫\0アアアア\0⬆️𝘫\0アアアア\0𝘥𝘥\0アアアア\0p⁷\0◝◝◝◝\0pw\0◝◝◝◝\0pw⁷◝◝◝◝\0pw\0◝◝◝◝@y▥⁴◝◝◝◝𝘥𝘵𝘥𝘥◝◝◝◝\0𝘵𝘥⁴◝◝◝◝\0\0\0\0◝◝◝◝@⁴\0\0めめめめ@𝘫⁷⁵めめめめ@た𝘸\0めめめめ@⬆️w\0めめめめ\0𝘥w⁴めめめめ\0𝘦⬆️𝘥めめめめ𝘱\0𝘥⁴めめめめ\0\0@\0めめめめめめめめめ33めめ𝘶𝘶め;3;は[𝘦𝘥ふ3は33[𝘥𝘥ひははは3[𝘥𝘥ひ3333[𝘥𝘥ひ3;;3め𝘥𝘥め;3は3めめめめめは3は",i\2+1)sset(i%16,i\16,v\16^(i%2)%16)end sd="\as4i7c" x=60y=35dx=1dy=0r=0 g="8558"gi="8?:5?"k={} function dig(o) l=0if(o==49)l=33r+=1 if(o==33)l=48 if(l!=0)k[flr(x+dx)..flr(y+dy)]=l ?sd end function fmap(x,y) for a=0,16 do for b=0,16 do i=1n=sn((a+flr(x)-8)*.01,(b+flr(y)-8)*.01) if(n>.5)i=17 if(n>.6)i=33 if(n>.75)i=49 mset(a,b,i) l=k[(a+x-8)..(b+y-8)] if(l!=nil)mset(a,b,l) end end end function move() b=btn()ps=16fx=0fy=0 z=(b\2%2-b%2) v=(b\8%2-b\4%2) m=mget(8,8) x+=z y+=v if(b&15>0)dx=z dy=v if(abs(dy)>0)ps=0 if(abs(dx)+abs(dy)>1)ps=32 if(m==1)spr(ps,64,64+t()%2,1,1,dx>0,dy>0) if(m!=1)?"웃",65,65,5 w,h=64+dx*8,64+dy*8rect(w,h,w+8,h+8,7) end function _draw() cls()if(btnp(❎))dig(mget(8+dx,8+dy)) fmap(x,y)map()move() ?"wood:"..r,8,8,2 ?"웃:"..flr(x)..":"..flr(y),8,14,4 end --sn2d srand(678)--seed local p={} for i=1,512 do p[i]=flr(rnd(256)) end local g={{1,1},{1,-1},{-1,1},{-1,0},{-1,-1},{1,-1},{1,-1},{1,0}} function cb(x,y,z) local t=.5-x*x-y*y if(t<0)return 0 return t^4*(g[z+1][1]*x+g[z+1][2]*y) end function sn(x,y) local g=.2113 local s=(x+y)*.366 local i,j=flr(x+s),flr(y+s) local t=(i+j)*g local x0,y0=x-(i-t),y-(j-t) local i1=0j1=1if(x0>y0)i1=1j1=0 local x1=x0-i1+g local y1=y0-j1+g local x2=x0-1+2*g local y2=y0-1+2*g local u=i&255 local v=j&255 return 70*(cb(x0,y0,p[u+p[v+1]]%8)+cb(x1,y1,p[u+i1+p[v+j1+1]]%8)+cb(x2,y2,p[u+1+p[v+2]]%8)) end
Download
Click download now to get access to the following files:
Leave a comment
Log in with itch.io to leave a comment.