From b343805257b33b6511cb05068f8f054c2b6c989c Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Sun, 9 Dec 2012 16:11:55 +0100 Subject: [PATCH] Prepare menu and save files for configurable difficulty and gameplay mode. --- code/defs.h | 8 ++++++ code/loadSave.cpp | 6 +++++ code/structs.h | 10 +++---- code/title.cpp | 68 +++++++++++++++++++++++++++++++++++++++++------ 4 files changed, 78 insertions(+), 14 deletions(-) diff --git a/code/defs.h b/code/defs.h index e093b2f..a24c3db 100644 --- a/code/defs.h +++ b/code/defs.h @@ -310,3 +310,11 @@ const int screenWidth = 800; const int screenHeight = 600; const int viewBorder = 100; + +#define DIFFICULTY_EASY -1 +#define DIFFICULTY_NORMAL 0 +#define DIFFICULTY_HARD 1 +#define DIFFICULTY_NIGHTMARE 2 + +#define GAMEPLAY_ORIGINAL 0 +#define GAMEPLAY_ONPON 1 diff --git a/code/loadSave.cpp b/code/loadSave.cpp index 07aba9b..2281c7c 100644 --- a/code/loadSave.cpp +++ b/code/loadSave.cpp @@ -101,6 +101,11 @@ bool loadGame(int slot) fclose(fp); + if(currentGame.saveFormat < 2) { + currentGame.gamePlay = GAMEPLAY_ORIGINAL; + currentGame.difficulty = DIFFICULTY_NORMAL; + } + weapon[0] = currentGame.playerWeapon; player = currentGame.thePlayer; @@ -127,6 +132,7 @@ void saveGame(int slot) sprintf(fileName, "%ssave%.2d.dat", engine.userHomeDirectory, slot); fp = fopen(fileName, "wb"); + currentGame.saveFormat = 2; currentGame.playerWeapon = weapon[0]; currentGame.thePlayer = player; for (int i = 0 ; i < 10 ; i++) diff --git a/code/structs.h b/code/structs.h index 3af75db..f66a3c7 100644 --- a/code/structs.h +++ b/code/structs.h @@ -120,7 +120,6 @@ struct textObject { }; struct Game { - object thePlayer; object playerWeapon; @@ -129,11 +128,9 @@ struct Game { unsigned char musicVolume; unsigned char sfxVolume; - // First three variable below are here for save game compatibility only. - - signed char fullScreen; // Do not use! - signed char useMusic; // Do not use! - signed char useSound; // Do not use! + signed char saveFormat; + signed char gamePlay; + signed char difficulty; signed char autoSaveSlot; @@ -175,6 +172,7 @@ struct Game { unsigned char maxRocketAmmo; unsigned char shieldUnits; + }; struct ShopItem { diff --git a/code/title.cpp b/code/title.cpp index 911a17e..7ab6713 100644 --- a/code/title.cpp +++ b/code/title.cpp @@ -64,6 +64,35 @@ static signed char showLoadMenu() return rtn; } +static void createDifficultyMenu() +{ + textSurface(13, "START GAME", -1, 350, FONT_WHITE); + + if (currentGame.difficulty == DIFFICULTY_EASY) + textSurface(14, "DIFFICULTY - EASY", -1, 370, FONT_WHITE); + else if(currentGame.difficulty == DIFFICULTY_HARD) + textSurface(14, "DIFFICULTY - HARD", -1, 370, FONT_WHITE); + else + textSurface(14, "DIFFICULTY - NORMAL", -1, 370, FONT_WHITE); + + if (currentGame.gamePlay == GAMEPLAY_ONPON) + textSurface(15, "GAMEPLAY - ONPON", -1, 390, FONT_WHITE); + else + textSurface(15, "GAMEPLAY - NORMAL", -1, 390, FONT_WHITE); +} + +static signed char showDifficultyMenu() +{ + textShape[12].y = 430; + + blitText(13); + blitText(14); + blitText(15); + blitText(12); + + return 4; +} + static void createOptionsMenu() { if (engine.useSound) @@ -187,6 +216,7 @@ int doTitle() textSurface(7, "QUIT", -1, 430, FONT_WHITE); createOptionsMenu(); + createDifficultyMenu(); textSurface(12, "BACK TO MAIN MENU", -1, 0, FONT_WHITE); createCheatMenu(); @@ -299,6 +329,9 @@ int doTitle() case 3: listLength = showCheatMenu(); break; + case 4: + listLength = showDifficultyMenu(); + break; } redGlow += redDir; @@ -363,11 +396,13 @@ int doTitle() { switch(menuType) { - case 0: - if ((selectedOption == 1) || (selectedOption == 3)) - engine.done = 1; + case 0: // Main menu + if (selectedOption == 1) + {menuType = 4; selectedOption = 1;} else if (selectedOption == 2) {menuType = 1; selectedOption = 1;} + else if (selectedOption == 3) + engine.done = 1; else if (selectedOption == 4) {menuType = 2; selectedOption = 1;} else if (selectedOption == 5) @@ -381,14 +416,14 @@ int doTitle() engine.done = 1; break; - case 1: + case 1: // Load game menu if (selectedOption != listLength) {engine.done = 1; continueSaveSlot = selectedOption; selectedOption = 3;} else {menuType = 0; selectedOption = 1;} break; - case 2: + case 2: // Options menu if ((selectedOption == 1) && (engine.useAudio)) engine.useSound = !engine.useSound; else if ((selectedOption == 2) && (engine.useAudio)) @@ -429,7 +464,7 @@ int doTitle() createOptionsMenu(); break; - case 3: + case 3: // Cheat menu if (selectedOption == 1) engine.cheatShield = !engine.cheatShield; else if (selectedOption == 2) @@ -443,9 +478,24 @@ int doTitle() createCheatMenu(); break; - case 4: - if (selectedOption == listLength) + case 4: // Difficulty menu + if (selectedOption == 1) + engine.done = 1; + else if (selectedOption == 2) + currentGame.difficulty++; + if(currentGame.difficulty > DIFFICULTY_HARD) + currentGame.difficulty = DIFFICULTY_EASY; + else if (selectedOption == 3) + currentGame.gamePlay++; + if(currentGame.gamePlay > GAMEPLAY_ONPON) + currentGame.gamePlay = GAMEPLAY_ORIGINAL; + else if (selectedOption == listLength) {menuType = 0; selectedOption = 1;} + createDifficultyMenu(); + break; + + default: + menuType = 0, selectedOption = 1; break; } } @@ -480,6 +530,8 @@ int doTitle() exit(0); } + fprintf(stderr, "Difficulty %d, gameplay %d\n", currentGame.difficulty, currentGame.gamePlay); + return selectedOption; }