remove broken animator impl. text springs in.
there's something wrong with mknew's attempt to do inheritance. I need to figure out why it's wrong, but for now I think the animator and linked list are just noise.
This commit is contained in:
parent
15d51012ab
commit
8f3e780537
134
vacation.p8
134
vacation.p8
@ -23,7 +23,7 @@ __lua__
|
|||||||
-- dogica font by roberto mocci
|
-- dogica font by roberto mocci
|
||||||
-- https://www.dafont.com/es/dogica.font
|
-- https://www.dafont.com/es/dogica.font
|
||||||
--
|
--
|
||||||
-- converted by josé aular
|
-- converted by josれた aular
|
||||||
-- https://jaular.itch.io/pico-8-dogica-font
|
-- https://jaular.itch.io/pico-8-dogica-font
|
||||||
|
|
||||||
-- tab 0: library
|
-- tab 0: library
|
||||||
@ -80,81 +80,6 @@ function outer_or_each_opt(t, mname)
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
-------------------------------
|
|
||||||
-- linked_list
|
|
||||||
-------------------------------
|
|
||||||
-- intrusive singly-linked list.
|
|
||||||
-- cannot be nested!
|
|
||||||
linked_list = {is_linked_list=true}
|
|
||||||
mknew(linked_list, function(x)
|
|
||||||
x.next=nil
|
|
||||||
x.tail=x
|
|
||||||
end)
|
|
||||||
|
|
||||||
function linked_list:push_back(x)
|
|
||||||
self.tail.next = x
|
|
||||||
self.tail = x
|
|
||||||
end
|
|
||||||
|
|
||||||
function linked_list:push_front(x)
|
|
||||||
if (not self.next) self.tail = x
|
|
||||||
x.next = self.next
|
|
||||||
self.next = x
|
|
||||||
end
|
|
||||||
|
|
||||||
-- vore eats another linked list
|
|
||||||
-- by appending its contents.
|
|
||||||
-- the ingested linked is empty.
|
|
||||||
function linked_list:vore(x)
|
|
||||||
if (not x.next) return
|
|
||||||
self.tail.next = x.next
|
|
||||||
self.tail = x.tail
|
|
||||||
x.next = nil
|
|
||||||
x.tail = x
|
|
||||||
end
|
|
||||||
|
|
||||||
-- strip calls f(x) for each
|
|
||||||
-- node, removing each node for
|
|
||||||
-- which f(x) returns true. it
|
|
||||||
-- returns the new tail; nil
|
|
||||||
-- if the list is now empty.
|
|
||||||
function linked_list:strip(f)
|
|
||||||
local p, n = self, self.next
|
|
||||||
while n do
|
|
||||||
if f(n) then
|
|
||||||
p.next = n.next
|
|
||||||
else
|
|
||||||
p = n
|
|
||||||
end
|
|
||||||
n = n.next
|
|
||||||
end
|
|
||||||
self.tail = p
|
|
||||||
return p
|
|
||||||
end
|
|
||||||
|
|
||||||
-- optimized special case -
|
|
||||||
-- could be done with strip but
|
|
||||||
-- this avoids extra function
|
|
||||||
-- calls and comparisions since
|
|
||||||
-- draw isn't allowed to kill
|
|
||||||
-- the item
|
|
||||||
function linked_list:draw()
|
|
||||||
local n = self.next
|
|
||||||
while n do
|
|
||||||
n:draw()
|
|
||||||
n = n.next
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
function linked_list:pop_front()
|
|
||||||
local ret = self.next
|
|
||||||
if (not ret) return
|
|
||||||
self.next = ret.next
|
|
||||||
if (not ret.next) ret.tail = nil
|
|
||||||
return ret
|
|
||||||
end
|
|
||||||
|
|
||||||
-------------------------------
|
-------------------------------
|
||||||
-- view
|
-- view
|
||||||
-------------------------------
|
-------------------------------
|
||||||
@ -212,22 +137,6 @@ function bg:draw()
|
|||||||
fillp(oldfp)
|
fillp(oldfp)
|
||||||
end
|
end
|
||||||
|
|
||||||
-------------------------------
|
|
||||||
-- animator
|
|
||||||
-------------------------------
|
|
||||||
-- animator is a linked list of
|
|
||||||
-- temporary drawables. a
|
|
||||||
-- temporary drawable is dropped
|
|
||||||
-- when its :update returns
|
|
||||||
-- a non-false value.
|
|
||||||
-------------------------------
|
|
||||||
animator = linked_list.new{}
|
|
||||||
mknew(animator)
|
|
||||||
|
|
||||||
function animator:update()
|
|
||||||
self:strip(function(x) x:update() end)
|
|
||||||
end
|
|
||||||
|
|
||||||
-->8
|
-->8
|
||||||
-- setup and p8 entry points
|
-- setup and p8 entry points
|
||||||
|
|
||||||
@ -235,7 +144,7 @@ function _init()
|
|||||||
-- custom font: dogica
|
-- custom font: dogica
|
||||||
poke(0x5600,unpack(split"6,8,9,0,0,1,0,0,0,0,0,0,0,0,0,0,69,16,32,81,85,0,117,116,0,0,0,0,0,84,22,6,2,0,0,0,96,6,38,0,0,7,7,16,112,87,80,16,5,0,1,0,112,7,39,0,0,0,0,32,0,112,116,1,0,0,96,102,96,0,96,96,0,96,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,1,0,0,10,10,5,0,0,0,0,0,18,63,18,18,63,18,0,0,14,21,5,14,20,21,14,34,21,21,10,40,84,84,34,6,9,9,6,41,17,46,0,0,2,2,1,0,0,0,0,2,1,1,1,1,1,2,0,1,2,2,2,2,2,1,0,0,4,21,10,21,4,0,0,0,4,4,31,4,4,0,0,0,0,0,0,0,2,2,1,0,0,0,0,15,0,0,0,0,0,0,0,0,0,1,0,8,8,4,4,2,2,1,1,14,17,21,21,21,17,14,0,4,7,4,4,4,4,31,0,14,17,16,8,4,2,31,0,15,16,16,14,16,16,15,0,8,12,10,9,31,8,8,0,31,1,15,16,16,17,14,0,14,17,1,15,17,17,14,0,31,17,16,8,4,2,2,0,14,17,17,14,17,17,14,0,14,17,17,30,16,8,6,0,0,0,1,0,0,1,0,0,0,0,0,2,0,2,2,1,0,4,2,1,2,4,0,0,0,0,63,0,63,0,0,0,0,1,2,4,2,1,0,0,14,17,16,12,2,0,4,0,30,33,45,41,29,65,62,0,0,14,16,30,17,17,30,0,1,1,15,17,17,17,15,0,0,14,17,1,1,1,30,0,16,16,30,17,17,17,30,0,0,14,17,31,1,1,30,0,28,2,2,15,2,2,2,0,0,30,17,17,17,30,16,14,1,1,13,19,17,17,17,0,2,0,3,2,2,2,7,0,0,7,2,2,2,2,2,1,0,17,9,5,7,9,17,0,0,1,1,1,1,1,6,0,0,54,73,73,73,73,73,0,0,12,19,17,17,17,17,0,0,14,17,17,17,17,14,0,0,15,17,17,17,15,1,1,0,30,17,17,17,30,16,16,0,13,3,1,1,1,1,0,0,14,1,14,16,17,14,0,1,1,15,1,1,1,14,0,0,17,17,17,17,25,22,0,0,17,17,17,10,10,4,0,0,32,37,37,37,37,26,0,0,17,10,4,4,10,17,0,0,0,9,9,9,6,4,3,0,15,8,4,2,1,15,0,3,1,1,1,1,1,3,0,1,1,2,2,4,4,8,8,3,2,2,2,2,2,3,0,4,10,17,0,0,0,0,0,0,0,0,0,0,0,0,63,0,1,2,2,0,0,0,0,14,17,17,17,31,17,17,0,15,17,17,15,17,17,15,0,14,17,1,1,1,17,14,0,31,34,34,34,34,34,30,0,31,1,1,15,1,1,31,0,31,1,1,15,1,1,1,0,30,1,1,25,17,17,30,0,17,17,17,31,17,17,17,0,7,2,2,2,2,2,7,0,15,4,4,4,4,4,3,0,17,9,5,7,9,9,17,0,1,1,1,1,1,1,15,0,33,33,51,45,33,33,33,0,17,19,21,25,17,17,17,0,14,17,17,17,17,17,14,0,15,17,17,15,1,1,1,0,14,17,17,17,21,9,22,0,15,17,17,15,9,17,17,0,14,17,1,14,16,17,14,0,31,4,4,4,4,4,4,0,17,17,17,17,17,17,14,0,17,17,17,17,10,10,4,0,65,65,73,73,73,85,34,0,17,17,10,4,10,17,17,0,17,17,17,10,4,4,4,0,31,16,8,4,2,1,31,0,4,10,2,1,1,2,10,4,1,1,1,1,1,1,1,1,2,5,4,8,8,4,5,2,0,0,0,38,25,0,0,0,0,0,0,0,0,0,0,0,0,0,127,127,127,127,127,0,0,0,85,42,85,42,85,0,0,0,65,127,93,93,62,0,0,0,62,99,99,119,62,0,0,0,17,68,17,68,17,0,0,0,2,30,14,15,8,0,0,0,14,23,31,31,14,0,0,0,27,31,31,14,4,0,0,0,28,54,119,54,28,0,0,0,14,14,31,14,10,0,0,0,28,62,127,42,58,0,0,0,62,103,99,103,62,0,0,0,127,93,127,65,127,0,0,0,28,4,4,7,7,0,0,0,62,99,107,99,62,0,0,0,4,14,31,14,4,0,0,0,0,0,85,0,0,0,0,0,62,115,99,115,62,0,0,0,8,28,127,62,34,0,0,0,31,14,4,14,31,0,0,0,62,119,99,99,62,0,0,0,0,5,82,32,0,0,0,0,0,17,42,68,0,0,0,0,62,107,119,107,62,0,0,0,127,0,127,0,127,0,0,0,85,85,85,85,85,0"))
|
poke(0x5600,unpack(split"6,8,9,0,0,1,0,0,0,0,0,0,0,0,0,0,69,16,32,81,85,0,117,116,0,0,0,0,0,84,22,6,2,0,0,0,96,6,38,0,0,7,7,16,112,87,80,16,5,0,1,0,112,7,39,0,0,0,0,32,0,112,116,1,0,0,96,102,96,0,96,96,0,96,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,1,0,0,10,10,5,0,0,0,0,0,18,63,18,18,63,18,0,0,14,21,5,14,20,21,14,34,21,21,10,40,84,84,34,6,9,9,6,41,17,46,0,0,2,2,1,0,0,0,0,2,1,1,1,1,1,2,0,1,2,2,2,2,2,1,0,0,4,21,10,21,4,0,0,0,4,4,31,4,4,0,0,0,0,0,0,0,2,2,1,0,0,0,0,15,0,0,0,0,0,0,0,0,0,1,0,8,8,4,4,2,2,1,1,14,17,21,21,21,17,14,0,4,7,4,4,4,4,31,0,14,17,16,8,4,2,31,0,15,16,16,14,16,16,15,0,8,12,10,9,31,8,8,0,31,1,15,16,16,17,14,0,14,17,1,15,17,17,14,0,31,17,16,8,4,2,2,0,14,17,17,14,17,17,14,0,14,17,17,30,16,8,6,0,0,0,1,0,0,1,0,0,0,0,0,2,0,2,2,1,0,4,2,1,2,4,0,0,0,0,63,0,63,0,0,0,0,1,2,4,2,1,0,0,14,17,16,12,2,0,4,0,30,33,45,41,29,65,62,0,0,14,16,30,17,17,30,0,1,1,15,17,17,17,15,0,0,14,17,1,1,1,30,0,16,16,30,17,17,17,30,0,0,14,17,31,1,1,30,0,28,2,2,15,2,2,2,0,0,30,17,17,17,30,16,14,1,1,13,19,17,17,17,0,2,0,3,2,2,2,7,0,0,7,2,2,2,2,2,1,0,17,9,5,7,9,17,0,0,1,1,1,1,1,6,0,0,54,73,73,73,73,73,0,0,12,19,17,17,17,17,0,0,14,17,17,17,17,14,0,0,15,17,17,17,15,1,1,0,30,17,17,17,30,16,16,0,13,3,1,1,1,1,0,0,14,1,14,16,17,14,0,1,1,15,1,1,1,14,0,0,17,17,17,17,25,22,0,0,17,17,17,10,10,4,0,0,32,37,37,37,37,26,0,0,17,10,4,4,10,17,0,0,0,9,9,9,6,4,3,0,15,8,4,2,1,15,0,3,1,1,1,1,1,3,0,1,1,2,2,4,4,8,8,3,2,2,2,2,2,3,0,4,10,17,0,0,0,0,0,0,0,0,0,0,0,0,63,0,1,2,2,0,0,0,0,14,17,17,17,31,17,17,0,15,17,17,15,17,17,15,0,14,17,1,1,1,17,14,0,31,34,34,34,34,34,30,0,31,1,1,15,1,1,31,0,31,1,1,15,1,1,1,0,30,1,1,25,17,17,30,0,17,17,17,31,17,17,17,0,7,2,2,2,2,2,7,0,15,4,4,4,4,4,3,0,17,9,5,7,9,9,17,0,1,1,1,1,1,1,15,0,33,33,51,45,33,33,33,0,17,19,21,25,17,17,17,0,14,17,17,17,17,17,14,0,15,17,17,15,1,1,1,0,14,17,17,17,21,9,22,0,15,17,17,15,9,17,17,0,14,17,1,14,16,17,14,0,31,4,4,4,4,4,4,0,17,17,17,17,17,17,14,0,17,17,17,17,10,10,4,0,65,65,73,73,73,85,34,0,17,17,10,4,10,17,17,0,17,17,17,10,4,4,4,0,31,16,8,4,2,1,31,0,4,10,2,1,1,2,10,4,1,1,1,1,1,1,1,1,2,5,4,8,8,4,5,2,0,0,0,38,25,0,0,0,0,0,0,0,0,0,0,0,0,0,127,127,127,127,127,0,0,0,85,42,85,42,85,0,0,0,65,127,93,93,62,0,0,0,62,99,99,119,62,0,0,0,17,68,17,68,17,0,0,0,2,30,14,15,8,0,0,0,14,23,31,31,14,0,0,0,27,31,31,14,4,0,0,0,28,54,119,54,28,0,0,0,14,14,31,14,10,0,0,0,28,62,127,42,58,0,0,0,62,103,99,103,62,0,0,0,127,93,127,65,127,0,0,0,28,4,4,7,7,0,0,0,62,99,107,99,62,0,0,0,4,14,31,14,4,0,0,0,0,0,85,0,0,0,0,0,62,115,99,115,62,0,0,0,8,28,127,62,34,0,0,0,31,14,4,14,31,0,0,0,62,119,99,99,62,0,0,0,0,5,82,32,0,0,0,0,0,17,42,68,0,0,0,0,62,107,119,107,62,0,0,0,127,0,127,0,127,0,0,0,85,85,85,85,85,0"))
|
||||||
-- to use custom fonts, poke(0x5f58, 0x81)
|
-- to use custom fonts, poke(0x5f58, 0x81)
|
||||||
mainview = titlescreen
|
mainview = newtitle()
|
||||||
end
|
end
|
||||||
|
|
||||||
function _update()
|
function _update()
|
||||||
@ -258,11 +167,36 @@ txtbox = {
|
|||||||
}
|
}
|
||||||
mknew(txtbox)
|
mknew(txtbox)
|
||||||
|
|
||||||
|
function txtbox:update() end
|
||||||
|
|
||||||
function txtbox:draw()
|
function txtbox:draw()
|
||||||
poke(0x5f58, self.mode)
|
poke(0x5f58, self.mode)
|
||||||
print(self.text, self.x, self.y, self.col)
|
print(self.text, self.x, self.y, self.col)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
springup = {
|
||||||
|
from = 128,
|
||||||
|
to = 0,
|
||||||
|
frames=60,
|
||||||
|
f = 0,
|
||||||
|
}
|
||||||
|
mknew(springup)
|
||||||
|
|
||||||
|
function springup:update()
|
||||||
|
local v = self.v
|
||||||
|
self.v:update()
|
||||||
|
if self.f >= self.frames then
|
||||||
|
v.y=self.to
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
local t, range = self.f/self.frames, self.to - self.from
|
||||||
|
v.y = self.to-range*(2^(-10*t)*cos(2*t))
|
||||||
|
self.f += 1
|
||||||
|
end
|
||||||
|
|
||||||
|
function springup:draw()
|
||||||
|
self.v:draw()
|
||||||
|
end
|
||||||
|
|
||||||
-->8
|
-->8
|
||||||
-- sprite rendering
|
-- sprite rendering
|
||||||
@ -272,14 +206,18 @@ end
|
|||||||
|
|
||||||
-->8
|
-->8
|
||||||
-- title screen
|
-- title screen
|
||||||
titlescreen = view.of{
|
function newtitle()
|
||||||
|
return view.of{
|
||||||
bg.new{c=1},
|
bg.new{c=1},
|
||||||
txtbox.new{
|
springup.new{
|
||||||
x=10,
|
v=txtbox.new{
|
||||||
y=35,
|
x=30,
|
||||||
text="tEXTBOX tEST",
|
text="sPRING tEST",
|
||||||
},
|
},
|
||||||
|
to=16,
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
-->8
|
-->8
|
||||||
-- zonk mode
|
-- zonk mode
|
||||||
|
Loading…
Reference in New Issue
Block a user