"scoot" -- quartic ease in

This commit is contained in:
Kistaro Windrider 2024-02-01 20:56:51 -08:00
parent 8f3e780537
commit 56fa99ad45
Signed by: kistaro
SSH Key Fingerprint: SHA256:TBE2ynfmJqsAf0CP6gsflA0q5X5wD5fVKWPsZ7eVUg8

View File

@ -174,15 +174,15 @@ function txtbox:draw()
print(self.text, self.x, self.y, self.col)
end
springup = {
spring = {
from = 128,
to = 0,
frames=60,
f = 0,
}
mknew(springup)
mknew(spring)
function springup:update()
function spring:update()
local v = self.v
self.v:update()
if self.f >= self.frames then
@ -194,7 +194,35 @@ function springup:update()
self.f += 1
end
function springup:draw()
function spring:draw()
self.v:draw()
end
scoot = {
from=64,
to=-16,
frames=30,
f=0,
}
mknew(scoot)
function scoot:update()
local v = self.v
self.v:update()
if self.f >= self.frames then
v.y=self.to
return true
end
self.f += 1
if self.f < 0 then
v.y=self.from
return
end
local t, range = self.f/self.frames, self.to - self.from
v.y = self.from + range * t * t * t * t
end
function scoot:draw()
self.v:draw()
end
@ -209,13 +237,22 @@ end
function newtitle()
return view.of{
bg.new{c=1},
springup.new{
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,
},
}
end