1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-23 01:59:43 +01:00

Put screen effects render handling inside a function

This de-duplicates the screen effects rendering code by putting it
inside a function, Graphics::renderwithscreeneffects(), and using that
instead of copy-pasted code.
This commit is contained in:
Misa 2020-04-26 19:24:50 -07:00 committed by Ethan Lee
parent 0e082551b1
commit 857937326e
5 changed files with 26 additions and 104 deletions

View file

@ -2667,6 +2667,23 @@ void Graphics::render()
} }
} }
void Graphics::renderwithscreeneffects()
{
if (game.flashlight > 0 && !game.noflashingmode)
{
graphics.flashlight();
}
if (game.screenshake > 0 && !game.noflashingmode)
{
graphics.screenshake();
}
else
{
graphics.render();
}
}
void Graphics::bigrprint(int x, int y, std::string& t, int r, int g, int b, bool cen, float sc) void Graphics::bigrprint(int x, int y, std::string& t, int r, int g, int b, bool cen, float sc)
{ {
if (r < 0) r = 0; if (r < 0) r = 0;

View file

@ -131,6 +131,7 @@ public:
void screenshake(); void screenshake();
void render(); void render();
void renderwithscreeneffects();
bool Hitest(SDL_Surface* surface1, point p1, SDL_Surface* surface2, point p2); bool Hitest(SDL_Surface* surface1, point p1, SDL_Surface* surface2, point p2);

View file

@ -1124,19 +1124,7 @@ void titlerender()
graphics.drawfade(); graphics.drawfade();
if (game.flashlight > 0 && !game.noflashingmode) graphics.renderwithscreeneffects();
{
graphics.flashlight();
}
if (game.screenshake > 0 && !game.noflashingmode)
{
graphics.screenshake();
}
else
{
graphics.render();
}
} }
void gamecompleterender() void gamecompleterender()
@ -1287,19 +1275,7 @@ void gamecompleterender()
graphics.drawfade(); graphics.drawfade();
if (game.flashlight > 0 && !game.noflashingmode) graphics.renderwithscreeneffects();
{
graphics.flashlight();
}
if (game.screenshake > 0 && !game.noflashingmode)
{
graphics.screenshake();
}
else
{
graphics.render();
}
} }
void gamecompleterender2() void gamecompleterender2()
@ -1329,19 +1305,7 @@ void gamecompleterender2()
graphics.drawfade(); graphics.drawfade();
if (game.flashlight > 0 && !game.noflashingmode) graphics.renderwithscreeneffects();
{
graphics.flashlight();
}
if (game.screenshake > 0 && !game.noflashingmode)
{
graphics.screenshake();
}
else
{
graphics.render();
}
} }
void gamerender() void gamerender()
@ -1697,19 +1661,7 @@ void gamerender()
} }
if (game.flashlight > 0 && !game.noflashingmode) graphics.renderwithscreeneffects();
{
graphics.flashlight();
}
if (game.screenshake > 0 && !game.noflashingmode)
{
graphics.screenshake();
}
else
{
graphics.render();
}
} }
void maprender() void maprender()
@ -2510,11 +2462,6 @@ void maprender()
graphics.drawfade(); graphics.drawfade();
if (game.flashlight > 0 && !game.noflashingmode)
{
graphics.flashlight();
}
if (graphics.resumegamemode) if (graphics.resumegamemode)
{ {
graphics.menuoffset += 25; graphics.menuoffset += 25;
@ -2548,14 +2495,7 @@ void maprender()
} }
else else
{ {
if (game.screenshake > 0 && !game.noflashingmode) graphics.renderwithscreeneffects();
{
graphics.screenshake();
}
else
{
graphics.render();
}
} }
} }
@ -2685,11 +2625,6 @@ void teleporterrender()
} }
if (game.flashlight > 0 && !game.noflashingmode)
{
graphics.flashlight();
}
if (graphics.resumegamemode) if (graphics.resumegamemode)
{ {
graphics.menuoffset += 25; graphics.menuoffset += 25;
@ -2723,13 +2658,6 @@ void teleporterrender()
} }
else else
{ {
if (game.screenshake > 0 && !game.noflashingmode) graphics.renderwithscreeneffects();
{
graphics.screenshake();
}
else
{
graphics.render();
}
} }
} }

View file

@ -3422,19 +3422,7 @@ void editorrender()
graphics.drawfade(); graphics.drawfade();
if (game.flashlight > 0 && !game.noflashingmode) graphics.renderwithscreeneffects();
{
graphics.flashlight();
}
if (game.screenshake > 0 && !game.noflashingmode)
{
graphics.screenshake();
}
else
{
graphics.render();
}
} }
void editorlogic() void editorlogic()

View file

@ -95,17 +95,5 @@ void preloaderrender()
graphics.drawfade(); graphics.drawfade();
if (game.flashlight > 0 && !game.noflashingmode) graphics.renderwithscreeneffects();
{
graphics.flashlight();
}
if (game.screenshake > 0 && !game.noflashingmode)
{
graphics.screenshake();
}
else
{
graphics.render();
}
} }