Prepare menu and save files for configurable difficulty and gameplay mode.

This commit is contained in:
Guus Sliepen 2012-12-09 16:11:55 +01:00
parent 070d67e91d
commit b343805257
4 changed files with 78 additions and 14 deletions

View File

@ -310,3 +310,11 @@ const int screenWidth = 800;
const int screenHeight = 600; const int screenHeight = 600;
const int viewBorder = 100; 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

View File

@ -101,6 +101,11 @@ bool loadGame(int slot)
fclose(fp); fclose(fp);
if(currentGame.saveFormat < 2) {
currentGame.gamePlay = GAMEPLAY_ORIGINAL;
currentGame.difficulty = DIFFICULTY_NORMAL;
}
weapon[0] = currentGame.playerWeapon; weapon[0] = currentGame.playerWeapon;
player = currentGame.thePlayer; player = currentGame.thePlayer;
@ -127,6 +132,7 @@ void saveGame(int slot)
sprintf(fileName, "%ssave%.2d.dat", engine.userHomeDirectory, slot); sprintf(fileName, "%ssave%.2d.dat", engine.userHomeDirectory, slot);
fp = fopen(fileName, "wb"); fp = fopen(fileName, "wb");
currentGame.saveFormat = 2;
currentGame.playerWeapon = weapon[0]; currentGame.playerWeapon = weapon[0];
currentGame.thePlayer = player; currentGame.thePlayer = player;
for (int i = 0 ; i < 10 ; i++) for (int i = 0 ; i < 10 ; i++)

View File

@ -120,7 +120,6 @@ struct textObject {
}; };
struct Game { struct Game {
object thePlayer; object thePlayer;
object playerWeapon; object playerWeapon;
@ -129,11 +128,9 @@ struct Game {
unsigned char musicVolume; unsigned char musicVolume;
unsigned char sfxVolume; unsigned char sfxVolume;
// First three variable below are here for save game compatibility only. signed char saveFormat;
signed char gamePlay;
signed char fullScreen; // Do not use! signed char difficulty;
signed char useMusic; // Do not use!
signed char useSound; // Do not use!
signed char autoSaveSlot; signed char autoSaveSlot;
@ -175,6 +172,7 @@ struct Game {
unsigned char maxRocketAmmo; unsigned char maxRocketAmmo;
unsigned char shieldUnits; unsigned char shieldUnits;
}; };
struct ShopItem { struct ShopItem {

View File

@ -64,6 +64,35 @@ static signed char showLoadMenu()
return rtn; 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() static void createOptionsMenu()
{ {
if (engine.useSound) if (engine.useSound)
@ -187,6 +216,7 @@ int doTitle()
textSurface(7, "QUIT", -1, 430, FONT_WHITE); textSurface(7, "QUIT", -1, 430, FONT_WHITE);
createOptionsMenu(); createOptionsMenu();
createDifficultyMenu();
textSurface(12, "BACK TO MAIN MENU", -1, 0, FONT_WHITE); textSurface(12, "BACK TO MAIN MENU", -1, 0, FONT_WHITE);
createCheatMenu(); createCheatMenu();
@ -299,6 +329,9 @@ int doTitle()
case 3: case 3:
listLength = showCheatMenu(); listLength = showCheatMenu();
break; break;
case 4:
listLength = showDifficultyMenu();
break;
} }
redGlow += redDir; redGlow += redDir;
@ -363,11 +396,13 @@ int doTitle()
{ {
switch(menuType) switch(menuType)
{ {
case 0: case 0: // Main menu
if ((selectedOption == 1) || (selectedOption == 3)) if (selectedOption == 1)
engine.done = 1; {menuType = 4; selectedOption = 1;}
else if (selectedOption == 2) else if (selectedOption == 2)
{menuType = 1; selectedOption = 1;} {menuType = 1; selectedOption = 1;}
else if (selectedOption == 3)
engine.done = 1;
else if (selectedOption == 4) else if (selectedOption == 4)
{menuType = 2; selectedOption = 1;} {menuType = 2; selectedOption = 1;}
else if (selectedOption == 5) else if (selectedOption == 5)
@ -381,14 +416,14 @@ int doTitle()
engine.done = 1; engine.done = 1;
break; break;
case 1: case 1: // Load game menu
if (selectedOption != listLength) if (selectedOption != listLength)
{engine.done = 1; continueSaveSlot = selectedOption; selectedOption = 3;} {engine.done = 1; continueSaveSlot = selectedOption; selectedOption = 3;}
else else
{menuType = 0; selectedOption = 1;} {menuType = 0; selectedOption = 1;}
break; break;
case 2: case 2: // Options menu
if ((selectedOption == 1) && (engine.useAudio)) if ((selectedOption == 1) && (engine.useAudio))
engine.useSound = !engine.useSound; engine.useSound = !engine.useSound;
else if ((selectedOption == 2) && (engine.useAudio)) else if ((selectedOption == 2) && (engine.useAudio))
@ -429,7 +464,7 @@ int doTitle()
createOptionsMenu(); createOptionsMenu();
break; break;
case 3: case 3: // Cheat menu
if (selectedOption == 1) if (selectedOption == 1)
engine.cheatShield = !engine.cheatShield; engine.cheatShield = !engine.cheatShield;
else if (selectedOption == 2) else if (selectedOption == 2)
@ -443,9 +478,24 @@ int doTitle()
createCheatMenu(); createCheatMenu();
break; break;
case 4: case 4: // Difficulty menu
if (selectedOption == listLength) 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;} {menuType = 0; selectedOption = 1;}
createDifficultyMenu();
break;
default:
menuType = 0, selectedOption = 1;
break; break;
} }
} }
@ -480,6 +530,8 @@ int doTitle()
exit(0); exit(0);
} }
fprintf(stderr, "Difficulty %d, gameplay %d\n", currentGame.difficulty, currentGame.gamePlay);
return selectedOption; return selectedOption;
} }