1
0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-06-24 13:38:29 +02:00

Add being able to toggle over/fixed-30-FPS, off by default

There is now an option in "graphic options" named "toggle fps", which
toggles whether the game visually runs at 1000/34 FPS or over 1000/34
FPS. It is off by default.

I've had to put the entire game loop in yet another set of braces, I'll
indent it next commit.
This commit is contained in:
Misa 2020-05-04 12:52:57 -07:00 committed by Ethan Lee
parent eaf9eec3dc
commit 7f526f3ef2
5 changed files with 57 additions and 0 deletions

View File

@ -387,6 +387,8 @@ void Game::init(void)
shouldreturntoeditor = false;
#endif
over30mode = false;
/* Terry's Patrons... */
const char* superpatrons_arr[] = {
"Anders Ekermo",
@ -4746,6 +4748,11 @@ void Game::loadstats()
skipfakeload = atoi(pText);
}
if (pKey == "over30mode")
{
over30mode = atoi(pText);
}
if (pKey == "notextoutline")
{
graphics.notextoutline = atoi(pText);
@ -4991,6 +4998,10 @@ void Game::savestats()
msg->LinkEndChild(doc.NewText(help.String((int)graphics.showmousecursor).c_str()));
dataNode->LinkEndChild(msg);
msg = doc.NewElement("over30mode");
msg->LinkEndChild(doc.NewText(help.String((int) over30mode).c_str()));
dataNode->LinkEndChild(msg);
for (size_t i = 0; i < controllerButton_flip.size(); i += 1)
{
msg = doc.NewElement("flipButton");
@ -7063,6 +7074,7 @@ void Game::createmenu( enum Menu::MenuName t, bool samemenu/*= false*/ )
option("toggle filter");
option("toggle analogue");
option("toggle mouse");
option("toggle fps");
option("return");
menuxoff = -50;
menuyoff = 8;

View File

@ -401,6 +401,8 @@ public:
{
return inintermission || insecretlab || intimetrial || nodeathmode;
}
bool over30mode;
};
extern Game game;

View File

@ -358,6 +358,12 @@ void menuactionpress()
graphics.showmousecursor = true;
}
break;
case 5:
//toggle 30+ fps
music.playef(11);
game.over30mode = !game.over30mode;
game.savestats();
break;
default:
//back
music.playef(11);

View File

@ -162,6 +162,20 @@ void menurender()
graphics.Print(-1, 85, "Current mode: HIDE", tr/2, tg/2, tb/2, true);
}
break;
case 5:
graphics.bigprint(-1, 30, "Toggle 30+ FPS", tr, tg, tb, true);
graphics.Print(-1, 65, "Change whether the game", tr, tg, tb, true);
graphics.Print(-1, 75, "runs at 30 or over 30 FPS.", tr, tg, tb, true);
if (!game.over30mode)
{
graphics.Print(-1, 95, "Current mode: 30 FPS", tr/2, tg/2, tb/2, true);
}
else
{
graphics.Print(-1, 95, "Current mode: Over 30 FPS", tr, tg, tb, true);
}
break;
}
break;
case Menu::credits:

View File

@ -306,12 +306,34 @@ int main(int argc, char *argv[])
volatile Uint32 time = 0;
volatile Uint32 timePrev = 0;
volatile Uint32 accumulator = 0;
volatile Uint32 f_time = 0;
volatile Uint32 f_timePrev = 0;
volatile Uint32 f_accumulator = 0;
game.infocus = true;
key.isActive = true;
game.gametimer = 0;
while(!key.quitProgram)
{
f_timePrev = f_time;
f_time = SDL_GetTicks();
const float f_rawdeltatime = static_cast<float>(f_time - f_timePrev);
if (!game.over30mode)
{
f_accumulator += f_rawdeltatime;
}
while ((game.over30mode || f_accumulator >= 34) && !key.quitProgram)
{
if (game.over30mode)
{
f_accumulator = 0;
}
else
{
f_accumulator = fmodf(f_accumulator, 34);
}
timePrev = time;
time = SDL_GetTicks();
@ -601,6 +623,7 @@ int main(int argc, char *argv[])
}
gameScreen.FlipScreen();
}
}
}
game.savestats();