scootbox: a frame for dumping stuff into and scooting it off later
This commit is contained in:
parent
56fa99ad45
commit
c60b07183b
73
vacation.p8
73
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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user