1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-23 18:19:43 +01:00

Interpolate fade amount

This makes the fadeouts and fadeins (screenwipes) much more buttery
smooth.
This commit is contained in:
Misa 2020-04-28 18:10:40 -07:00 committed by Ethan Lee
parent 8fde6f28a3
commit e897543383
2 changed files with 6 additions and 2 deletions

View file

@ -90,6 +90,7 @@ void Graphics::init()
fadebars.resize(15); fadebars.resize(15);
fadeamount = 0; fadeamount = 0;
oldfadeamount = 0;
fademode = 0; fademode = 0;
// initialize everything else to zero // initialize everything else to zero
@ -1074,6 +1075,7 @@ void Graphics::createtextbox( std::string t, int xp, int yp, int r/*= 255*/, int
void Graphics::drawfade() void Graphics::drawfade()
{ {
int usethisamount = lerp(oldfadeamount, fadeamount);
if ((fademode == 1)||(fademode == 4)) if ((fademode == 1)||(fademode == 4))
{ {
FillRect(backBuffer, 0, 0, backBuffer->w, backBuffer->h, 0x000000); FillRect(backBuffer, 0, 0, backBuffer->w, backBuffer->h, 0x000000);
@ -1082,14 +1084,14 @@ void Graphics::drawfade()
{ {
for (int i = 0; i < 15; i++) for (int i = 0; i < 15; i++)
{ {
FillRect(backBuffer, fadebars[i], i * 16, fadeamount, 16, 0x000000 ); FillRect(backBuffer, fadebars[i], i * 16, usethisamount, 16, 0x000000 );
} }
} }
else if(fademode==5 ) else if(fademode==5 )
{ {
for (int i = 0; i < 15; i++) for (int i = 0; i < 15; i++)
{ {
FillRect(backBuffer, fadebars[i]-fadeamount, i * 16, 500, 16, 0x000000 ); FillRect(backBuffer, fadebars[i]-usethisamount, i * 16, 500, 16, 0x000000 );
} }
} }
@ -1097,6 +1099,7 @@ void Graphics::drawfade()
void Graphics::processfade() void Graphics::processfade()
{ {
oldfadeamount = fadeamount;
if (fademode > 1) if (fademode > 1)
{ {
if (fademode == 2) if (fademode == 2)

View file

@ -264,6 +264,7 @@ public:
int fademode; int fademode;
int fadeamount; int fadeamount;
int oldfadeamount;
std::vector <int> fadebars; std::vector <int> fadebars;
bool trinketcolset; bool trinketcolset;