pico-8 cartridge // http://www.pico-8.com version 33 __lua__ -- pyras -- by: djib function _init() initpyras() t=0 end function _update() waitandmove() eatpyras() end function _draw() cls() drawbg() drawguy() drawpyras() end -->8 -- guy guy={ x=64, y=64, speed=4 } function moveguy() if (btn(0)) guy.x=max(0,guy.x-guy.speed) if (btn(1)) guy.x=min(127,guy.x+guy.speed) if (btn(2)) guy.y=max(0,guy.y-guy.speed) if (btn(3)) guy.y=min(127,guy.y+guy.speed) end function drawguy() pset(guy.x,guy.y,11) -- guides pset(guy.x-guy.speed,guy.y-guy.speed,6) pset(guy.x,guy.y-guy.speed,6) pset(guy.x+guy.speed,guy.y-guy.speed,6) pset(guy.x-guy.speed,guy.y,6) pset(guy.x+guy.speed,guy.y,6) pset(guy.x-guy.speed,guy.y+guy.speed,6) pset(guy.x,guy.y+guy.speed,6) pset(guy.x+guy.speed,guy.y+guy.speed,6) end -->8 pyras={} function initpyras() for i=1,200 do pyras[i]={ x=flr(rnd(128)), y=flr(rnd(128)) } end end function drawpyras() for pyra in all(pyras) do pset(pyra.x,pyra.y,8) end end function movepyras() for pyra in all(pyras) do if (pyra.x>guy.x) pyra.x-=1 if (pyra.xguy.y) pyra.y-=1 if (pyra.y8 function drawbg() local offset=1 if(#pyras>9)offset+=1 if(#pyras>99)offset+=1 rectfill(0,0,127,127,1) print(#pyras,128-4*offset,1,7) end function waitandmove() if t>0.05*#pyras then movepyras() moveguy() t=0 else t+=1 end end __gfx__ 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 __sfx__ 000100002e05000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000