diff --git a/pyras.p8 b/pyras.p8 index 91b24f2..0e6bbc8 100644 --- a/pyras.p8 +++ b/pyras.p8 @@ -20,42 +20,43 @@ function _draw() end -->8 -- guy -guyposx=64 -guyposy=64 -guyspeedx=2 -guyspeedy=2 +guy={ + x=64, + y=64, + speed=2 +} function moveguy() - if (btn(0)) guyposx=max(0,guyposx-guyspeedx) - if (btn(1)) guyposx=min(127,guyposx+guyspeedx) - if (btn(2)) guyposy=max(0,guyposy-guyspeedy) - if (btn(3)) guyposy=min(127,guyposy+guyspeedy) + 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() - rect(guyposx,guyposy,guyposx,guyposy,11) + pset(guy.x,guy.y,11) end -->8 pyras={} function initpyras() for i=1,10 do - pyras[i]={rnd(128),rnd(128)} + pyras[i]={x=rnd(128),y=rnd(128)} end end function drawpyras() for pyra in all(pyras) do - pset(pyra[1],pyra[2],8) + pset(pyra.x,pyra.y,8) end end function movepyras() for pyra in all(pyras) do - if (pyra[1]>guyposx) pyra[1]-=1 - if (pyra[1]guyposy) pyra[2]-=1 - if (pyra[2]guy.x) pyra.x-=1 + if (pyra.xguy.y) pyra.y-=1 + if (pyra.y