Adding varying speed

This commit is contained in:
2021-11-11 23:44:28 +01:00
parent 864fd55280
commit b417a01c73

View File

@ -6,16 +6,17 @@ __lua__
function _init() function _init()
initpyras() initpyras()
t=0
end end
function _update() function _update()
movepyras() wait()
moveguy() moveguy()
eatpyras() eatpyras()
end end
function _draw() function _draw()
cls() cls()
drawbg() drawbg()
drawguy() drawguy()
drawpyras() drawpyras()
@ -36,13 +37,13 @@ function moveguy()
end end
function drawguy() function drawguy()
pset(guy.x,guy.y,11) pset(guy.x,guy.y,11)
end end
-->8 -->8
pyras={} pyras={}
function initpyras() function initpyras()
for i=1,50 do for i=1,200 do
pyras[i]={ pyras[i]={
x=flr(rnd(128)), x=flr(rnd(128)),
y=flr(rnd(128)) y=flr(rnd(128))
@ -81,12 +82,21 @@ function eatpyras()
end end
-->8 -->8
function drawbg() function drawbg()
offset=1 local offset=1
if(#pyras>9)offset+=1 if(#pyras>9)offset+=1
if(#pyras>99)offset+=1 if(#pyras>99)offset+=1
rectfill(0,0,127,127,1) rectfill(0,0,127,127,1)
print(#pyras,128-4*offset,1,7) print(#pyras,128-4*offset,1,7)
end end
function wait()
if t>0.05*#pyras then
movepyras()
t=0
else
t+=1
end
end
__gfx__ __gfx__
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000