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

Move render functions to outer deltatime loop

Ok, and this is where the fun starts.

In an ideal world, this would be the end of this patch. However, of
course, there are many, MANY places in the game that update
fixed-timestep timers DIRECTLY inside the render function, which is not
ideal because it means those timers go super fast.

I'll have to fix those later.
This commit is contained in:
Misa 2020-04-28 15:02:37 -07:00 committed by Ethan Lee
parent c63036fcd3
commit fd44098f38

View file

@ -314,6 +314,8 @@ int main(int argc, char *argv[])
timePrev = time; timePrev = time;
time = SDL_GetTicks(); time = SDL_GetTicks();
game.infocus = key.isActive;
// Update network per frame. // Update network per frame.
NETWORK_update(); NETWORK_update();
@ -365,7 +367,6 @@ int main(int argc, char *argv[])
game.press_map = false; game.press_map = false;
} }
game.infocus = key.isActive;
if(!game.infocus) if(!game.infocus)
{ {
Mix_Pause(-1); Mix_Pause(-1);
@ -380,6 +381,7 @@ int main(int argc, char *argv[])
graphics.bprint(5, 230, "Press N to mute music only", 164 - help.glow, 196 - help.glow, 164 - help.glow, true); graphics.bprint(5, 230, "Press N to mute music only", 164 - help.glow, 196 - help.glow, 164 - help.glow, true);
} }
graphics.render(); graphics.render();
gameScreen.FlipScreen();
//We are minimised, so lets put a bit of a delay to save CPU //We are minimised, so lets put a bit of a delay to save CPU
SDL_Delay(100); SDL_Delay(100);
} }
@ -391,16 +393,12 @@ int main(int argc, char *argv[])
switch(game.gamestate) switch(game.gamestate)
{ {
case PRELOADER: case PRELOADER:
//Render
preloaderrender();
break; break;
#if !defined(NO_CUSTOM_LEVELS) #if !defined(NO_CUSTOM_LEVELS)
case EDITORMODE: case EDITORMODE:
graphics.flipmode = false; graphics.flipmode = false;
//Input //Input
editorinput(); editorinput();
//Render
editorrender();
////Logic ////Logic
editorlogic(); editorlogic();
break; break;
@ -408,8 +406,6 @@ int main(int argc, char *argv[])
case TITLEMODE: case TITLEMODE:
//Input //Input
titleinput(); titleinput();
//Render
titlerender();
////Logic ////Logic
titlelogic(); titlelogic();
break; break;
@ -420,18 +416,15 @@ int main(int argc, char *argv[])
} }
gameinput(); gameinput();
gamerender();
gamelogic(); gamelogic();
break; break;
case MAPMODE: case MAPMODE:
maprender();
mapinput(); mapinput();
maplogic(); maplogic();
break; break;
case TELEPORTERMODE: case TELEPORTERMODE:
teleporterrender();
if(game.useteleporter) if(game.useteleporter)
{ {
teleporterinput(); teleporterinput();
@ -447,21 +440,18 @@ int main(int argc, char *argv[])
maplogic(); maplogic();
break; break;
case GAMECOMPLETE: case GAMECOMPLETE:
gamecompleterender();
//Input //Input
gamecompleteinput(); gamecompleteinput();
//Logic //Logic
gamecompletelogic(); gamecompletelogic();
break; break;
case GAMECOMPLETE2: case GAMECOMPLETE2:
gamecompleterender2();
//Input //Input
gamecompleteinput2(); gamecompleteinput2();
//Logic //Logic
gamecompletelogic2(); gamecompletelogic2();
break; break;
case CLICKTOSTART: case CLICKTOSTART:
help.updateglow();
break; break;
default: default:
@ -551,10 +541,44 @@ int main(int argc, char *argv[])
music.processmusic(); music.processmusic();
graphics.processfade(); graphics.processfade();
game.gameclock(); game.gameclock();
}
const float alpha = static_cast<float>(accumulator) / timesteplimit;
if (game.infocus)
{
switch (game.gamestate)
{
case PRELOADER:
preloaderrender();
break;
case EDITORMODE:
graphics.flipmode = false;
editorrender();
break;
case TITLEMODE:
titlerender();
break;
case GAMEMODE:
gamerender();
break;
case MAPMODE:
maprender();
break;
case TELEPORTERMODE:
teleporterrender();
break;
case GAMECOMPLETE:
gamecompleterender();
break;
case GAMECOMPLETE2:
gamecompleterender2();
break;
case CLICKTOSTART:
help.updateglow();
break;
}
gameScreen.FlipScreen(); gameScreen.FlipScreen();
} }
const float deltatime = rawdeltatime/1000.0f * 34.0f / timesteplimit;
const float alpha = static_cast<float>(accumulator) / timesteplimit;
} }
game.savestats(); game.savestats();