diff --git a/vacation.p8 b/vacation.p8 index a87086c..47be317 100644 --- a/vacation.p8 +++ b/vacation.p8 @@ -54,7 +54,7 @@ mknew(event_list, function(x) x.tail=x end) -function event_list:push_back(x) +function event_list:pb(x) self.tail.next = x self.tail = x end @@ -235,7 +235,7 @@ function _update60() awakener_hold_frames=0 awakener_armed=false mainview = fast_awakener() - mainview:activate() + mainview:av() end mainview:u() end @@ -312,7 +312,7 @@ function txtbox:draw() print(self.text, self.x, self.y, self.col) end -function txtbox:xmax() +function txtbox:xm() return print(self.text, self.x, -9999) end @@ -450,7 +450,7 @@ function zonk_txt(s, x, y, p, md, amt, frms) frames=frms, v=v, } - itv.eff_w=t1:xmax()-1 + itv.eff_w=t1:xm()-1 return itv end @@ -639,11 +639,11 @@ function breather:draw() end end -function breather:matches(x, alwaysmatched) +function breather:mt(x, awm) if (not self.on) return true - if (x==1) return not alwaysmatched and self:starting_reverse() - if (x==2) return not alwaysmatched and self:starting_forward() - if (x==3) return not alwaysmatched and self:starting_reverse() or self:starting_forward() + if (x==1) return not awm and self:starting_reverse() + if (x==2) return not awm and self:starting_forward() + if (x==3) return not awm and self:starting_reverse() or self:starting_forward() return true end @@ -693,7 +693,7 @@ zonk_mode = { twt=60, expect_cfg_line=true, txt_frame=blank, - playing_text=true, + px=true, cx=0, cy=0, } @@ -708,7 +708,7 @@ mknew(zonk_mode, function(self) sep=self.br_sep, speed=self.br_spd, } - self.alwaysmatched=true + self.awm=true end) function zonk_mode:set(_, field,value) @@ -752,15 +752,15 @@ function zonk_mode:bgwt(_, w) self.stripes.weight = w end -function zonk_mode:activate() +function zonk_mode:av() clear_alt_pal_bits() pal() font_monogram() if (type(self.file) == "string") self.file = split(self.file, "\n") - if (not self.file) self:next_file() + if (not self.file) self:nf() assert(self.file) end -function zonk_mode:next_file() +function zonk_mode:nf() if #self.files > 0 then self.file=split(deli(self.files,1), "\n") self.expect_cfg_line=true @@ -772,7 +772,7 @@ end -- return char count, item -- or 0, nil: end of page -- or nil (, nil): end of file -function zonk_mode:next_item() +function zonk_mode:ni() if not self.line then if (not self.file or #self.file == 0) return local line = deli(self.file, 1) @@ -785,7 +785,7 @@ function zonk_mode:next_item() self[frags[1]](self, unpack(frags)) end end - return self:next_item() + return self:ni() end if line == "-----" then self.line = nil @@ -800,7 +800,7 @@ function zonk_mode:next_item() self.line = nil self.cx = 0 self.cy += self.lnh - return self:next_item() + return self:ni() end -- parse token local token = tostr(deli(self.line, 1)) @@ -825,7 +825,7 @@ function twmul(s) return 1 end -function zonk_mode:empty() +function zonk_mode:ey() if (self.file and #self.file > 0) return false return #self.files == 0 end @@ -835,16 +835,16 @@ function fadetbl(col, tbl, frac) end function zonk_mode:u() - if (not self.brth:matches(self.bwt)) self.alwaysmatched=false - if self.playing_text then + if (not self.brth:mt(self.bwt)) self.awm=false + if self.px then self.twt -= 1 if self.twt <= 0 then - local item, wt = self:next_item() - self.confirmed = self.confirmed or self.ac + local item, wt = self:ni() + self.cf = self.cf or self.ac if not item then - if (not self.file or #self.file == 0) self:next_file() - self.playing_text=false - if (not self.confirmed) psound(8,8,2) + if (not self.file or #self.file == 0) self:nf() + self.px=false + if (not self.cf) psound(8,8,2) else self.txt_frame:push(item) self.twt = wt*self.cmul @@ -853,36 +853,32 @@ function zonk_mode:u() end else --waiting to advance or exit - if self.wtmr then - self.twt += self.wait_more - self.wtmr = nil - end if self.twt <= 0 then local justc=false - if (btnp(1) and not self.confirmed) self.confirmed,justc=true,true - if not self.nextpage and self.confirmed and self.brth:matches(self.bwt, self.alwaysmatched) then - self.nextpage = true + if (btnp(1) and not self.cf) self.cf,justc=true,true + if not self.nxp and self.cf and self.brth:mt(self.bwt, self.awm) then + self.nxp = true self.txt_frame.go = true self.fpfrm = self.exf - self.alwaysmatched=true + self.awm=true if (not self.ac) psound(8, justc and 16 or 18, 8, true) end - if (justc and not self.nextpage) psound(8,16,2, true) + if (justc and not self.nxp) psound(8,16,2, true) else self.twt -= 1 end end - if self.nextpage and not self.d then + if self.nxp and not self.d then if self.fpfrm > 0 then self.fpfrm -= 1 - elseif self:empty() then + elseif self:ey() then self.txt_frame=blank self.d = ditherer.new{di=0.5} else - self.nextpage = false - self.confirmed=false + self.nxp = false + self.cf=false self.txt_frame=blank - self.playing_text=true + self.px=true self.fpfrm=nil end end @@ -905,10 +901,10 @@ function zonk_mode:draw() fadetbl(15, self.fd15, ffrac) end self.txt_frame:draw() - if not self.playing_text and not self.confirmed and self.twt <= 0 then + if not self.px and not self.cf and self.twt <= 0 then font_default() print("➡️",121,121,12) - print("➡️",120,120,self.brth:matches(self.bwt) and (hz(2) and 7 or 6) or 5) + print("➡️",120,120,self.brth:mt(self.bwt) and (hz(2) and 7 or 6) or 5) end if(self.d) self.d:draw() end @@ -1031,7 +1027,7 @@ function awakener_lock() arm_awakener() return { u=nop, - activate=nop, + av=nop, draw=function() pal() font_default() @@ -1143,7 +1139,7 @@ end -- whatever view I want to debug function newtitle() local ret = title_screen.new() - ret:activate() + ret:av() return ret end @@ -1155,7 +1151,7 @@ mknew(title_screen, function(t) wordwait=9999, extra_layer={ draw=function() - t:draw_menu() + t:m() end, u=nop, }, @@ -1163,8 +1159,8 @@ mknew(title_screen, function(t) } end) -function title_screen:activate() - self.a:activate() +function title_screen:av() + self.a:av() font_monogram() end @@ -1172,7 +1168,7 @@ function title_screen:draw() self.a:draw() end -function title_screen:draw_menu() +function title_screen:m() font_special() print("\^w\^tvACATION", 18, 24, 0) print("\^w\^tvACATION", 17, 23, 3) @@ -1534,7 +1530,7 @@ mknew(arcade_level, function(x) } end) -function arcade_level:activate() +function arcade_level:av() -- TODO: fade in level music font_compact() end @@ -1577,7 +1573,7 @@ function arcade_level:spawn_word() self.next_break -= 1 local row = self.pattern[i] - self.words:push_back(wordtarget.new{ + self.words:pb(wordtarget.new{ y=32*row+irnd(13)-6, phin=self.phin, on_hit = function(word) @@ -1608,8 +1604,8 @@ end function arcade_level:word_hit(word) self.score += 1 -- TODO: sfx - self.bg:push_back(spark.new{x=word.x-1, y=word.y-1, dx=-2}) - self.bg:push_back(spark.new{x=word.x+word.w, y=word.y-1, dx=1}) + self.bg:pb(spark.new{x=word.x-1, y=word.y-1, dx=-2}) + self.bg:pb(spark.new{x=word.x+word.w, y=word.y-1, dx=1}) end function arcade_level:draw() @@ -1624,9 +1620,9 @@ function arcade_level:draw_splash(x, force) for i=0,n do local d = droplet.new{x=x, force=force, y=72+wave(), f=i/n-0.5} if rnd() < 0.5 then - self.bg:push_back(d) + self.bg:pb(d) else - self.fg:push_back(d) + self.fg:pb(d) end end end @@ -1682,7 +1678,7 @@ ggwp = { } mknew(ggwp) -function ggwp:activate() +function ggwp:av() font_monogram() local score_pct = 100 if seq.max_score ~= 0 then @@ -1798,7 +1794,7 @@ function sequencer:next() else mainview = rec.f() end - mainview:activate() + mainview:av() mainview:u() end