diff --git a/source/code/MenuSystem.h b/source/code/MenuSystem.h index b84e0f0..0a083d7 100644 --- a/source/code/MenuSystem.h +++ b/source/code/MenuSystem.h @@ -68,7 +68,7 @@ public: Button(); Button(const Button& b); - ~Button(); + virtual ~Button(); //Set the text to write on the button diff --git a/source/code/global.hpp b/source/code/global.hpp index 00dc939..2c5a72a 100644 --- a/source/code/global.hpp +++ b/source/code/global.hpp @@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/ Source information and contacts persons can be found at -http://blockattack.net +http://www.blockattack.net =========================================================================== */ @@ -33,7 +33,10 @@ http://blockattack.net void MainMenu(); void ResetFullscreen(); void RunGameState(sago::GameStateInterface& state ); -int runGame(int gametype,int level); + +enum class Gametype { SinglePlayerEndless=0, SinglePlayerTimeTrial=1, StageClear=2, Puzzle=3, SinglePlayerVs=4, TwoPlayerTimeTrial=10, TwoPlayerVs=11 }; + +int runGame(Gametype gametype,int level); bool OpenDialogbox(int x, int y, std::string& name, const std::string& header); extern sago::SagoSprite menuMarked; diff --git a/source/code/main.cpp b/source/code/main.cpp index e4385b6..c8a8318 100644 --- a/source/code/main.cpp +++ b/source/code/main.cpp @@ -1430,7 +1430,7 @@ int main(int argc, char* argv[]) { DrawEverything(xsize,ysize,&theGame,&theGame2); SDL_RenderPresent(screen); if (singlePuzzle) { - runGame(3, singlePuzzleNr); + runGame(Gametype::Puzzle, singlePuzzleNr); } else { //game loop @@ -1493,7 +1493,7 @@ int main(int argc, char* argv[]) { } -int runGame(int gametype, int level) { +int runGame(Gametype gametype, int level) { int mousex, mousey; //Mouse coordinates theTopScoresEndless = Highscore("endless"); theTopScoresTimeTrial = Highscore("timetrial"); @@ -1542,34 +1542,34 @@ int runGame(int gametype, int level) { registerTTHighscorePlayer1 = false; registerTTHighscorePlayer2 = false; switch (gametype) { - case 1: - StartSinglePlayerTimeTrial(); - break; - case 2: { - int myLevel = PuzzleLevelSelect(1); - if (myLevel == -1) { - return 1; - } - BlockGameStartInfo s; - s.ticks = SDL_GetTicks(); - s.stageClear = true; - s.level = myLevel; - theGame.NewGame(s); - DrawIMG(backgroundImage, screen, 0, 0); - twoPlayers =false; - BlockGameAction a; - a.action = BlockGameAction::Action::SET_GAME_OVER; - theGame2.DoAction(a); - theGame.name = player1name; - theGame2.name = player2name; - } - break; - case 3: - if (StartSinglePlayerPuzzle(level)) { - return 1; + case Gametype::SinglePlayerTimeTrial: + StartSinglePlayerTimeTrial(); + break; + case Gametype::StageClear: { + int myLevel = PuzzleLevelSelect(1); + if (myLevel == -1) { + return 1; + } + BlockGameStartInfo s; + s.ticks = SDL_GetTicks(); + s.stageClear = true; + s.level = myLevel; + theGame.NewGame(s); + DrawIMG(backgroundImage, screen, 0, 0); + twoPlayers =false; + BlockGameAction a; + a.action = BlockGameAction::Action::SET_GAME_OVER; + theGame2.DoAction(a); + theGame.name = player1name; + theGame2.name = player2name; } break; - case 4: { + case Gametype::Puzzle: + if (StartSinglePlayerPuzzle(level)) { + return 1; + } + break; + case Gametype::SinglePlayerVs: { //1 player - Vs mode int theAIlevel = level; //startSingleVs(); BlockGameStartInfo startInfo; @@ -1586,13 +1586,13 @@ int runGame(int gametype, int level) { theGame2.name = player2name; } break; - case 10: + case Gametype::TwoPlayerTimeTrial: StarTwoPlayerTimeTrial(); break; - case 11: + case Gametype::TwoPlayerVs: StartTwoPlayerVs(); break; - case 0: + case Gametype::SinglePlayerEndless: default: StartSinglePlayerEndless(); break; @@ -1610,7 +1610,7 @@ int runGame(int gametype, int level) { SDL_RenderClear(screen); DrawIMG(backgroundImage, screen, 0, 0); - //updates the balls and explosions: + //updates the balls and explosions:g theBallManager.update(); theExplosionManager.update(); theTextManager.update(); diff --git a/source/code/menudef.cpp b/source/code/menudef.cpp index 4b84434..3e0729a 100644 --- a/source/code/menudef.cpp +++ b/source/code/menudef.cpp @@ -102,31 +102,31 @@ void InitMenues() { static void runSinglePlayerEndless(Button* b) { - runGame(0,0); + runGame(Gametype::SinglePlayerEndless, 0); } static void runSinglePlayerTimeTrial(Button* b) { - runGame(1,0); + runGame(Gametype::SinglePlayerTimeTrial, 0); } static void runStageClear(Button* b) { - runGame(2,0); + runGame(Gametype::StageClear, 0); } static void runSinglePlayerPuzzle(Button* b) { - runGame(3,0); + runGame(Gametype::Puzzle, 0); } static void runSinglePlayerVs(Button* b) { - runGame(4,b->iGeneric1); + runGame(Gametype::SinglePlayerVs, b->iGeneric1); } static void runTwoPlayerTimeTrial(Button* b) { - runGame(10,0); + runGame(Gametype::TwoPlayerTimeTrial, 0); } static void runTwoPlayerVs(Button* b) { - runGame(11,0); + runGame(Gametype::TwoPlayerVs, 0); } static void buttonActionMusic(Button* b) { @@ -257,7 +257,7 @@ static void SinglePlayerVsMenu(Button* b) { static void MultiplayerMenu(Button* b) { Menu mm(screen,_("Multiplayer"),true); - Button bTT, bVs, bNet; + Button bTT, bVs; bTT.setLabel(_("Two player - time trial")); bTT.setAction(runTwoPlayerTimeTrial); bVs.setLabel(_("Two player - vs"));