Skip to content

Instantly share code, notes, and snippets.

@pancelor
Last active May 13, 2024 00:14
Show Gist options
  • Save pancelor/5196243ebbb51ca97905b0df52f11d26 to your computer and use it in GitHub Desktop.
Save pancelor/5196243ebbb51ca97905b0df52f11d26 to your computer and use it in GitHub Desktop.
r=rnd?"⁶!5f2d3"
f=127o=0j=0m=r()d={}for i=1,8do d[i]={r(f),r(f),5+i%6,r(2),r(2)}end::f::c=stat(32)g=stat(33)srand(m)for d=1,22do?".",r(f),r(f),5+d%3
end if(#d<1)?"⁶jemwin!⁶9⁶9"
u=unpack?"⁶1⁶c"
if(o<t())i=░ if(btnp(5))j+=1e=c i=g o=t()+█?"⁷i4c2eag"
for f in all(d)do n,a=u(f)if(n&-128~=0)f[4]*=-1
if(a&-128~=0)f[5]*=-1
f[1]=n+f[4]f[2]=a+f[5]if(o==t()+█ and abs(n-e+3)+abs(a-i+2)<5)del(d,f)?"⁷i6fc"
l=line?"😐",u(f)
end l(0,0,e,i,12)l(0,f)l(f,0,e,i)l(f,f)?"⁵fe+⁶j11⧗:"..t().."⁶jq1◆:"..j,c,g,7
goto f
--spaceface
-- by ThatTomHall, modified+minified by pancelor. 496 bytes
--[[
This code isn't meant to be readable, but you can take a look if you like.
This is the actual code I edited while working on the game.
(I ran it through shrinko8 to rename vars and remove comments/spaces to get the final cart)
]]
--[[rename::r]]rnd_=rnd
?"\^!5f2d3" -- turn on mouse
-- mx=64 --cursor location
-- my=64
_127=127 --screen limit. can't be 128 b/c then the laser lines look bad
kt=0--the future value of t() at which the player can shoot again
sc=0 --score
seed=rnd_() -- for stars
enp={} -- enemy properties
for i=1,8 do
-- space faces
enp[i]={
rnd_(_127), --1=x
rnd_(_127), --2=y
5+i%6, --3=color
rnd_(2), --4=dx
rnd_(2), --5=dy
}
end
::s::
mx=stat(32) -- read mouse - before flip-cls b/c targeting code check prev pos for enemies
my=stat(33)
-- draw stars
-- this is the last thing in the frame, so they go _in front_ of the faces sometimes
-- which is awkward
-- but doing it this way avoids awkward "screenshake" due to printing sfx (sometimes it scrolls the screen)
srand(seed)
for i=1,22 do
?".",rnd_(_127),rnd_(_127),5+i%3
end
-- win message is after the stars -- this code pauses for 16 seconds and then runs a single frame
if (#enp<1)?"\^jemwin!\^9\^9"
-- do_toast()--pqn
--[[rename::u]]unpack_=unpack
?'\^1\^c' --flip-cls
--[[
if (kt<t()) do
-- reset laser
-- tx=nil --laser pos
ty=░ --store it _wildly_ offscreen
-- shoot laser
if (btnp(5)) do
sc += 1
tx=mx
ty=my
kt=t()+█ --█ v. .5 is tricky b/c █ sometimes needs a space after
-- ?'\^3' --pause --feels good but needs to happen after drawing, and there's no easy way to do that
-- sfx(0) -- zap
?"\ai4c2eag"
end
--]]
-- needs to be one line b/c shrinko8 won't merge if-if-? I guess
if (kt<t())ty=░ if (btnp(5)) sc += 1 tx=mx ty=my kt=t()+█ ?"\ai4c2eag"
-- enemies
for en in all(enp) do
-- move
x,y=unpack_(en)
--[[
if (x>127 or x<0) en[4]*=-1
if (y>127 or y<0) en[5]*=-1
--]]
-- bounce
if (x&-128!=0) en[4]*=-1
if (y&-128!=0) en[5]*=-1
-- move
en[1]=x+en[4]
en[2]=y+en[5]
-- die
if (kt==t()+█ and abs(x-tx+3)+abs(y-ty+2)<5) do --pico8-logo-shaped hitbox (taxicab distance)
-- if (kt==t()+█ and abs(x-tx)<3 and abs(y-ty)<3) do
del(enp,en)
?"\ai6fc"
-- sfx(1) -- boom
end
--[[rename::l]]line_=line
-- draw faces
?"😐",unpack_(en)
end
-- draw lasers
line_(0,0,tx,ty,12)
line_(0,_127)
line_(_127,0,tx,ty)
line_(_127,_127)
-- print hud after lasers (esp necessary for when game ends right after)
?"\+fe+\^j11⧗:"..t().."\^jq1◆:"..sc,mx,my,7
goto s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment