Compare commits

..

5 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
3 changed files with 237 additions and 4 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

@ -1396,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
@ -1441,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({
@ -1563,8 +1653,18 @@ mknew(arcade_level, function(x)
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()
@ -1574,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 {
@ -1645,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