mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-11-13 22:49:42 +01:00
Factor timestep calculation out to Game function
This is so we can grab the game's timestep anywhere else in the codebase without copy-pasting it.
This commit is contained in:
parent
f8f6f3b96e
commit
f6ea05f521
3 changed files with 32 additions and 30 deletions
|
@ -6742,3 +6742,33 @@ void Game::copyndmresults(void)
|
|||
ndmresulthardestroom = hardestroom;
|
||||
SDL_memcpy(ndmresultcrewstats, crewstats, sizeof(ndmresultcrewstats));
|
||||
}
|
||||
|
||||
static inline int get_framerate(const int slowdown)
|
||||
{
|
||||
switch (slowdown)
|
||||
{
|
||||
case 30:
|
||||
return 34;
|
||||
case 24:
|
||||
return 41;
|
||||
case 18:
|
||||
return 55;
|
||||
case 12:
|
||||
return 83;
|
||||
}
|
||||
|
||||
return 34;
|
||||
}
|
||||
|
||||
int Game::get_timestep(void)
|
||||
{
|
||||
switch (gamestate)
|
||||
{
|
||||
case EDITORMODE:
|
||||
return 24;
|
||||
case GAMEMODE:
|
||||
return get_framerate(slowdown);
|
||||
default:
|
||||
return 34;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -292,6 +292,7 @@ public:
|
|||
bool colourblindmode;
|
||||
bool noflashingmode;
|
||||
int slowdown;
|
||||
int get_timestep(void);
|
||||
|
||||
bool nodeathmode;
|
||||
int gameoverdelay;
|
||||
|
|
|
@ -57,23 +57,6 @@ static volatile Uint32 accumulator = 0;
|
|||
static volatile Uint32 f_time = 0;
|
||||
static volatile Uint32 f_timePrev = 0;
|
||||
|
||||
static inline Uint32 get_framerate(const int slowdown)
|
||||
{
|
||||
switch (slowdown)
|
||||
{
|
||||
case 30:
|
||||
return 34;
|
||||
case 24:
|
||||
return 41;
|
||||
case 18:
|
||||
return 55;
|
||||
case 12:
|
||||
return 83;
|
||||
}
|
||||
|
||||
return 34;
|
||||
}
|
||||
|
||||
enum FuncType
|
||||
{
|
||||
Func_null,
|
||||
|
@ -665,19 +648,7 @@ static void inline deltaloop(void)
|
|||
const float rawdeltatime = static_cast<float>(time_ - timePrev);
|
||||
accumulator += rawdeltatime;
|
||||
|
||||
Uint32 timesteplimit;
|
||||
if (game.gamestate == EDITORMODE)
|
||||
{
|
||||
timesteplimit = 24;
|
||||
}
|
||||
else if (game.gamestate == GAMEMODE)
|
||||
{
|
||||
timesteplimit = get_framerate(game.slowdown);
|
||||
}
|
||||
else
|
||||
{
|
||||
timesteplimit = 34;
|
||||
}
|
||||
Uint32 timesteplimit = game.get_timestep();
|
||||
|
||||
while (accumulator >= timesteplimit)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue