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

De-duplicate screen effects timer decrementing

The code to decrement the timers for flashing and shaking is now handled
outside the game-gamestate case-switch, instead of having to be
duplicated inside each render function.

As a bonus, I made it so the timer decrements even if screen effects are
disabled. This is to prevent any theoretical situation where the timer
can "pile up" due to disabled screen effects not letting it tick down.
This commit is contained in:
Misa 2020-04-26 18:33:07 -07:00 committed by Ethan Lee
parent b26e94b919
commit 0e082551b1
4 changed files with 10 additions and 16 deletions

View file

@ -1126,13 +1126,11 @@ void titlerender()
if (game.flashlight > 0 && !game.noflashingmode) if (game.flashlight > 0 && !game.noflashingmode)
{ {
game.flashlight--;
graphics.flashlight(); graphics.flashlight();
} }
if (game.screenshake > 0 && !game.noflashingmode) if (game.screenshake > 0 && !game.noflashingmode)
{ {
game.screenshake--;
graphics.screenshake(); graphics.screenshake();
} }
else else
@ -1291,13 +1289,11 @@ void gamecompleterender()
if (game.flashlight > 0 && !game.noflashingmode) if (game.flashlight > 0 && !game.noflashingmode)
{ {
game.flashlight--;
graphics.flashlight(); graphics.flashlight();
} }
if (game.screenshake > 0 && !game.noflashingmode) if (game.screenshake > 0 && !game.noflashingmode)
{ {
game.screenshake--;
graphics.screenshake(); graphics.screenshake();
} }
else else
@ -1335,13 +1331,11 @@ void gamecompleterender2()
if (game.flashlight > 0 && !game.noflashingmode) if (game.flashlight > 0 && !game.noflashingmode)
{ {
game.flashlight--;
graphics.flashlight(); graphics.flashlight();
} }
if (game.screenshake > 0 && !game.noflashingmode) if (game.screenshake > 0 && !game.noflashingmode)
{ {
game.screenshake--;
graphics.screenshake(); graphics.screenshake();
} }
else else
@ -1705,13 +1699,11 @@ void gamerender()
if (game.flashlight > 0 && !game.noflashingmode) if (game.flashlight > 0 && !game.noflashingmode)
{ {
game.flashlight--;
graphics.flashlight(); graphics.flashlight();
} }
if (game.screenshake > 0 && !game.noflashingmode) if (game.screenshake > 0 && !game.noflashingmode)
{ {
game.screenshake--;
graphics.screenshake(); graphics.screenshake();
} }
else else
@ -2520,7 +2512,6 @@ void maprender()
if (game.flashlight > 0 && !game.noflashingmode) if (game.flashlight > 0 && !game.noflashingmode)
{ {
game.flashlight--;
graphics.flashlight(); graphics.flashlight();
} }
@ -2559,7 +2550,6 @@ void maprender()
{ {
if (game.screenshake > 0 && !game.noflashingmode) if (game.screenshake > 0 && !game.noflashingmode)
{ {
game.screenshake--;
graphics.screenshake(); graphics.screenshake();
} }
else else
@ -2697,7 +2687,6 @@ void teleporterrender()
if (game.flashlight > 0 && !game.noflashingmode) if (game.flashlight > 0 && !game.noflashingmode)
{ {
game.flashlight--;
graphics.flashlight(); graphics.flashlight();
} }
@ -2736,7 +2725,6 @@ void teleporterrender()
{ {
if (game.screenshake > 0 && !game.noflashingmode) if (game.screenshake > 0 && !game.noflashingmode)
{ {
game.screenshake--;
graphics.screenshake(); graphics.screenshake();
} }
else else

View file

@ -3424,13 +3424,11 @@ void editorrender()
if (game.flashlight > 0 && !game.noflashingmode) if (game.flashlight > 0 && !game.noflashingmode)
{ {
game.flashlight--;
graphics.flashlight(); graphics.flashlight();
} }
if (game.screenshake > 0 && !game.noflashingmode) if (game.screenshake > 0 && !game.noflashingmode)
{ {
game.screenshake--;
graphics.screenshake(); graphics.screenshake();
} }
else else

View file

@ -479,6 +479,16 @@ int main(int argc, char *argv[])
} }
//Screen effects timers
if (game.infocus && game.flashlight > 0)
{
game.flashlight--;
}
if (game.infocus && game.screenshake > 0)
{
game.screenshake--;
}
//We did editorinput, now it's safe to turn this off //We did editorinput, now it's safe to turn this off
key.linealreadyemptykludge = false; key.linealreadyemptykludge = false;

View file

@ -97,13 +97,11 @@ void preloaderrender()
if (game.flashlight > 0 && !game.noflashingmode) if (game.flashlight > 0 && !game.noflashingmode)
{ {
game.flashlight--;
graphics.flashlight(); graphics.flashlight();
} }
if (game.screenshake > 0 && !game.noflashingmode) if (game.screenshake > 0 && !game.noflashingmode)
{ {
game.screenshake--;
graphics.screenshake(); graphics.screenshake();
} }
else else