Skip to content

Instantly share code, notes, and snippets.

@smallfx
Last active March 24, 2021 14:22
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save smallfx/c46645b7279e7d64ec37 to your computer and use it in GitHub Desktop.
screen fade function for pico8
-- "fa" is a number ranging from 0 to 1
-- 1 = 100% faded out
-- 0 = 0% faded out
-- 0.5 = 50% faded out, etc.
function fade_scr(fa)
fa=max(min(1,fa),0)
local fn=8
local pn=15
local fc=1/fn
local fi=flr(fa/fc)+1
local fades={
{1,1,1,1,0,0,0,0},
{2,2,2,1,1,0,0,0},
{3,3,4,5,2,1,1,0},
{4,4,2,2,1,1,1,0},
{5,5,2,2,1,1,1,0},
{6,6,13,5,2,1,1,0},
{7,7,6,13,5,2,1,0},
{8,8,9,4,5,2,1,0},
{9,9,4,5,2,1,1,0},
{10,15,9,4,5,2,1,0},
{11,11,3,4,5,2,1,0},
{12,12,13,5,5,2,1,0},
{13,13,5,5,2,1,1,0},
{14,9,9,4,5,2,1,0},
{15,14,9,4,5,2,1,0}
}
for n=1,pn do
pal(n,fades[n][fi],0)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment