Pyranas can now eat their fellow pyranas

This commit is contained in:
2021-11-11 23:16:43 +01:00
parent 4fad2e4af3
commit c0a7eb1ee2

View File

@ -11,10 +11,12 @@ end
function _update()
movepyras()
moveguy()
eatpyras()
end
function _draw()
cls()
print(#pyras,7)
drawguy()
drawpyras()
end
@ -40,8 +42,11 @@ end
pyras={}
function initpyras()
for i=1,10 do
pyras[i]={x=rnd(128),y=rnd(128)}
for i=1,50 do
pyras[i]={
x=flr(rnd(128)),
y=flr(rnd(128))
}
end
end
@ -59,6 +64,21 @@ function movepyras()
if (pyra.y<guy.y) pyra.y+=1
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__
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
@ -66,3 +86,5 @@ __gfx__
00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
__sfx__
000100002e05000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000