Improving variable names
This commit is contained in:
31
pyras.p8
31
pyras.p8
@ -20,42 +20,43 @@ function _draw()
|
|||||||
end
|
end
|
||||||
-->8
|
-->8
|
||||||
-- guy
|
-- guy
|
||||||
guyposx=64
|
guy={
|
||||||
guyposy=64
|
x=64,
|
||||||
guyspeedx=2
|
y=64,
|
||||||
guyspeedy=2
|
speed=2
|
||||||
|
}
|
||||||
|
|
||||||
function moveguy()
|
function moveguy()
|
||||||
if (btn(0)) guyposx=max(0,guyposx-guyspeedx)
|
if (btn(0)) guy.x=max(0,guy.x-guy.speed)
|
||||||
if (btn(1)) guyposx=min(127,guyposx+guyspeedx)
|
if (btn(1)) guy.x=min(127,guy.x+guy.speed)
|
||||||
if (btn(2)) guyposy=max(0,guyposy-guyspeedy)
|
if (btn(2)) guy.y=max(0,guy.y-guy.speed)
|
||||||
if (btn(3)) guyposy=min(127,guyposy+guyspeedy)
|
if (btn(3)) guy.y=min(127,guy.y+guy.speed)
|
||||||
end
|
end
|
||||||
|
|
||||||
function drawguy()
|
function drawguy()
|
||||||
rect(guyposx,guyposy,guyposx,guyposy,11)
|
pset(guy.x,guy.y,11)
|
||||||
end
|
end
|
||||||
-->8
|
-->8
|
||||||
pyras={}
|
pyras={}
|
||||||
|
|
||||||
function initpyras()
|
function initpyras()
|
||||||
for i=1,10 do
|
for i=1,10 do
|
||||||
pyras[i]={rnd(128),rnd(128)}
|
pyras[i]={x=rnd(128),y=rnd(128)}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function drawpyras()
|
function drawpyras()
|
||||||
for pyra in all(pyras) do
|
for pyra in all(pyras) do
|
||||||
pset(pyra[1],pyra[2],8)
|
pset(pyra.x,pyra.y,8)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function movepyras()
|
function movepyras()
|
||||||
for pyra in all(pyras) do
|
for pyra in all(pyras) do
|
||||||
if (pyra[1]>guyposx) pyra[1]-=1
|
if (pyra.x>guy.x) pyra.x-=1
|
||||||
if (pyra[1]<guyposx) pyra[1]+=1
|
if (pyra.x<guy.x) pyra.x+=1
|
||||||
if (pyra[2]>guyposy) pyra[2]-=1
|
if (pyra.y>guy.y) pyra.y-=1
|
||||||
if (pyra[2]<guyposy) pyra[2]+=1
|
if (pyra.y<guy.y) pyra.y+=1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
__gfx__
|
__gfx__
|
||||||
|
Reference in New Issue
Block a user