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

View file

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

View file

@ -358,6 +358,12 @@ void menuactionpress()
graphics.showmousecursor = true; graphics.showmousecursor = true;
} }
break; break;
case 5:
//toggle 30+ fps
music.playef(11);
game.over30mode = !game.over30mode;
game.savestats();
break;
default: default:
//back //back
music.playef(11); 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); graphics.Print(-1, 85, "Current mode: HIDE", tr/2, tg/2, tb/2, true);
} }
break; 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; break;
case Menu::credits: case Menu::credits:

View file

@ -306,12 +306,34 @@ int main(int argc, char *argv[])
volatile Uint32 time = 0; volatile Uint32 time = 0;
volatile Uint32 timePrev = 0; volatile Uint32 timePrev = 0;
volatile Uint32 accumulator = 0; volatile Uint32 accumulator = 0;
volatile Uint32 f_time = 0;
volatile Uint32 f_timePrev = 0;
volatile Uint32 f_accumulator = 0;
game.infocus = true; game.infocus = true;
key.isActive = true; key.isActive = true;
game.gametimer = 0; game.gametimer = 0;
while(!key.quitProgram) 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; timePrev = time;
time = SDL_GetTicks(); time = SDL_GetTicks();
@ -602,6 +624,7 @@ int main(int argc, char *argv[])
gameScreen.FlipScreen(); gameScreen.FlipScreen();
} }
} }
}
game.savestats(); game.savestats();
NETWORK_shutdown(); NETWORK_shutdown();