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:
parent
c63036fcd3
commit
fd44098f38
1 changed files with 39 additions and 15 deletions
|
@ -314,6 +314,8 @@ int main(int argc, char *argv[])
|
|||
timePrev = time;
|
||||
time = SDL_GetTicks();
|
||||
|
||||
game.infocus = key.isActive;
|
||||
|
||||
// Update network per frame.
|
||||
NETWORK_update();
|
||||
|
||||
|
@ -365,7 +367,6 @@ int main(int argc, char *argv[])
|
|||
game.press_map = false;
|
||||
}
|
||||
|
||||
game.infocus = key.isActive;
|
||||
if(!game.infocus)
|
||||
{
|
||||
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.render();
|
||||
gameScreen.FlipScreen();
|
||||
//We are minimised, so lets put a bit of a delay to save CPU
|
||||
SDL_Delay(100);
|
||||
}
|
||||
|
@ -391,16 +393,12 @@ int main(int argc, char *argv[])
|
|||
switch(game.gamestate)
|
||||
{
|
||||
case PRELOADER:
|
||||
//Render
|
||||
preloaderrender();
|
||||
break;
|
||||
#if !defined(NO_CUSTOM_LEVELS)
|
||||
case EDITORMODE:
|
||||
graphics.flipmode = false;
|
||||
//Input
|
||||
editorinput();
|
||||
//Render
|
||||
editorrender();
|
||||
////Logic
|
||||
editorlogic();
|
||||
break;
|
||||
|
@ -408,8 +406,6 @@ int main(int argc, char *argv[])
|
|||
case TITLEMODE:
|
||||
//Input
|
||||
titleinput();
|
||||
//Render
|
||||
titlerender();
|
||||
////Logic
|
||||
titlelogic();
|
||||
break;
|
||||
|
@ -420,18 +416,15 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
gameinput();
|
||||
gamerender();
|
||||
gamelogic();
|
||||
|
||||
|
||||
break;
|
||||
case MAPMODE:
|
||||
maprender();
|
||||
mapinput();
|
||||
maplogic();
|
||||
break;
|
||||
case TELEPORTERMODE:
|
||||
teleporterrender();
|
||||
if(game.useteleporter)
|
||||
{
|
||||
teleporterinput();
|
||||
|
@ -447,21 +440,18 @@ int main(int argc, char *argv[])
|
|||
maplogic();
|
||||
break;
|
||||
case GAMECOMPLETE:
|
||||
gamecompleterender();
|
||||
//Input
|
||||
gamecompleteinput();
|
||||
//Logic
|
||||
gamecompletelogic();
|
||||
break;
|
||||
case GAMECOMPLETE2:
|
||||
gamecompleterender2();
|
||||
//Input
|
||||
gamecompleteinput2();
|
||||
//Logic
|
||||
gamecompletelogic2();
|
||||
break;
|
||||
case CLICKTOSTART:
|
||||
help.updateglow();
|
||||
break;
|
||||
default:
|
||||
|
||||
|
@ -551,10 +541,44 @@ int main(int argc, char *argv[])
|
|||
music.processmusic();
|
||||
graphics.processfade();
|
||||
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();
|
||||
}
|
||||
const float deltatime = rawdeltatime/1000.0f * 34.0f / timesteplimit;
|
||||
const float alpha = static_cast<float>(accumulator) / timesteplimit;
|
||||
}
|
||||
|
||||
game.savestats();
|
||||
|
|
Loading…
Reference in a new issue