diff --git a/vacation.p8 b/vacation.p8 index e4e8910..ee13d59 100644 --- a/vacation.p8 +++ b/vacation.p8 @@ -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