From c60b07183b7ae859b08f515ab2d1b374d7ca630e Mon Sep 17 00:00:00 2001 From: Kistaro Windrider Date: Fri, 2 Feb 2024 21:14:07 -0800 Subject: [PATCH] scootbox: a frame for dumping stuff into and scooting it off later --- vacation.p8 | 73 ++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 53 insertions(+), 20 deletions(-) diff --git a/vacation.p8 b/vacation.p8 index ee13d59..c3502dc 100644 --- a/vacation.p8 +++ b/vacation.p8 @@ -158,11 +158,15 @@ end -->8 -- text rendering +-- text colors for zonk mode: +-- 8 -- standard +-- 9 -- delayed fade +-- 10 -- currently fading in txtbox = { x=0, y=0, text="???", - col=6, + col=8, mode=0x81, } mknew(txtbox) @@ -199,8 +203,8 @@ function spring:draw() end scoot = { - from=64, - to=-16, + from=0, + to=-128, frames=30, f=0, } @@ -219,13 +223,43 @@ function scoot:update() return end local t, range = self.f/self.frames, self.to - self.from - v.y = self.from + range * t * t * t * t + v.y = self.from + range * t * t end function scoot:draw() self.v:draw() end +scootbox = {} +mknew(scootbox, function(x) + x.v = view.new() + x.s = scoot.new{ + from=x.from or scoot.from, + to=x.to or scoot.to, + frames=x.frames or scoot.frames, + v=x.v + } +end) + +function scootbox:update() + if self.go then + self.s:update() + else + self.v:update() + end +end + +function scootbox:push(drawable) + add(self.v.views, drawable) +end + +function scootbox:done() + return self.s.f >= self.s.frames +end + +function scootbox:draw() + return self.v:draw() +end -->8 -- sprite rendering @@ -235,24 +269,23 @@ end -->8 -- title screen function newtitle() + local box = scootbox.new() + box:push(spring.new{ + v=txtbox.new{ + x=30, + text="sPRING tEST", + }, + to=64, + }) return view.of{ + { + update=function() + box.go = btn(4) + -- if (box:done()) mainview.views[2].c=2 + end + }, bg.new{c=1}, - spring.new{ - v=txtbox.new{ - x=30, - text="sPRING tEST", - }, - to=16, - }, - scoot.new{ - v=txtbox.new{ - x=65, - text="bYE!", - }, - from=64, - to=128, - f=-150, - }, + box, } end