mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2026-01-29 17:38:16 +03:00
Use enums for swngame
This replaces the swngame int variable with a named enum and enforces strict typechecking on it. Strict typechecking is okay here as the swngame variable is not part of the API surface of the game in any way and is completely internal. And just to make things clear, I've added a SWN_NONE enum to use for initialization, because previously it was being initialized to 0, even though 0 was the Gravitron.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user