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.
1234567891011121314151617181920212223242526-- physics: tile collision & butterfly movement
function solid_box(x,y,w,h) if lvl==4 then return false end for i=mid(0,x\8,lvw-1),mid(0,(x+w-1)\8,lvw-1) do for j=max(0,y\8),min(15,(y+h-1)\8) do -- above row 0 = out of bounds (no tiles), not solid if fget(mget(lvox+i,lvoy+j),0) then return true end end endend
function move_bf(dx,dy) bf.rx+=dx local a=flr(bf.rx+0.5) bf.rx-=a local s=sgn(a) for _=1,abs(a) do if solid_box(bf.x-5+s,bf.y-4,10,8) then bf.vx=0 break end bf.x+=s end bf.ry+=dy a=flr(bf.ry+0.5) bf.ry-=a s=sgn(a) for _=1,abs(a) do if solid_box(bf.x-5,bf.y-4+s,10,8) then bf.vy=0 break end bf.y+=s endend