diff --git a/vacation.p8 b/vacation.p8 index 957850f..16f1895 100644 --- a/vacation.p8 +++ b/vacation.p8 @@ -1268,12 +1268,11 @@ end wordtarget = { x = 129, y = 60, - str = "GOOD TOY!", on_hit = nop, } mknew(wordtarget, function(x) poke(0x5f58, 0x81) - x.w = print(x.str or wordtarget.str, 0, -9999)-1 + x.w = print(x.str, 0, -9999)-1 end) function collides(b1, b2) @@ -1398,21 +1397,19 @@ end arcade_level = { score=0, - max_score=999, wordwait = 90, } mknew(arcade_level, function(x) x.phin = toyphin.new{splasher=x} - -- TODO: decent looking sky and sea x.sky = bg.new{c=13} x.sea = sea.new() x.bg = event_list.new() x.fg = event_list.new() x.words = event_list.new() - -- TODO: score renderer x.t0 = t() x.wordremain = x.max_score or arcade_level.max_score x.wordtimer = x.wordwait or arcade_level.wordwait + if (type(x.wordsets) == "string") x.wordsets = csv(x.wordsets) x.v = view.of{ x.sky, @@ -1466,18 +1463,71 @@ function arcade_level:update() end function arcade_level:spawn_word() - -- TODO: basically everything. - -- word lists - -- pattern generator + -- pick row from pattern + 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 + local row = self.pattern[i] + 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, on_hit = function(word) self:word_hit(word) end, + str=rnd(self.wordsets[row + pbk]), }) 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) self.score += 1 -- TODO: sfx @@ -1580,11 +1630,10 @@ function start_game() { f=zonk_mode.new, params={{ - file=[[center:4:20 + file=[[center:4:19 wELCOME! iN A LATER VERSION, THERE WILL -BE INSTRUCTIONS HERE -AND NO BG yet.]], +BE A TUTORIAL HERE.]], txd=0, txf=1, cmul=0.25, @@ -1593,8 +1642,14 @@ AND NO BG yet.]], { f = arcade_level.new, 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, @@ -1615,8 +1670,7 @@ bREATHE OUT... set:bwt:0 set:txd:16 set:txf:20 set:exf:60 center:3:19 >gREAT! iT'S LIKE YOU'VE BEEN DOING -THIS ALL YOUR LIFE. - ]], +THIS ALL YOUR LIFE.]], }}, }, }