scootbox: a frame for dumping stuff into and scooting it off later

This commit is contained in:
Kistaro Windrider 2024-02-02 21:14:07 -08:00
parent 56fa99ad45
commit c60b07183b
Signed by: kistaro
SSH Key Fingerprint: SHA256:TBE2ynfmJqsAf0CP6gsflA0q5X5wD5fVKWPsZ7eVUg8

View File

@ -158,11 +158,15 @@ end
-->8 -->8
-- text rendering -- text rendering
-- text colors for zonk mode:
-- 8 -- standard
-- 9 -- delayed fade
-- 10 -- currently fading in
txtbox = { txtbox = {
x=0, x=0,
y=0, y=0,
text="???", text="???",
col=6, col=8,
mode=0x81, mode=0x81,
} }
mknew(txtbox) mknew(txtbox)
@ -199,8 +203,8 @@ function spring:draw()
end end
scoot = { scoot = {
from=64, from=0,
to=-16, to=-128,
frames=30, frames=30,
f=0, f=0,
} }
@ -219,13 +223,43 @@ function scoot:update()
return return
end end
local t, range = self.f/self.frames, self.to - self.from 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 end
function scoot:draw() function scoot:draw()
self.v:draw() self.v:draw()
end 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 -->8
-- sprite rendering -- sprite rendering
@ -235,24 +269,23 @@ end
-->8 -->8
-- title screen -- title screen
function newtitle() function newtitle()
return view.of{ local box = scootbox.new()
bg.new{c=1}, box:push(spring.new{
spring.new{
v=txtbox.new{ v=txtbox.new{
x=30, x=30,
text="sPRING tEST", text="sPRING tEST",
}, },
to=16, to=64,
}, })
scoot.new{ return view.of{
v=txtbox.new{ {
x=65, update=function()
text="bYE!", box.go = btn(4)
}, -- if (box:done()) mainview.views[2].c=2
from=64, end
to=128,
f=-150,
}, },
bg.new{c=1},
box,
} }
end end