diff --git a/desktop_version/src/Entity.cpp b/desktop_version/src/Entity.cpp index 43b9d902..32d21731 100644 --- a/desktop_version/src/Entity.cpp +++ b/desktop_version/src/Entity.cpp @@ -1762,7 +1762,7 @@ void entityclass::createentity(int xp, int yp, int t, int meta1, int meta2, int entity.colour = 21; entity.tile = 78; //default case entity.animate = 1; - if (game.swngame == 1) + if (game.swngame == SWN_SUPERGRAVITRON) { //set colour based on current state entity.colour = swncolour(game.swncolstate); diff --git a/desktop_version/src/Game.cpp b/desktop_version/src/Game.cpp index 2c68c8d6..1181f69f 100644 --- a/desktop_version/src/Game.cpp +++ b/desktop_version/src/Game.cpp @@ -316,7 +316,7 @@ void Game::init(void) inertia = 1.1f; swnmode = false; swntimer = 0; - swngame = 0;//Not playing sine wave ninja! + swngame = SWN_NONE; // Not playing sine wave ninja! swnstate = 0; swnstate2 = 0; swnstate3 = 0; @@ -943,7 +943,7 @@ void Game::updatestate(void) obj.removetrigger(9); swnmode = true; - swngame = 6; + swngame = SWN_START_SUPERGRAVITRON_STEP_1; swndelay = 150; swntimer = 60 * 30; @@ -964,7 +964,7 @@ void Game::updatestate(void) obj.removetrigger(10); swnmode = true; - swngame = 4; + swngame = SWN_START_GRAVITRON_STEP_1; swndelay = 150; swntimer = 60 * 30; @@ -7479,7 +7479,9 @@ bool Game::incompetitive(void) return ( !map.custommode && swnmode - && (swngame == 1 || swngame == 6 || swngame == 7) + && (swngame == SWN_SUPERGRAVITRON || + swngame == SWN_START_SUPERGRAVITRON_STEP_1 || + swngame == SWN_START_SUPERGRAVITRON_STEP_2) ) || intimetrial || nodeathmode; diff --git a/desktop_version/src/Game.h b/desktop_version/src/Game.h index 774dd76d..4c10e692 100644 --- a/desktop_version/src/Game.h +++ b/desktop_version/src/Game.h @@ -117,6 +117,21 @@ enum SLIDERMODE SLIDER_SOUNDVOLUME }; +/* enums for swngame variable */ +enum SWNMODE +{ + SWN_GRAVITRON, + SWN_SUPERGRAVITRON, + SWN_START_GRAVITRON_STEP_3, + SWN_START_GRAVITRON_STEP_2, + SWN_START_GRAVITRON_STEP_1, + SWN_FINISH_GRAVITRON_STEP_1, + SWN_START_SUPERGRAVITRON_STEP_1, + SWN_START_SUPERGRAVITRON_STEP_2, + SWN_FINISH_GRAVITRON_STEP_2, + SWN_NONE +}; + struct MenuStackFrame { int option; @@ -334,7 +349,8 @@ public: //Sine Wave Ninja Minigame bool swnmode; - int swngame, swnstate, swnstate2, swnstate3, swnstate4, swndelay, swndeaths; + enum SWNMODE swngame; + int swnstate, swnstate2, swnstate3, swnstate4, swndelay, swndeaths; int swntimer, swncolstate, swncoldelay; int swnrecord, swnbestrank, swnrank, swnmessage; diff --git a/desktop_version/src/Graphics.cpp b/desktop_version/src/Graphics.cpp index bc8fdbaa..14e9f4bf 100644 --- a/desktop_version/src/Graphics.cpp +++ b/desktop_version/src/Graphics.cpp @@ -2009,7 +2009,8 @@ void Graphics::drawentity(const int i, const int yoff) case 5: //Horizontal Line { int oldw = obj.entities[i].w; - if ((game.swngame == 3 || kludgeswnlinewidth) && obj.getlineat(84 - 32) == i) + if ((game.swngame == SWN_START_GRAVITRON_STEP_2 || kludgeswnlinewidth) + && obj.getlineat(84 - 32) == i) { oldw -= 24; } diff --git a/desktop_version/src/Input.cpp b/desktop_version/src/Input.cpp index 25172a32..89b973b8 100644 --- a/desktop_version/src/Input.cpp +++ b/desktop_version/src/Input.cpp @@ -2763,7 +2763,9 @@ void gameinput(void) // Do nothing } else if (game.swnmode == 1 - && (game.swngame == 1 || game.swngame == 6 || game.swngame == 7)) + && (game.swngame == SWN_SUPERGRAVITRON || + game.swngame == SWN_START_SUPERGRAVITRON_STEP_1 || + game.swngame == SWN_START_SUPERGRAVITRON_STEP_2)) { //quitting the super gravitron game.mapheld = true; diff --git a/desktop_version/src/Logic.cpp b/desktop_version/src/Logic.cpp index 1d1af26c..5fa3609e 100644 --- a/desktop_version/src/Logic.cpp +++ b/desktop_version/src/Logic.cpp @@ -429,11 +429,11 @@ void gamelogic(void) if (game.swnmode) { //if playing SWN game a, push the clock back to the nearest 10 second interval - if (game.swngame == 0) + if (game.swngame == SWN_GRAVITRON) { game.swnpenalty(); } - else if (game.swngame == 1) + else if (game.swngame == SWN_SUPERGRAVITRON) { game.swnstate = 0; game.swnstate2 = 0; @@ -481,7 +481,7 @@ void gamelogic(void) if (game.swnmode) { //if playing SWN game b, reset the clock - if (game.swngame == 1) + if (game.swngame == SWN_SUPERGRAVITRON) { game.swntimer = 0; game.swnmessage = 0; @@ -557,21 +557,21 @@ void gamelogic(void) //SWN Minigame Logic if (game.swnmode) //which game? { - if(game.swngame==0) //intermission, survive 60 seconds game + switch (game.swngame) { + case SWN_GRAVITRON: // intermission, survive 60 seconds game game.swntimer -= 1; if (game.swntimer <= 0) { music.niceplay(Music_PREDESTINEDFATE); - game.swngame = 5; + game.swngame = SWN_FINISH_GRAVITRON_STEP_1; } else { obj.generateswnwave(0); } - } - else if(game.swngame==1) //super gravitron game - { + break; + case SWN_SUPERGRAVITRON: game.swntimer += 1; #ifndef MAKEANDPLAY if (!map.custommode) @@ -660,19 +660,18 @@ void gamelogic(void) graphics.rcol = game.swncolstate; obj.swnenemiescol(game.swncolstate); } - } - else if (game.swngame == 2) //introduce game a - { + break; + case SWN_START_GRAVITRON_STEP_3: //introduce game a game.swndelay--; if (game.swndelay <= 0) { - game.swngame = 0; + game.swngame = SWN_GRAVITRON; game.swndelay = 0; game.swntimer = (60 * 30) - 1; //game.swntimer = 15; } - } - else if (game.swngame == 3) //extend line + break; + case SWN_START_GRAVITRON_STEP_2: //extend line { int line = obj.getlineat(84 - 32); if (INBOUNDS_VEC(line, obj.entities)) @@ -681,19 +680,19 @@ void gamelogic(void) if (obj.entities[line].w > 332) { obj.entities[line].w = 332; - game.swngame = 2; + game.swngame = SWN_START_GRAVITRON_STEP_3; graphics.kludgeswnlinewidth = true; } } + break; } - else if (game.swngame == 4) //create top line - { - game.swngame = 3; + case SWN_START_GRAVITRON_STEP_1: //create top line + game.swngame = SWN_START_GRAVITRON_STEP_2; obj.createentity(-8, 84 - 32, 11, 8); // (horizontal gravity line) music.niceplay(Music_POSITIVEFORCE); game.swndeaths = game.deathcounts; - } - else if (game.swngame == 5) //remove line + break; + case SWN_FINISH_GRAVITRON_STEP_1: //remove line { int line = obj.getlineat(148 + 32); if (INBOUNDS_VEC(line, obj.entities)) @@ -702,28 +701,27 @@ void gamelogic(void) if (obj.entities[line].xp > 320) { obj.disableentity(line); - game.swngame = 8; + game.swngame = SWN_FINISH_GRAVITRON_STEP_2; } } + break; } - else if (game.swngame == 6) //Init the super gravitron - { - game.swngame = 7; + case SWN_START_SUPERGRAVITRON_STEP_1: //Init the super gravitron + game.swngame = SWN_START_SUPERGRAVITRON_STEP_2; music.niceplay(Music_POTENTIALFORANYTHING); - } - else if (game.swngame == 7) //introduce game b - { + break; + case SWN_START_SUPERGRAVITRON_STEP_2: //introduce game b game.swndelay--; if (game.swndelay <= 0) { - game.swngame = 1; + game.swngame = SWN_SUPERGRAVITRON; game.swndelay = 0; game.swntimer = 0; game.swncolstate = 3; game.swncoldelay = 30; } - } - else if (game.swngame == 8) //extra kludge if player dies after game a ends + break; + case SWN_FINISH_GRAVITRON_STEP_2: //extra kludge if player dies after game a ends { bool square_onscreen = false; for (size_t i = 0; i < obj.entities.size(); i++) @@ -739,6 +737,9 @@ void gamelogic(void) game.swnmode = false; } } + case SWN_NONE: + break; + } } //Time trial stuff diff --git a/desktop_version/src/Render.cpp b/desktop_version/src/Render.cpp index b16144de..96470a17 100644 --- a/desktop_version/src/Render.cpp +++ b/desktop_version/src/Render.cpp @@ -2020,7 +2020,7 @@ void gamerender(void) if (graphics.fademode == FADE_NONE && !game.intimetrial && !game.isingamecompletescreen() - && (!game.swnmode || game.swngame != 1) + && (!game.swnmode || game.swngame != SWN_SUPERGRAVITRON) && game.showingametimer && !roomname_translator::enabled) { @@ -2129,12 +2129,12 @@ void gamerender(void) if (game.swnmode) { - if (game.swngame == 0) + if (game.swngame == SWN_GRAVITRON) { std::string tempstring = help.timestring(game.swntimer); font::print(PR_2X | PR_CEN | PR_BOR, -1, 20, tempstring, 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2)); } - else if (game.swngame == 1) + else if (game.swngame == SWN_SUPERGRAVITRON) { if (game.swnmessage == 0) { @@ -2210,7 +2210,7 @@ void gamerender(void) ); font::print(PR_BOR | PR_CEN, -1, 228, buffer, 160 - (help.glow/2), 160 - (help.glow/2), 160 - (help.glow/2)); } - else if(game.swngame==2) + else if (game.swngame == SWN_START_GRAVITRON_STEP_3) { if (int(game.swndelay / 15) % 2 == 1 || game.swndelay >= 120) { @@ -2230,7 +2230,7 @@ void gamerender(void) font::print(PR_2X | PR_CEN | PR_BOR, -1, y2, loc::gettext("60 seconds!"), 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2)); } } - else if(game.swngame==7) + else if (game.swngame == SWN_START_SUPERGRAVITRON_STEP_2) { if (game.swndelay >= 60) { diff --git a/desktop_version/src/Script.cpp b/desktop_version/src/Script.cpp index ed0b510c..d510f719 100644 --- a/desktop_version/src/Script.cpp +++ b/desktop_version/src/Script.cpp @@ -3140,7 +3140,7 @@ void scriptclass::hardreset(void) game.swnmode = false; game.swntimer = 0; - game.swngame = 0;//Not playing sine wave ninja! + game.swngame = SWN_NONE; // Not playing sine wave ninja! game.swnstate = 0; game.swnstate2 = 0; game.swnstate3 = 0;