|
--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 |