Compare commits
5 Commits
bf6fa03374
...
9a865e418f
Author | SHA1 | Date | |
---|---|---|---|
9a865e418f | |||
4a086be607 | |||
09a09b646a | |||
0574fe4021 | |||
79d6321891 |
112
vacation.p8
112
vacation.p8
@ -59,6 +59,12 @@ function event_list:pb(x)
|
||||
self.tail = x
|
||||
end
|
||||
|
||||
function event_list:pf(x)
|
||||
if (not self.next) self.tail = x
|
||||
x.next = self.next
|
||||
self.next = x
|
||||
end
|
||||
|
||||
function event_list:u()
|
||||
local p, n = self, self.next
|
||||
while n do
|
||||
@ -1485,9 +1491,72 @@ function spark:draw()
|
||||
spr(48+self.f\2, self.x, self.y)
|
||||
end
|
||||
|
||||
-- other fields: level, item
|
||||
-- level must provide:
|
||||
-- function :pdone(item)
|
||||
-- field .pdx (scrolling parallax dx)
|
||||
-- item must provide:
|
||||
-- drawable api
|
||||
-- .x readwrite (draw coord)
|
||||
-- .w (width)
|
||||
parallax = {
|
||||
dx=0,
|
||||
z=1,
|
||||
}
|
||||
mknew(parallax)
|
||||
|
||||
function parallax:u()
|
||||
local item = self.item
|
||||
if item:u() then
|
||||
self.level:pdone(self)
|
||||
return true
|
||||
end
|
||||
|
||||
item.x += self.dx
|
||||
item.x += self.level.pdx * self.z
|
||||
|
||||
if item.x > 256 or item.x + item.w < -128 then
|
||||
self.level:pdone(self)
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
function parallax:draw()
|
||||
self.item:draw()
|
||||
end
|
||||
|
||||
spritem = {
|
||||
s = {0},
|
||||
sw = 1,
|
||||
sh = 1,
|
||||
i = 1,
|
||||
xf = -1,
|
||||
f = 4,
|
||||
x = 0,
|
||||
y = 0,
|
||||
}
|
||||
mknew(spritem, function(self)
|
||||
self.w = (self.sw or spritem.sw) << 3
|
||||
self.h = (self.sh or spritem.sh) << 3
|
||||
end)
|
||||
|
||||
function spritem:u()
|
||||
self.xf += 1
|
||||
if self.xf > self.f then
|
||||
self.i += 1
|
||||
if (self.i > #self.s) self.i = 1
|
||||
self.xf = 0
|
||||
end
|
||||
end
|
||||
|
||||
function spritem:draw()
|
||||
spr(self.s[self.i], self.x, self.y, self.sw, self.sh, self.flipx, self.flipy)
|
||||
end
|
||||
|
||||
arcade_level = {
|
||||
score=0,
|
||||
wordwait = 90,
|
||||
pdx=0,
|
||||
}
|
||||
mknew(arcade_level, function(x)
|
||||
x.phin = toyphin.new{
|
||||
@ -1532,9 +1601,35 @@ end)
|
||||
|
||||
function arcade_level:av()
|
||||
if (musicmode & 1 ==0) music(0,1000,7)
|
||||
for _=1,5 do
|
||||
self:gen_fish(-127, 256)
|
||||
end
|
||||
font_compact()
|
||||
end
|
||||
|
||||
function arcade_level:gen_fish(xmin, xrg)
|
||||
local fishdx = rnd(0.5) - 0.25, rnd(xrg) + xmin
|
||||
local fish = spritem.new{
|
||||
x = rnd(xrg) + xmin,
|
||||
y = 80 + irnd(44),
|
||||
s = {54, 55, 56, 55},
|
||||
flipx = fishdx > 0,
|
||||
i = irnd(4) + 1,
|
||||
f = 20,
|
||||
}
|
||||
self.bg:pf(parallax.new{
|
||||
level=self,
|
||||
item=fish,
|
||||
dx=fishdx,
|
||||
z=0.5 + rnd(0.4),
|
||||
id="fish",
|
||||
})
|
||||
end
|
||||
|
||||
function arcade_level:pdone(item)
|
||||
if (item.id == "fish") self:gen_fish(129, 50)
|
||||
end
|
||||
|
||||
function arcade_level:onmchg()
|
||||
music((musicmode & 0x1 == 0) and 0 or -1, 500, 7)
|
||||
end
|
||||
@ -1558,6 +1653,7 @@ function arcade_level:u()
|
||||
end
|
||||
if (self.d:u()) seq:next()
|
||||
end
|
||||
self.pdx = (self.phin.entered and not self.phin.exiting) and -1 or 0
|
||||
self.v:u()
|
||||
end
|
||||
|
||||
@ -2503,14 +2599,14 @@ __gfx__
|
||||
0000000070000000000000000000000700000000000000000000000070000222222000070000000000222e000000000000000000002227000000000000000000
|
||||
000000007000000000000000000000070000000000000000000000007000000000000007000000000002222e0000000000000000000222270000000000000000
|
||||
000000007777777777777777777777770000000000000000000000007777777777777777022000000022e222ee20000002200000002272227720000000000000
|
||||
000000000000000000000000a00aa00a000aa00000a00a0000000000000000000000000022e200002ee222222222200022720000277222222222200000000000
|
||||
00000000000aa0000f0aa0f0000ff00000a00a000000000000000000000000000000000002ee22222222222227772e2002772222222222222777272000000000
|
||||
000aa0000000000000affa0000a00a000a0000a0a000000a000000000000000000000000022e22ee2222222227c122e20e2722772222222227c1227200000000
|
||||
00aaaa000a0ff0a00afaafa0af0000faa000000a000000000000000000000000000000002222227772222222227772e2222222eee222222222eee27200000000
|
||||
00aaaa000a0ff0a00afaafa0af0000faa000000a00000000000000000000000000000000222777777777722227777770222eeeeeeeeee2222eeeeee000000000
|
||||
000aa0000000000000affa0000a00a000a0000a0a000000a00000000000000000000000027770000777722e2777770002eee0000eeee2272eeeee00000000000
|
||||
00000000000aa0000f0aa0f0000ff00000a00a0000000000000000000000000000000000770000000002222e00000000ee000000000222270000000000000000
|
||||
000000000000000000000000a00aa00a000aa00000a00a00000000000000000000000000000000000222770000000000000000000222ee000000000000000000
|
||||
000000000000000000000000a00aa00a000aa00000a00a0000000001000000000000000022e200002ee222222222200022720000277222222222200000000000
|
||||
00000000000aa0000f0aa0f0000ff00000a00a000000000000010001000100010000100002ee22222222222227772e2002772222222222222777272000000000
|
||||
000aa0000000000000affa0000a00a000a0000a0a000000a011110110111101101111001022e22ee2222222227c122e20e2722772222222227c1227200000000
|
||||
00aaaa000a0ff0a00afaafa0af0000faa000000a000000001111111111111111111111112222227772222222227772e2222222eee222222222eee27200000000
|
||||
00aaaa000a0ff0a00afaafa0af0000faa000000a00000000111111111111111111111111222777777777722227777770222eeeeeeeeee2222eeeeee000000000
|
||||
000aa0000000000000affa0000a00a000a0000a0a000000a01111001011110110111101127770000777722e2777770002eee0000eeee2272eeeee00000000000
|
||||
00000000000aa0000f0aa0f0000ff00000a00a0000000000000010000001000100010001770000000002222e00000000ee000000000222270000000000000000
|
||||
000000000000000000000000a00aa00a000aa00000a00a00000000000000000000000001000000000222770000000000000000000222ee000000000000000000
|
||||
00000000000066000000000000000000000002200000000000000000000002200000000000000000000000000000000000000000000000000000000000000000
|
||||
0000000000022260000000000000000000222662000000000000000000222662000000000000000000000000000070220000000000220e220000000000000000
|
||||
00000000002222e000000000000000006227222e00000000000000002227222e0000000000000000000000000222026200000000022262220000000000000000
|
||||
|
Loading…
Reference in New Issue
Block a user