Last active
March 24, 2021 14:22
-
-
Save smallfx/c46645b7279e7d64ec37 to your computer and use it in GitHub Desktop.
screen fade function for pico8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- "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