10 Commits

Author SHA1 Message Date
23df0bbe23 visual tweaks 2024-02-29 22:20:55 -08:00
d48b81f371 second cloud layer. correct lighting angle.
there are entrance or exit artifacts; this set of values seems to give acceptable levels of entrance artifacts
2024-02-29 22:18:18 -08:00
ad05ea4bde minor optimization and consistent light source 2024-02-29 22:04:14 -08:00
b421df9174 cloud prototype in-game 2024-02-29 22:00:32 -08:00
dd34ad0a37 by Pyrex: cloud animation prototype 2024-02-29 21:19:26 -08:00
9a865e418f fix fish direction and placement 2024-02-29 20:40:14 -08:00
4a086be607 fish sprites, bg fix 2024-02-29 20:32:05 -08:00
09a09b646a prototype fish drawer (fish not implemented) 2024-02-29 20:26:51 -08:00
0574fe4021 whitespace 2024-02-29 19:59:16 -08:00
79d6321891 sprite renderer and parallax drifting thing renderer 2024-02-29 19:58:39 -08:00
3 changed files with 341 additions and 12 deletions

124
clouds3.p8 Normal file
View File

@ -0,0 +1,124 @@
pico-8 cartridge // http://www.pico-8.com
version 42
__lua__
function _init()
cmgr0=cloud_manager:new(15,51,5,1,5,13)
cmgr1=cloud_manager:new(12,51-8,7,4,13,6)
cmgr2=cloud_manager:new(6,51-14,9,3,15,7)
cmgr0.step=5
cmgr1.step=4
cmgr2.step=3
last_x=0
x=0
dx=0
end
function _update60()
if (btn(4)) dx+=1.0
dx*=0.75
x+=dx
while last_x<x do
cmgr0:update()
cmgr1:update()
cmgr2:update()
last_x+=1
end
end
function _draw()
cls(12)
cmgr0:draw()
cmgr1:draw()
cmgr2:draw()
end
cloud_manager={}
function cloud_manager:new(sparseness,y,h,oval_h,c0,c1)
local c={
frame=0,
clouds={},
bitplanes=split"241,242,244,248",
step=1,
sparseness=sparseness,
y=y,
c0=c0,
c1=c1,
h=h,
oval_h=oval_h
}
setmetatable(c,{__index=cloud_manager})
return c
end
function cloud_manager:update()
self.frame+=1
if self.frame%(self.step*self.sparseness) == 0 then
local bp=deli(self.bitplanes,1)
add(self.clouds,{x=127,y=rnd()*self.h,w=flr(rnd()*16)+16,plane=bp})
add(self.bitplanes,bp)
end
if self.frame%self.step==0 then
local clouds2={}
for c in all(self.clouds) do
c.x-=1
if (c.x+c.w>0) add(clouds2,c)
end
self.clouds=clouds2
end
end
function cloud_manager:draw()
local r0=96
local r1=96+16
local h=self.h+self.oval_h+1
assert(h<=16)
-- render to spritesheet
poke(0x5f55,0x00)
rectfill(0,r0,127,r0+h,0)
-- use bitplanes
for c in all(self.clouds) do
poke(0x5f5e,c.plane)
ovalfill(c.x,r0+c.y,c.x+c.w,r0+c.y+self.oval_h,15)
end
poke(0x5f5e,255)
-- render from high memory
-- to higher memory
rectfill(0,r1,127,r1+h,0)
for i in all(split"0,1,2,4,8") do
palt(i,true)
end
for i=0,15 do
pal(i,7)
end
poke(0x5f5e,0xf1)
sspr(0,r0,128,h,0,r1)
poke(0x5f5e,0xf2)
sspr(0,r0,128,h,1,r1+1)
sspr(0,r0,128,h,5,r1+1)
poke(0x5f5e,255)
-- render to screen
poke(0x5f55,0x60)
pal()
pal(1,self.c1)
pal(2,self.c0)
pal(3,self.c1)
sspr(0,r1,128,h,0,self.y)
pal()
end
__gfx__
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

View File

@ -9,11 +9,16 @@ Arcade Mode palette notes:
-- 4 (underwater) is a deeper blue shade part of sea
-- 6: dolphin specular highlights
-- 7: dolphin white paint
-- 8, 9: unassigned, layer specific
-- 8, 9: layer specific
-- sky:
-- 8: bright cloud shadows (15)
-- 9: light gray for clouds (6? 13? 134?)
-- 10: word primary (yellow 10?)
-- 11: word shadow (wood 132?)
-- 12: dolphin eye
-- 13: common sky color
-- 13: common sky color
-- this is a reassignment candidate but means I will never do
-- the "sunset palette cycle" thing
-- 14: dolphin primary color
-- 15: highlight white (all layers)
--

View File

@ -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
@ -1390,6 +1396,96 @@ function toyphin:draw()
spr(st.s[1+(((t()<<1)&0x0.ffff*#st.s)&0x7fff)], self.x + st.xo, y + st.yo, self.state.ws, self.state.hs)
end
-->8
-- pyrex's cloud renderer
cld_bpl={241,242,244,248}
wpal={[0]=7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7}
cmgr={
f=0,
df=1,
bpi=1, -- TODO: bitplane index -- different algorithm
sprs=10,
step=3,
y=10,
h=10,
oval_h=5,
c0 = 8, -- shadow
c1 = 7, -- primary
}
mknew(cmgr, function(self)
self.clouds = {}
--todo: nonempty spawn
end)
function cmgr:u()
self.f+=self.df
if self.f%(self.step*self.sprs) == 0 then
self.f=0
local bp=cld_bpl[self.bpi]
self.bpi += 1
if (self.bpi > #cld_bpl) self.bpi = 1
add(self.clouds,{x=127,y=rnd()*self.h,w=flr(rnd()*16)+16,plane=bp})
end
if self.f%self.step==0 then
local clouds2={}
for c in all(self.clouds) do
c.x-=1
if (c.x+c.w>-6) add(clouds2,c)
end
self.clouds=clouds2
end
end
function cmgr:draw()
--back up pal01
memcpy(0x8010,0x5f00,32)
--back up pal2
memcpy(0x8000,0x5f60,16)
fillp(0)
local h=self.h+self.oval_h+1
assert(h<=16)
-- render to spritesheet
poke(0x5f55,0x00)
rectfill(0,96,127,96+h,0)
-- use bitplanes
for c in all(self.clouds) do
poke(0x5f5e,c.plane)
ovalfill(c.x,96+c.y,c.x+c.w,96+c.y+self.oval_h,15)
end
poke(0x5f5e,255)
-- render from high memory
-- to higher memory
rectfill(0,112,127,112+h,0)
palt(0b1110100010000000)
pal(wpal)
poke(0x5f5e,0xf1)
sspr(0,96,128,h,0,112)
poke(0x5f5e,0xf2)
sspr(0,96,128,h,-1,113)
sspr(0,96,128,h,-3,113)
poke(0x5f5e,255)
-- render to screen
poke(0x5f55,0x60)
pal()
pal(1,self.c1)
pal(2,self.c0)
pal(3,self.c1)
sspr(0,112,128,h,0,self.y)
-- restore former palettes
memcpy(0x5f00,0x8010,32)
memcpy(0x5f60,0x8000,16)
end
-->8
-- arcade mode
@ -1435,7 +1531,7 @@ function setup_arcade_pal()
pal()
--game_nrm_pal
pal({
[0] = 1, 0, 2, 140, 4, 5, 7, 7, 8, 9, 10, 132, 12, 12, 14, 7
[0] = 1, 0, 2, 140, 4, 5, 7, 7, 15, 6, 10, 132, 12, 134, 14, 7
}, 1)
--game_uw_pal
pal({
@ -1485,17 +1581,90 @@ 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{
splasher=x,
xtarget=x.phin_x,
}
x.sky = bg.new{c=13}
x.sky = bg.new{c=12}
x.sea = sea.new()
x.cld0 = cmgr.new{
y=18,
h=9,
oval_h=4,
sprs=12,
step=4,
c0=13,
c1=9,
}
x.cld1 = cmgr.new{}
x.bg = event_list.new()
x.fg = event_list.new()
x.words = event_list.new()
@ -1505,6 +1674,8 @@ mknew(arcade_level, function(x)
x.v = view.of{
x.sky,
x.cld0,
x.cld1,
x.sea,
x.waves,
x.noscore and blank or {
@ -1532,9 +1703,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
@ -1550,6 +1747,8 @@ function arcade_level:u()
end
if self.wordremain <= 0 and self.words.next == nil then
self.phin.exiting = true
self.cld1.df = 0.125
self.cld0.df = 0.125
end
if self.phin.x > 90 then
if not self.mstp then
@ -1558,6 +1757,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 +2703,14 @@ __gfx__
0000000070000000000000000000000700000000000000000000000070000222222000070000000000222e000000000000000000002227000000000000000000
000000007000000000000000000000070000000000000000000000007000000000000007000000000002222e0000000000000000000222270000000000000000
000000007777777777777777777777770000000000000000000000007777777777777777022000000022e222ee20000002200000002272227720000000000000
000000000000000000000000a00aa00a000aa00000a00a0000000000000000000000000022e200002ee222222222200022720000277222222222200000000000
00000000000aa0000f0aa0f0000ff00000a00a000000000000000000000000000000000002ee22222222222227772e2002772222222222222777272000000000
000aa0000000000000affa0000a00a000a0000a0a000000a000000000000000000000000022e22ee2222222227c122e20e2722772222222227c1227200000000
00aaaa000a0ff0a00afaafa0af0000faa000000a000000000000000000000000000000002222227772222222227772e2222222eee222222222eee27200000000
00aaaa000a0ff0a00afaafa0af0000faa000000a00000000000000000000000000000000222777777777722227777770222eeeeeeeeee2222eeeeee000000000
000aa0000000000000affa0000a00a000a0000a0a000000a00000000000000000000000027770000777722e2777770002eee0000eeee2272eeeee00000000000
00000000000aa0000f0aa0f0000ff00000a00a0000000000000000000000000000000000770000000002222e00000000ee000000000222270000000000000000
000000000000000000000000a00aa00a000aa00000a00a00000000000000000000000000000000000222770000000000000000000222ee000000000000000000
000000000000000000000000a00aa00a000aa00000a00a0000000001000000000000000022e200002ee222222222200022720000277222222222200000000000
00000000000aa0000f0aa0f0000ff00000a00a000000000000010001000100010000100002ee22222222222227772e2002772222222222222777272000000000
000aa0000000000000affa0000a00a000a0000a0a000000a011110110111101101111001022e22ee2222222227c122e20e2722772222222227c1227200000000
00aaaa000a0ff0a00afaafa0af0000faa000000a000000001111111111111111111111112222227772222222227772e2222222eee222222222eee27200000000
00aaaa000a0ff0a00afaafa0af0000faa000000a00000000111111111111111111111111222777777777722227777770222eeeeeeeeee2222eeeeee000000000
000aa0000000000000affa0000a00a000a0000a0a000000a01111001011110110111101127770000777722e2777770002eee0000eeee2272eeeee00000000000
00000000000aa0000f0aa0f0000ff00000a00a0000000000000010000001000100010001770000000002222e00000000ee000000000222270000000000000000
000000000000000000000000a00aa00a000aa00000a00a00000000000000000000000001000000000222770000000000000000000222ee000000000000000000
00000000000066000000000000000000000002200000000000000000000002200000000000000000000000000000000000000000000000000000000000000000
0000000000022260000000000000000000222662000000000000000000222662000000000000000000000000000070220000000000220e220000000000000000
00000000002222e000000000000000006227222e00000000000000002227222e0000000000000000000000000222026200000000022262220000000000000000