Skip to content

Instantly share code, notes, and snippets.

@vteromero
Created September 4, 2023 06:03
Show Gist options
  • Save vteromero/a844d9f5cc33ecd77d3ff2bf7f2e93dd to your computer and use it in GitHub Desktop.
Save vteromero/a844d9f5cc33ecd77d3ff2bf7f2e93dd to your computer and use it in GitHub Desktop.
pico-8 cartridge // http://www.pico-8.com
version 41
__lua__
function st(e)
if rnd({0,1})==0 then
e.a=20+flr(rnd(60))
e.dx=0
e.dy=0
else
dx=rnd(122)-e.x
dy=rnd(118)-e.y
a=atan2(dx,dy)
e.dx=cos(a)
e.dy=sin(a)
e.a=flr(sqrt(dx*dx+dy*dy))
end
end
function _init()
E={}A={}gs=1f=0t=0
for c in all(split("abcdefghijklmnopqrstuvwxyz0123456789","")) do
e={x=rnd(122),y=rnd(118),c=c,l=0}st(e)add(E,e)
end
tg=rnd(E)
pl=add(E,{x=60,y=59,c=tg.c,l=0})
pldx={-3,3,0,0,-2.12,-2.12,2.12,2.12}pldx[0]=0
pldy={0,0,-3,3,-2.12,2.12,-2.12,2.12}pldy[0]=0
b2d={1,2,0,3,5,7,3,4,6,8,4,0,1,2,0}b2d[0]=0
end
function _draw()
cls(7)
if gs==1 then
for e in all(E) do
rectfill(e.x,e.y+11,e.x+5,e.y+13,6)
pset(e.x-1,e.y+12,6)
pset(e.x+6,e.y+12,6)
end
for e in all(E) do
?"\^w\^t"..e.c,e.x,e.y,0
pset(e.x+2+e.l,e.y+11,0)
pset(e.x+4-e.l,e.y+11,0)
end
else
?t.." seconds",42,50,0
?"try again? 🅾️",38,75,0
end
for a in all(A) do
circfill(a.x,a.y,a.r,0)
end
end
function _update()
if gs==1 then
d=b2d[btn()&0b1111]
pl.dx=pldx[d]
pl.dy=pldy[d]
pl.a=2
for e in all(E) do
e.a-=1
if e.a<=0 then
st(e)
else
e.x=mid(0,e.x+e.dx,122)
e.y=mid(0,e.y+e.dy,118)
end
e.l=(e.dx==0 and e.dy==0 or f%4<2) and 0 or 1
end
if btnp(5) then
local x0,y0,x1,y1,x2,y2,x3,y3=pl.x,pl.y,pl.x+6,pl.y+10,tg.x,tg.y,tg.x+6,tg.y+10
if x1>=x2 and x0<=x3 and y1>=y2 and y0<=y3 then
for i=1,8 do
add(A,{x=pl.x-2+rnd(10),y=pl.y-2+rnd(14),a=8+flr(rnd(8))})
end
?"\as3i5x4v2d1x5v5a1x4v2d1d1x5v5a1x4v2d1d1x5v5a1x4v2d1"
del(E,tg)
pl=del(E,pl)
if #E==0 then
t=f\30
gs=2
else
tg=rnd(E)
pl=add(E,{x=pl.x,y=pl.y,c=tg.c,l=0})
end
end
end
else
if(btnp(4))sfx(-1)_init()
end
for a in all(A) do
a.a-=1
if(a.a==0)del(A,a)
a.r=8*a.a/16
end
if f%191==0 then
?"\asoi0v3x5c1e1g1e1c1e1g1e1g#0c1d#1c1g#0c1d#1c1c1e1g1e1c1e1g1e1a#0d1f1d1a#0d1f1d1"
p=f\191
if(p>1)?"\asoi0v3x3c1.......c1.......c1.......c1"
if(p>3)?"\asoi6v1x5....c3.......c3.......c3.......c3"
end
f+=1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment