Pyranas can now eat their fellow pyranas
This commit is contained in:
26
pyras.p8
26
pyras.p8
@ -11,10 +11,12 @@ end
|
|||||||
function _update()
|
function _update()
|
||||||
movepyras()
|
movepyras()
|
||||||
moveguy()
|
moveguy()
|
||||||
|
eatpyras()
|
||||||
end
|
end
|
||||||
|
|
||||||
function _draw()
|
function _draw()
|
||||||
cls()
|
cls()
|
||||||
|
print(#pyras,7)
|
||||||
drawguy()
|
drawguy()
|
||||||
drawpyras()
|
drawpyras()
|
||||||
end
|
end
|
||||||
@ -40,8 +42,11 @@ end
|
|||||||
pyras={}
|
pyras={}
|
||||||
|
|
||||||
function initpyras()
|
function initpyras()
|
||||||
for i=1,10 do
|
for i=1,50 do
|
||||||
pyras[i]={x=rnd(128),y=rnd(128)}
|
pyras[i]={
|
||||||
|
x=flr(rnd(128)),
|
||||||
|
y=flr(rnd(128))
|
||||||
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -59,6 +64,21 @@ function movepyras()
|
|||||||
if (pyra.y<guy.y) pyra.y+=1
|
if (pyra.y<guy.y) pyra.y+=1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function eatpyras()
|
||||||
|
local toeat={}
|
||||||
|
for i,pyra in ipairs(pyras) do
|
||||||
|
for j=i+1,#pyras do
|
||||||
|
if pyra.x==pyras[j].x and pyra.y==pyras[j].y then
|
||||||
|
add(toeat,j)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
for index in all(toeat) do
|
||||||
|
sfx(0)
|
||||||
|
deli(pyras,index)
|
||||||
|
end
|
||||||
|
end
|
||||||
__gfx__
|
__gfx__
|
||||||
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
@ -66,3 +86,5 @@ __gfx__
|
|||||||
00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
__sfx__
|
||||||
|
000100002e05000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
Reference in New Issue
Block a user