create orchestrator system that actually works

the slide off screen bit creates a palette problem but that's separate
This commit is contained in:
Kistaro Windrider 2024-02-07 00:35:27 -08:00
parent 76afbcbfe1
commit 523361500a
Signed by: kistaro
SSH Key Fingerprint: SHA256:TBE2ynfmJqsAf0CP6gsflA0q5X5wD5fVKWPsZ7eVUg8

View File

@ -385,9 +385,23 @@ end
-- currently just loading
-- whatever view I want to debug
function newtitle()
return arcade_level.new()
return title_screen.new()
end
title_screen = {}
mknew(title_screen)
function title_screen:draw()
pal()
memset(0x5f78,0x0,8)
cls(12)
print("title screen", 40, 58, 0)
print("press right arrow", 30, 65, 0)
end
function title_screen:update()
if (btnp(1)) start_game()
end
-->8
-- dolphin sprite renderer
@ -700,7 +714,7 @@ end
arcade_level = {
score=0,
wordcount=999,
max_score=999,
wordwait = 90,
}
mknew(arcade_level, function(x)
@ -713,7 +727,7 @@ mknew(arcade_level, function(x)
x.words = event_list.new()
-- TODO: score renderer
x.t0 = t()
x.wordremain = x.wordcount or arcade_level.wordcount
x.wordremain = x.max_score or arcade_level.max_score
x.wordtimer = x.wordwait or arcade_level.wordwait
x.v = view.of{
@ -758,14 +772,12 @@ function arcade_level:update()
if self.wordremain <= 0 and self.words.next == nil then
self.phin.exiting = true
end
if self.phin.x > 90 then
-- TODO: done callback
self:on_level_done()
end
self.s.go = self.phin.x > 90
-- TODO: timers, word loop,
-- level state tracking and
-- progression, etc.
self.s:update()
if (self.s:done()) seq:next()
end
function arcade_level:spawn_word()
@ -850,6 +862,39 @@ end
-->8
-- game sequencer
sequencer = {
idx = 0,
score = 0,
max_score = 0,
}
mknew(sequencer)
function sequencer:next()
if (mainview.score) self.score += mainview.score
if (mainview.max_score) self.max_score += mainview.max_score
self.idx += 1
local rec = self[self.idx]
if rec == nil then
mainview = newtitle()
return
end
mainview = rec.f(unpack(rec.params))
mainview:update()
end
function start_game()
seq = sequencer.new{
{
f = arcade_level.new,
params = {{
max_score=5,
}}
}
}
seq:next()
end
__gfx__
00888800777777777777777777777777000000000000000000000000777777777777777700000000000000000000000000000000000000000000000000000000
0888e780700000000000000000000007000000000000000000000000700000000000000700000000000000000000000000000000000000000000000000000000