create orchestrator system that does not work
This commit is contained in:
parent
76afbcbfe1
commit
63e7bfeb40
119
vacation.p8
119
vacation.p8
@ -249,6 +249,7 @@ function _init()
|
|||||||
poke(0x5f34, 1)
|
poke(0x5f34, 1)
|
||||||
|
|
||||||
mainview = newtitle()
|
mainview = newtitle()
|
||||||
|
mainview:on_focus()
|
||||||
end
|
end
|
||||||
|
|
||||||
function _update60()
|
function _update60()
|
||||||
@ -382,10 +383,42 @@ end
|
|||||||
-->8
|
-->8
|
||||||
-- title screen
|
-- title screen
|
||||||
|
|
||||||
|
title_screen = {
|
||||||
|
}
|
||||||
|
mknew(title_screen)
|
||||||
|
|
||||||
|
function title_screen:draw()
|
||||||
|
pal()
|
||||||
|
cls(12)
|
||||||
|
print("title screen", 30, 58, 0)
|
||||||
|
print("press right arrow", 20, 65, 0)
|
||||||
|
end
|
||||||
|
|
||||||
|
function title_screen:on_focus()
|
||||||
|
self.active = true
|
||||||
|
end
|
||||||
|
|
||||||
|
function title_screen:update()
|
||||||
|
if (self.sq or not self.active or not btnp(1)) return
|
||||||
|
self.sq = sequencer.new{
|
||||||
|
{
|
||||||
|
activate = function(self, sq)
|
||||||
|
return arcade_level.new{
|
||||||
|
maxscore=2,
|
||||||
|
sq = sq,
|
||||||
|
}
|
||||||
|
end,
|
||||||
|
dir=slide_left,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
self.sq:do_it()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
-- currently just loading
|
-- currently just loading
|
||||||
-- whatever view I want to debug
|
-- whatever view I want to debug
|
||||||
function newtitle()
|
function newtitle()
|
||||||
return arcade_level.new()
|
return title_screen.new()
|
||||||
end
|
end
|
||||||
|
|
||||||
-->8
|
-->8
|
||||||
@ -463,10 +496,10 @@ phinstate_error = {
|
|||||||
-- center point of the dolphin.
|
-- center point of the dolphin.
|
||||||
-- many states are off-center.
|
-- many states are off-center.
|
||||||
toyphin = {
|
toyphin = {
|
||||||
x=-12,
|
x=-48,
|
||||||
y=64,
|
y=64,
|
||||||
dy=0,
|
dy=0,
|
||||||
state=phinstate_nrm
|
state=phinstate_nrm,
|
||||||
}
|
}
|
||||||
mknew(toyphin)
|
mknew(toyphin)
|
||||||
|
|
||||||
@ -700,8 +733,9 @@ end
|
|||||||
|
|
||||||
arcade_level = {
|
arcade_level = {
|
||||||
score=0,
|
score=0,
|
||||||
wordcount=999,
|
maxscore=999,
|
||||||
wordwait = 90,
|
wordwait = 90,
|
||||||
|
-- sq: sequencer to call when done
|
||||||
}
|
}
|
||||||
mknew(arcade_level, function(x)
|
mknew(arcade_level, function(x)
|
||||||
x.phin = toyphin.new{splasher=x}
|
x.phin = toyphin.new{splasher=x}
|
||||||
@ -711,9 +745,8 @@ mknew(arcade_level, function(x)
|
|||||||
x.bg = event_list.new()
|
x.bg = event_list.new()
|
||||||
x.fg = event_list.new()
|
x.fg = event_list.new()
|
||||||
x.words = event_list.new()
|
x.words = event_list.new()
|
||||||
-- TODO: score renderer
|
|
||||||
x.t0 = t()
|
x.t0 = t()
|
||||||
x.wordremain = x.wordcount or arcade_level.wordcount
|
x.wordremain = x.maxscore or arcade_level.maxscore
|
||||||
x.wordtimer = x.wordwait or arcade_level.wordwait
|
x.wordtimer = x.wordwait or arcade_level.wordwait
|
||||||
|
|
||||||
x.v = view.of{
|
x.v = view.of{
|
||||||
@ -758,9 +791,9 @@ function arcade_level:update()
|
|||||||
if self.wordremain <= 0 and self.words.next == nil then
|
if self.wordremain <= 0 and self.words.next == nil then
|
||||||
self.phin.exiting = true
|
self.phin.exiting = true
|
||||||
end
|
end
|
||||||
if self.phin.x > 90 then
|
if self.phin.x > 90 and not self.leaving then
|
||||||
-- TODO: done callback
|
self.sq:do_it()
|
||||||
self:on_level_done()
|
self.leaving = true
|
||||||
end
|
end
|
||||||
-- TODO: timers, word loop,
|
-- TODO: timers, word loop,
|
||||||
-- level state tracking and
|
-- level state tracking and
|
||||||
@ -850,6 +883,74 @@ end
|
|||||||
|
|
||||||
-->8
|
-->8
|
||||||
-- game sequencer
|
-- game sequencer
|
||||||
|
|
||||||
|
slider = {}
|
||||||
|
mknew(slider, function(x)
|
||||||
|
x.vf = view.of{x.from}
|
||||||
|
x.vt = view.of{x.to}
|
||||||
|
x.vt.x = x.dir.x
|
||||||
|
x.vt.y = x.dir.y
|
||||||
|
end)
|
||||||
|
|
||||||
|
function slider:update()
|
||||||
|
local vf, vt = self.vf, self.vt
|
||||||
|
vf:update()
|
||||||
|
vt:update()
|
||||||
|
if vt.x == 0 and vt.y == 0 then
|
||||||
|
mainview = vt
|
||||||
|
if (vt.on_focus) vt:on_focus()
|
||||||
|
if (self.sq) self.sq:progress()
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
local dx, dy = self.dir.dx, self.dir.dy
|
||||||
|
vt.x += dx
|
||||||
|
vt.y += dy
|
||||||
|
vf.x += dx
|
||||||
|
vf.y += dy
|
||||||
|
end
|
||||||
|
|
||||||
|
function slider:draw()
|
||||||
|
self.vf:draw()
|
||||||
|
self.vt:draw()
|
||||||
|
end
|
||||||
|
|
||||||
|
slide_left = {
|
||||||
|
x = 128, y = 0, dx = -4, dy = 0
|
||||||
|
}
|
||||||
|
slide_right = {
|
||||||
|
x = -128, y = 0, dx = 4, dy = 0
|
||||||
|
}
|
||||||
|
sequencer = {
|
||||||
|
next_idx = 1,
|
||||||
|
score = 0,
|
||||||
|
maxscore = 0,
|
||||||
|
}
|
||||||
|
mknew(sequencer)
|
||||||
|
|
||||||
|
function sequencer:do_it()
|
||||||
|
local n = self[self.next_idx]
|
||||||
|
if n then
|
||||||
|
if (n.maxscore) self.maxscore += n.maxscore
|
||||||
|
if (mainview.score) self.score += mainview.score
|
||||||
|
mainview = slider.new{
|
||||||
|
from = mainview,
|
||||||
|
to = n:activate(self),
|
||||||
|
dir = n.dir,
|
||||||
|
sq = self,
|
||||||
|
}
|
||||||
|
return
|
||||||
|
end
|
||||||
|
mainview = slider.new{
|
||||||
|
from = mainview,
|
||||||
|
to = newtitle(),
|
||||||
|
dir = slide_right,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
function sequencer:progress()
|
||||||
|
self.next_idx += 1
|
||||||
|
end
|
||||||
|
|
||||||
__gfx__
|
__gfx__
|
||||||
00888800777777777777777777777777000000000000000000000000777777777777777700000000000000000000000000000000000000000000000000000000
|
00888800777777777777777777777777000000000000000000000000777777777777777700000000000000000000000000000000000000000000000000000000
|
||||||
0888e780700000000000000000000007000000000000000000000000700000000000000700000000000000000000000000000000000000000000000000000000
|
0888e780700000000000000000000007000000000000000000000000700000000000000700000000000000000000000000000000000000000000000000000000
|
||||||
|
Loading…
Reference in New Issue
Block a user