68 lines
1.7 KiB
Lua
68 lines
1.7 KiB
Lua
pico-8 cartridge // http://www.pico-8.com
|
|
version 33
|
|
__lua__
|
|
-- pyras
|
|
-- by: djib
|
|
|
|
function _init()
|
|
initpyras()
|
|
end
|
|
|
|
function _update()
|
|
movepyras()
|
|
moveguy()
|
|
end
|
|
|
|
function _draw()
|
|
cls()
|
|
drawguy()
|
|
drawpyras()
|
|
end
|
|
-->8
|
|
-- guy
|
|
guyposx=64
|
|
guyposy=64
|
|
guyspeedx=2
|
|
guyspeedy=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)
|
|
end
|
|
|
|
function drawguy()
|
|
rect(guyposx,guyposy,guyposx,guyposy,11)
|
|
end
|
|
-->8
|
|
pyras={}
|
|
|
|
function initpyras()
|
|
for i=1,10 do
|
|
pyras[i]={rnd(128),rnd(128)}
|
|
end
|
|
end
|
|
|
|
function drawpyras()
|
|
for pyra in all(pyras) do
|
|
pset(pyra[1],pyra[2],8)
|
|
end
|
|
end
|
|
|
|
function movepyras()
|
|
for pyra in all(pyras) do
|
|
if (pyra[1]>guyposx) pyra[1]-=1
|
|
if (pyra[1]<guyposx) pyra[1]+=1
|
|
if (pyra[2]>guyposy) pyra[2]-=1
|
|
if (pyra[2]<guyposy) pyra[2]+=1
|
|
end
|
|
end
|
|
__gfx__
|
|
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
|
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
|
00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
|
00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
|
00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
|
00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|