arcade mode: pattern generator, word sets

it's, uh, pretty effective for hypnosis, as it turns out
This commit is contained in:
Kistaro Windrider 2024-02-11 15:24:44 -08:00
parent eb0ccb50aa
commit 0476f22fc5
Signed by: kistaro
SSH Key Fingerprint: SHA256:TBE2ynfmJqsAf0CP6gsflA0q5X5wD5fVKWPsZ7eVUg8

View File

@ -1268,12 +1268,11 @@ end
wordtarget = { wordtarget = {
x = 129, x = 129,
y = 60, y = 60,
str = "GOOD TOY!",
on_hit = nop, on_hit = nop,
} }
mknew(wordtarget, function(x) mknew(wordtarget, function(x)
poke(0x5f58, 0x81) poke(0x5f58, 0x81)
x.w = print(x.str or wordtarget.str, 0, -9999)-1 x.w = print(x.str, 0, -9999)-1
end) end)
function collides(b1, b2) function collides(b1, b2)
@ -1398,21 +1397,19 @@ end
arcade_level = { arcade_level = {
score=0, score=0,
max_score=999,
wordwait = 90, wordwait = 90,
} }
mknew(arcade_level, function(x) mknew(arcade_level, function(x)
x.phin = toyphin.new{splasher=x} x.phin = toyphin.new{splasher=x}
-- TODO: decent looking sky and sea
x.sky = bg.new{c=13} x.sky = bg.new{c=13}
x.sea = sea.new() x.sea = sea.new()
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.max_score or arcade_level.max_score x.wordremain = x.max_score or arcade_level.max_score
x.wordtimer = x.wordwait or arcade_level.wordwait x.wordtimer = x.wordwait or arcade_level.wordwait
if (type(x.wordsets) == "string") x.wordsets = csv(x.wordsets)
x.v = view.of{ x.v = view.of{
x.sky, x.sky,
@ -1466,18 +1463,71 @@ function arcade_level:update()
end end
function arcade_level:spawn_word() function arcade_level:spawn_word()
-- TODO: basically everything. -- pick row from pattern
-- word lists if not self.pattern then
-- pattern generator self.pattern=gen_pattern()
self.pattern_idx = 0
self.next_break = 9 + flr(rnd(9))
end
local i, pbk = (self.pattern_idx&3)+1,0
if self.next_break == 0 then
-- do pattern break
local np = gen_pattern()
i = np[1]==self.pattern[i] and 2 or 1
self.next_break = 9 + flr(rnd(9))
pbk=3
end
self.pattern_idx = i
self.next_break -= 1
local row = self.pattern[i]
self.words:push_back(wordtarget.new{ self.words:push_back(wordtarget.new{
y=32+rnd(64), -- real game uses pattern generator! y=32*row+flr(rnd(13))-6,
phin=self.phin, phin=self.phin,
on_hit = function(word) on_hit = function(word)
self:word_hit(word) self:word_hit(word)
end, end,
str=rnd(self.wordsets[row + pbk]),
}) })
end end
function irnd(n)
return rnd(n) & 0x7fff
end
function gen_pattern()
local x0 = irnd(3)
local x1 = irnd(2)
if (x1 == x0) x1 = 2
local x2 = irnd(2)
if (x2 == x1) x2 = 2
local x3 = irnd(2)
if (x3 == x2) x3 = 2
while x3 == x2 or x3 == x0 do
x3 = (x3 + 1)%3
end
return {x0 + 1, x1 + 1, x2 + 1, x3 + 1}
end
function arcade_level:next_row()
if not self.pattern then
self.pattern=gen_pattern()
self.pattern_idx = 0
self.next_break = 9 + flr(rnd(9))
end
local i, pbk = (self.pattern_idx&3)+1,0
if self.next_break == 0 then
-- do pattern break
local np = gen_pattern()
i = np[1]==self.pattern[i] and 2 or 1
self.next_break = 9 + flr(rnd(9))
pbk=3
end
self.pattern_idx = i
self.next_break -= 1
return self.pattern[i], pbk
end
function arcade_level:word_hit(word) function arcade_level:word_hit(word)
self.score += 1 self.score += 1
-- TODO: sfx -- TODO: sfx
@ -1580,11 +1630,10 @@ function start_game()
{ {
f=zonk_mode.new, f=zonk_mode.new,
params={{ params={{
file=[[center:4:20 file=[[center:4:19
wELCOME! iN A LATER wELCOME! iN A LATER
VERSION, THERE WILL VERSION, THERE WILL
BE INSTRUCTIONS HERE BE A TUTORIAL HERE.]],
AND NO BG yet.]],
txd=0, txd=0,
txf=1, txf=1,
cmul=0.25, cmul=0.25,
@ -1593,8 +1642,14 @@ AND NO BG yet.]],
{ {
f = arcade_level.new, f = arcade_level.new,
params = {{ params = {{
max_score=5, max_score=25,
}} wordsets=[[JUMP,PLAY,AIR,SUN
DRIFT,SURF,FLOAT,WAVES
DIVE,WATER,OCEAN,SEA
DRIFT,SOAR,IMAGINE,BE
RELAX,CHILL,TOY,POOLTOY
SINK,DEEP,TRANCE,FOLLOW]]
}},
}, },
{ {
f = zonk_mode.new, f = zonk_mode.new,
@ -1615,8 +1670,7 @@ bREATHE OUT...
set:bwt:0 set:txd:16 set:txf:20 set:exf:60 center:3:19 set:bwt:0 set:txd:16 set:txf:20 set:exf:60 center:3:19
>gREAT! iT'S LIKE >gREAT! iT'S LIKE
YOU'VE BEEN DOING YOU'VE BEEN DOING
THIS ALL YOUR LIFE. THIS ALL YOUR LIFE.]],
]],
}}, }},
}, },
} }