Files
PICO-8/pyras.p8
2021-11-30 22:03:02 +01:00

378 lines
23 KiB
Lua
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

pico-8 cartridge // http://www.pico-8.com
version 33
__lua__
-- escape the pyras
-- by djib
function _init()
initgame()
end
function _update()
updategame()
end
function _draw()
drawgame()
end
-->8
-- guy
function initguy()
guy={
x=flr(game.boardsize/2),
y=flr(game.boardsize/2),
speed=4,
dead=false
}
end
function moveguy()
if (btn()) then
guy.x=max(0,guy.x-guy.speed)
end
if (btn()) then
guy.x=min(game.boardsize,guy.x+guy.speed)
end
if (btn()) then
guy.y=max(0,guy.y-guy.speed)
end
if (btn()) then
guy.y=min(game.boardsize,guy.y+guy.speed)
end
end
function drawguy()
local spd=guy.speed
local size=game.pixelsize
spr(size-1,guy.x*size,guy.y*size)
guides={
{guy.x-spd,guy.y-spd},
{guy.x ,guy.y-spd},
{guy.x+spd,guy.y-spd},
{guy.x-spd,guy.y },
{guy.x+spd,guy.y },
{guy.x-spd,guy.y+spd},
{guy.x ,guy.y+spd},
{guy.x+spd,guy.y+spd}
}
for g in all(guides) do
spr(15+size,g[1]*size,g[2]*size)
end
end
-->8
-- pyras
function initpyras()
pyras={}
for i=1,game.nbpyras do
repeat
pyras[i]={
x=flr(rnd(game.boardsize+1)),
y=flr(rnd(game.boardsize+1))
}
until abs(pyras[i].x-guy.x)>5
or abs(pyras[i].y-guy.y)>5
end
end
function movepyras()
for pyra in all(pyras) do
if (pyra.x>guy.x) pyra.x-=1
if (pyra.x<guy.x) pyra.x+=1
if (pyra.y>guy.y) pyra.y-=1
if (pyra.y<guy.y) pyra.y+=1
if pyra.x==guy.x and
pyra.y==guy.y then
guy.dead=true
end
end
end
function drawandeatpyras()
local size=game.pixelsize
for index,pyra in ipairs(pyras) do
local pxlclr=getpixel(pyra.x,pyra.y)
if pxlclr==8 or pxlclr==10 then
sfx(0)
deli(pyras,index)
else
spr(31+size,pyra.x*size,pyra.y*size)
end
end
end
-->8
-- game
game={
level=1,
pixelsize=2
}
function initgame()
local pxs=game.pixelsize
game.boardsize=flr((127-pxs+1)/pxs)
game.slowdown=0.125*pxs
game.state=0
game.tick=0
game.nbpyras=flr(40*1.25^game.level)
initguy()
initpyras()
end
function drawbg()
local offset=1
if(#pyras>9)offset+=1
if(#pyras>99)offset+=1
rectfill(0,0,127,127,5)
print(#pyras,128-4*offset,1,7)
print("l:"..game.level,1,1,7)
end
function waitormove()
if game.tick>min(20,game.slowdown*#pyras) then
moveguy()
movepyras()
game.tick=0
end
end
function updategame()
game.tick+=1
if game.state==0 then
if(btnp())game.state=1
if game.level==1 then
if(btnp()) and game.pixelsize>1 then
game.pixelsize-=1
initgame()
end
if(btnp()) and game.pixelsize<4 then
game.pixelsize+=1
initgame()
end
end
elseif game.state==1 then
waitormove()
if guy.dead then
if game.level>1 then
game.state=3
game.level-=1
else
game.state=4
end
sfx(1)
elseif #pyras==1 then
game.state=2
game.level+=1
sfx(2)
end
elseif game.tick>60 then
_init()
end
end
function drawgame()
cls()
drawbg()
if(game.state>=1)drawguy()
drawandeatpyras()
if game.state==0 then
rect(46,46,80,80,7)
cursor(48,58,7)
print "press ❎"
print "to start"
if game.level==1 then
cursor(30,90,7)
print "⬅️ change size ➡️"
end
elseif game.state>1 then
cursor(46,61,7)
print "game over"
if game.state==2 then
print "level up!"
end
if game.state==3 then
print "level down"
end
if game.state==4 then
print "try again!"
end
end
end
-->8
-- helpers
function drawpixel(x,y,colour)
local size=game.pixelsize
rectfill(
x*size,
y*size,
(x+1)*size-1,
(y+1)*size-1,
colour
)
end
function getpixel(x,y)
local size=game.pixelsize
return pget(
x*size,
y*size
)
end
__gfx__
e00000001e0000004440000044440000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000e10000001e1000001ee10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000e7e00000e77e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000ee00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
60000000660000006060000060060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000660000000f0000000ff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000606000000ff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000060060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
a0000000a80000008880000088880000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000008a000000a8a00000a88a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000008f8000008ff80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000088880000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
__label__
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111181111
17181111177711111111111111111111111118111111111111111111111111111111111111111111111111111111111111111111111111111111777177717771
17181171171711111111111111111111111111111111111111181111111111111111111111111111111111111111111111111111111111111111117111711171
17111111177711111111118811111111111111111111111111118111111111111111111111111111111111111111111111811111111111111111777117711771
17111171171711111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111711111711171
17771111177711111111111111111111111111111111111111111111811111111111111111111111111111111111111111111111111111111111777177717771
11111111111111111111111111111111111111111111111111111111111118111111111111111111111111111111111111111111111111111111111111111111
11111111111111111181111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111181111111111111111111111111111181111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111118111111111111111111111111111111111111111111111111111111111111181111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111811
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111118181111111111111111111111111111111111111111111111111111111111111111111111118111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111118111111111111111111111111111111111111111811111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111811111811111111111111111111811111111111111111111111111111111111111111111111111111111111111111111111111111111188111111
11111118111111111111111111111118111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111811
11111811111111111111111111111111111111111111111111111111111111111111111118111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111181111111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111181111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111811111111111111111111
11111111111111111111111111111111111111181111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111181111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111181111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111118111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
11118111111111111111111111111111111111111111111111111111111111111111111111111181111111118111111111111111111111111111111118111111
11111111111111111111111111181111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111181111111111111111111111111111111111111111111111111111111111111111111111111111111111111811111111118111111111
11111111111111111111181111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111118111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111181111111111111111111111111111111111111111111181111111
11111111111181111111111111181111181111111111111111111111118111111111111111181111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111181111111111111111111111111111118111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111811111118111111111111111111111111111111111111111111111111
11118111111111111111111111111111111111111111111111111111111118111111111111111111111111111111111181111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111181
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111181111111111111111111111111111811111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
11811111111111111111111111111111111811111111111111811111111111111111811111111111111111111111111111111111111111111111111111111111
18111111111118111111111111111111111111111111111111111111111111111111111111111111111111111111811111111111111181111181111111118111
11111111111111111111111111118111111111111111111111111111111111111111111111111111111111111111111111111111118111111111111111111111
11111181111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111181111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111118111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111181111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111811111111111111111111111111111811111111111111111111111111111111111111111111181111111111111111111111111111111111811111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111181111111111111118111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111118111111111111111111111111111111811111111111111181111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111118811111111111118118111111111111111
11111111111111111111111111111111111111111111181111111111181118111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111118111111111111111111111111111111111111111111111111111111111111881111111111
11111111111111111111111111111111111111111111111111111111111111118111111111111111111111111111111111111111111111111111118111111111
11118111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111811111111111111111
11181111111111111111111111118111111111111118111111111111111111111111111111111111111111111111111111111111111111111111111811111111
11111111111111111111111111111111111111111811111111111111111161116111611111111111111111111111111111111111111111111181111111111111
11111111111111111111111111111111111111111111111177717771777117711771111117777711111111111111111111111111111111111111111111111111
11111111111111188111111111111111111111111111111171717171711171117111111177171771111111181111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111177717711771177717771111177717778111111111111111111111111111111111111111111111111
1111111111111111111111111111111111111111181111117111717171116171b171611177171771111111111111111111111111111111111111111111111111
11111811111111111811111111111111111111111111111171117171777177117711111117777711111111111111111118111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111118111111
11111111111111111181111111111811111111111111111177711771111117717771777177717771111111111111111111111111111111111111111181111111
11111118111111111111111111111111111111111111111117117171111171116711717171711711111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111118111117117171111177711711777177111711111111111111111118111111111111111111111111111111
11111111111111111111111111111111111111111111111117117171111111711711717171711711111111111111111111181111111111111111111111111111
11111111111111118111111111111111111111111111111117117711111177111711717171711711111111111111111111111111111111111111111111111111
11111111111111111111181111111111111111118111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111181111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111181111111111111
11111111111111111111111111111111111111111118111111111811111111111111111111811111111111111111181811111111111111111111111111111111
11111111111111111111111811111111111111111111111111111111111118111111111111111111111111111111111111111181111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111118111111111111111111111111111111111111111111111111111181111111
11111111111181111111111111111111111111111111111111118111111111111111111111111181111111118111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111181111111111111111111111
11111111111111111111111111181111111111111111111111111111111111111111111111111181111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111118111111111111111111111111111111111111111111
11111111111111111111111111181111111111111111111111811111111111111111181111111111111111111111811111111111111111111111111111181111
11111811111111181111111111111111111111111111111111111111111111111111111111811111111111111111111111111111118111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111118111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111811111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111181111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111118111111111111111111111111111111111111111111111111111111111111111111111111111111111118111111111111111181118
11111111111111111111111111111111111118111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111181111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111811111111181111811111111
11111111111111111111181111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111118111111111111111111111111111111111111118111111111111111111111111111181111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111181181111111111111111111111111111111111111111111111111111111111111111111111
11111811111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111118111111111111111111111
11111111111111111111111111111181111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111118111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111811111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111811111111111111111111111111118111111111111111111118111111111111111111111111111111
11111181111111111111111111111111118111111111811111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111181111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111118111111111111111111111111111111111111111
11111111111111111111111111111118111111111111111111111111111111118111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111811111111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111811111111111111111111111111111111111111111111111111111111111111111111111111111111111111118111111111111118111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111118111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111118111111111111111111111
11111111111111111111111111111111111111111118111111111111111111111111111111111111111111111111111111111111111111111118111111111111
11111811111111111111111111111111111111111111111111111111111111111111111111111111111111111111811811111111111111111111111111118111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111181811111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111118111111
11111118111111111111111111111111111111811111111111111111111111111111111111111111111118111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111118111111111
11111111111111111111111111111111111811111111111111111111111111111111111111111111111111111111111111118111111111111111111111181111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111181111111111111111111
11181111111111111111111111111111111111111111111111111111111111111111111111111111111111111111181111111111111111111811111111111111
18111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111811111111
11111111111111111111111111111111111111111111811111111111111111111111111181111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111811111111111111111111111111111111111111111111111111811111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111188111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111118111111111111111111111111111111111111111111811111111111111111111111111111111111111
11118111111111111111111111111111118111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
__gff__
0000000000000000000000000000000000000000000000000000000000000000010101010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
__sfx__
000100002e05000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
9d0800000215000000000001910018100021500000000000021500000002150000000000014100131000515000000121000415000000041500000011100021500000002150000000010001150000000215000100
000d00000c150000000f1500f1501315100000000001115000000000000c15000000000000000000000000000000000000000000a15000000000000c150000000000000000000000000000000000000000000000