Something went wrong. Try again.
an npmx inspired game for PICO-8 npicomx.vinnymac.dev
games pico-8 adventure npmx
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970-- util: math, screen & text helpers
function lerp(a,b,t) return a+(b-a)*t end
function eio(t) return t*t*(3-2*t) end
function clmp(t) return mid(0,t,1) end
function appr(v,t,a) return v>t and max(v-a,t) or min(v+a,t) end
-- axis-aligned overlap: point (ax,ay) within (r,s) of point (bx,by)function ov(ax,ay,bx,by,r,s) return abs(ax-bx)<r and abs(ay-by)<s end
function grad(y0,y1,a,b) local h=(y1-y0)/5 for i=1,5 do fillp(gpat[i]) rectfill(0,y0+(i-1)*h,127,y0+i*h,a+b*16) end fillp()end
function fadeover(step) if step<=0 then return end -- fadep is keyed 1..5; step arrives fractional from the splash, so floor+clamp -- (a raw fractional index returns nil -> arithmetic-on-nil crash). fillp(fadep[mid(1,flr(step),5)]+0x0.8) rectfill(0,0,127,127,0) fillp()end
-- ember dissolve: the black cover burns away left->right, shedding embers off the-- wavy burn front. e=0 full cover -> e=1 clear. reuses the flame palette (fcol).function wipe(e) for i=0,127 do local x=191*e-32+sin(i*0.2)*12 rectfill(x,i,127,i,0) pset(x-rnd(12),i,fcol(rnd(1))) endend
function pal2(c) pal(12,c) pal(13,c) end
function skin_pal() local s=sk_c[bf_skin+1] if s[1]~=12 then pal(12,s[1]) pal(13,s[2]) endend
function gbox(a,b,c,d) fillp(0x5a5a.8) rectfill(a,b,c,d,5) fillp() end -- dithered glow box
function fcol(f) return f<0.3 and 7 or f<0.55 and 10 or f<0.8 and 9 or 8 endfunction bcol(f) return f<0.3 and 1 or f<0.8 and 12 or 7 end
function fmt_time(s) return (s\60)..":"..(s%60<10 and "0" or "")..(s%60) end
function pr_c(s,x,y,c) print(s,x-#s*2,y,c) end
function pso(s,x,y,c) print(s,x+1,y+1,0) print(s,x,y,c)end
function ptc(s,x,y,c,oc) print(s,x-#s*2+1,y+1,oc or 1) print(s,x-#s*2,y,c)end
function bf_sx(sp) return bfly_seq[flr(t()*sp)%4+1]*8 end
function bf_idx(sp) return bfly_seq[flr(t()*sp)%4+1] end