18 Commits

Author SHA1 Message Date
b91ebeb775 fix boss
it works now except for a square being drawn in the shield. good enough
2023-12-20 13:33:00 -08:00
ab687f8f6d adjust spawning
now it runs for a little tiny bit!
2023-12-20 13:23:29 -08:00
bef95df6a1 typo 2023-12-20 13:18:20 -08:00
24435a3c15 move guns before ships 2023-12-20 13:18:01 -08:00
0c3a36f1fd defer zap_gun creation until it exists 2023-12-20 13:15:34 -08:00
a39c419e5f fix mknew 2023-12-20 13:13:51 -08:00
9ef762268f many assorted syntax errors 2023-12-20 13:04:13 -08:00
e50f516b11 allow strings when spawning guns 2023-12-20 12:00:34 -08:00
f9e28fa0e2 fix missing paren 2023-12-20 11:59:20 -08:00
38a054dec1 candidate conversion to csv for level format 2023-12-20 11:48:08 -08:00
fd391ff3bc use _ENV to get rid of level_events and spawns 2023-12-20 11:40:11 -08:00
fbd9f97429 maybe fix the level parser 2023-12-20 11:33:59 -08:00
2a61e8b5d6 partial conversion to CSV-based levels, does not run yet 2023-10-15 21:09:12 -07:00
4ccbe1dc35 okay honestly this all can and should just be CSVs 2023-10-13 01:02:43 -07:00
b536d2c987 base for representing a level as a string 2023-10-08 00:41:24 -07:00
62fe5f51d3 val helper function 2023-10-07 23:57:27 -07:00
fd68ef88ec document The Parser, take an emit function. 2023-10-07 23:53:40 -07:00
fd9866e963 The Parser 2023-10-03 22:41:52 -07:00
2 changed files with 611 additions and 530 deletions

61
the_parser.p8 Normal file
View File

@ -0,0 +1,61 @@
pico-8 cartridge // http://www.pico-8.com
version 41
__lua__
-- the parser
parser = {}
mknew(parser)
-- calls parse_into with a nop
-- emit function.
function parser:parse(str)
self:parse_into(str, function() end)
end
-- read a file of commands and
-- execute them, emitting the
-- results from each call into
-- `emit` as a table per row.
--
-- a "command" is a method on
-- self. a row alternates
-- commands with args. when
-- calling a command, it also
-- gets a table of previous
-- results as the first arg.
-- args are split on ','.
function parser:parse_into(str, emit)
for row in all(split(str, "\n")) do
local prev = {}
local sectors = split(row, ":")
for i=1,#sectors,2 do
local x = self[sectors[i]](self, prev, usplit(sectors[i+1]))
if (x) add(prev, x)
end
emit(prev)
end
end
-- saves prev[sel] as self.name.
-- if sel is unspecified, saves
-- all of prev (as a table).
function parser:saveas(prev, name, sel)
self[name] = sel and prev[sel] or prev
end
-- returns its args, ignoring
-- prev. Used to stuff things
-- into prev. args are packed
-- if there's multiple.
function parser:val(_, ...)
local ret := pack(...)
if (#ret == 1) return ret[1]
return ret
end
function parser:bind(_, fn, ...)
local f = self[fn]
return function()
f(...)
end
end

File diff suppressed because it is too large Load Diff