2011-08-24 14:14:44 +02:00
|
|
|
/*
|
|
|
|
Copyright (C) 2003 Parallel Realities
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2011-08-26 21:29:04 +02:00
|
|
|
#include "Starfighter.h"
|
2011-08-24 14:14:44 +02:00
|
|
|
|
2011-08-26 21:29:04 +02:00
|
|
|
static signed char showGameMenu(signed char continueSaveSlot)
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
2011-08-26 23:53:46 +02:00
|
|
|
blitText(2);
|
2011-08-24 14:14:44 +02:00
|
|
|
if (continueSaveSlot != 0)
|
|
|
|
{
|
2011-08-26 23:53:46 +02:00
|
|
|
blitText(3);
|
|
|
|
blitText(4);
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
2011-08-26 23:53:46 +02:00
|
|
|
blitText(5);
|
2011-08-24 14:14:44 +02:00
|
|
|
if (engine.cheat)
|
|
|
|
{
|
2011-08-26 23:53:46 +02:00
|
|
|
textShape[7].y = 450;
|
|
|
|
blitText(6);
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-08-26 23:53:46 +02:00
|
|
|
textShape[7].y = 430;
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
2011-08-26 23:53:46 +02:00
|
|
|
blitText(7);
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
if (engine.cheat)
|
|
|
|
return 6;
|
|
|
|
|
|
|
|
return 5;
|
|
|
|
}
|
|
|
|
|
2011-08-26 21:29:04 +02:00
|
|
|
static signed char showLoadMenu()
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
|
|
|
signed char rtn = 1;
|
|
|
|
|
|
|
|
for (int i = 13 ; i < 18 ; i++)
|
|
|
|
{
|
2011-08-26 23:53:46 +02:00
|
|
|
if (textShape[i].image != NULL)
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
2011-08-26 23:53:46 +02:00
|
|
|
blitText(i);
|
2011-08-24 14:14:44 +02:00
|
|
|
rtn++;
|
2011-08-26 23:53:46 +02:00
|
|
|
textShape[12].y = textShape[i].y + 40;
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
|
|
|
}
|
2011-08-26 23:53:46 +02:00
|
|
|
blitText(12);
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
return rtn;
|
|
|
|
}
|
|
|
|
|
2011-08-26 21:29:04 +02:00
|
|
|
static void createOptionsMenu()
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
2011-08-26 22:48:52 +02:00
|
|
|
if (engine.useSound)
|
2011-08-26 23:53:46 +02:00
|
|
|
textSurface(8, "SOUND - ON", -1, 350, FONT_WHITE);
|
2011-08-24 14:14:44 +02:00
|
|
|
else
|
2011-08-26 23:53:46 +02:00
|
|
|
textSurface(8, "SOUND - OFF", -1, 350, FONT_WHITE);
|
2011-08-24 14:14:44 +02:00
|
|
|
|
2011-08-26 22:48:52 +02:00
|
|
|
if (engine.useMusic)
|
2011-08-26 23:53:46 +02:00
|
|
|
textSurface(9, "MUSIC - ON", -1, 370, FONT_WHITE);
|
2011-08-24 14:14:44 +02:00
|
|
|
else
|
2011-08-26 23:53:46 +02:00
|
|
|
textSurface(9, "MUSIC - OFF", -1, 370, FONT_WHITE);
|
2011-08-24 14:14:44 +02:00
|
|
|
|
2011-08-26 22:48:52 +02:00
|
|
|
if (engine.fullScreen)
|
2011-08-26 23:53:46 +02:00
|
|
|
textSurface(10, "FULLSCREEN - ON", -1, 390, FONT_WHITE);
|
2011-08-24 14:14:44 +02:00
|
|
|
else
|
2011-08-26 23:53:46 +02:00
|
|
|
textSurface(10, "FULLSCREEN - OFF", -1, 390, FONT_WHITE);
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
char string[50];
|
|
|
|
strcpy(string, "AUTO SAVE SLOT - NONE");
|
|
|
|
if (currentGame.autoSaveSlot > -1)
|
|
|
|
sprintf(string, "AUTO SAVE SLOT - #%d", currentGame.autoSaveSlot + 1);
|
2011-08-26 23:53:46 +02:00
|
|
|
textSurface(11, string, -1, 410, FONT_WHITE);
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
|
|
|
|
2011-08-26 21:29:04 +02:00
|
|
|
static signed char showOptionsMenu()
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
2011-08-26 23:53:46 +02:00
|
|
|
textShape[12].y = 450;
|
2011-08-24 14:14:44 +02:00
|
|
|
|
2011-08-26 23:53:46 +02:00
|
|
|
blitText(8);
|
|
|
|
blitText(9);
|
|
|
|
blitText(10);
|
|
|
|
blitText(11);
|
|
|
|
blitText(12);
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
return 5;
|
|
|
|
}
|
|
|
|
|
2011-08-26 21:29:04 +02:00
|
|
|
static void createCheatMenu()
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
|
|
|
if (engine.cheatShield)
|
2011-08-26 23:53:46 +02:00
|
|
|
textSurface(18, "UNLIMITED SHIELD - ON", -1, 350, FONT_WHITE);
|
2011-08-24 14:14:44 +02:00
|
|
|
else
|
2011-08-26 23:53:46 +02:00
|
|
|
textSurface(18, "UNLIMITED SHIELD - OFF", -1, 350, FONT_WHITE);
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
if (engine.cheatAmmo)
|
2011-08-26 23:53:46 +02:00
|
|
|
textSurface(19, "UNLIMITED AMMO - ON", -1, 370, FONT_WHITE);
|
2011-08-24 14:14:44 +02:00
|
|
|
else
|
2011-08-26 23:53:46 +02:00
|
|
|
textSurface(19, "UNLIMITED AMMO - OFF", -1, 370, FONT_WHITE);
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
if (engine.cheatCash)
|
2011-08-26 23:53:46 +02:00
|
|
|
textSurface(20, "UNLIMITED CASH - ON", -1, 390, FONT_WHITE);
|
2011-08-24 14:14:44 +02:00
|
|
|
else
|
2011-08-26 23:53:46 +02:00
|
|
|
textSurface(20, "UNLIMITED CASH - OFF", -1, 390, FONT_WHITE);
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
if (engine.cheatTime)
|
2011-08-26 23:53:46 +02:00
|
|
|
textSurface(21, "UNLIMITED TIME - ON", -1, 410, FONT_WHITE);
|
2011-08-24 14:14:44 +02:00
|
|
|
else
|
2011-08-26 23:53:46 +02:00
|
|
|
textSurface(21, "UNLIMITED TIME - OFF", -1, 410, FONT_WHITE);
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
|
|
|
|
2011-08-26 21:29:04 +02:00
|
|
|
static signed char showCheatMenu()
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
2011-08-26 23:53:46 +02:00
|
|
|
textShape[12].y = 450;
|
2011-08-24 14:14:44 +02:00
|
|
|
|
2011-08-26 23:53:46 +02:00
|
|
|
blitText(18);
|
|
|
|
blitText(19);
|
|
|
|
blitText(20);
|
|
|
|
blitText(21);
|
|
|
|
blitText(12);
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
return 5;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
This is the main title screen, with the stars whirling past and the
|
|
|
|
"Parallel Realities, Present..." text. Nothing too special.
|
|
|
|
*/
|
|
|
|
int doTitle()
|
|
|
|
{
|
|
|
|
newGame();
|
|
|
|
|
|
|
|
engine.gameSection = SECTION_TITLE;
|
|
|
|
|
2011-08-26 23:53:46 +02:00
|
|
|
flushBuffer();
|
|
|
|
freeGraphics();
|
2011-08-24 14:14:44 +02:00
|
|
|
resetLists();
|
|
|
|
|
|
|
|
// required to stop the title screen crashing
|
|
|
|
currentGame.system = 0;
|
|
|
|
currentGame.area = 0;
|
|
|
|
|
|
|
|
loadGameGraphics();
|
|
|
|
|
2011-08-26 23:53:46 +02:00
|
|
|
clearScreen(black);
|
|
|
|
updateScreen();
|
|
|
|
clearScreen(black);
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
signed char continueSaveSlot = initSaveSlots();
|
|
|
|
|
|
|
|
loadMusic("music/Platinum.mod");
|
|
|
|
|
|
|
|
loadBackground("gfx/spirit.jpg");
|
|
|
|
|
|
|
|
SDL_Surface *prlogo, *sflogo;
|
2011-08-27 16:18:29 +02:00
|
|
|
prlogo = loadImage("gfx/prlogo.png");
|
|
|
|
sflogo = loadImage("gfx/sflogo.png");
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
int prx = ((800 - prlogo->w) / 2);
|
|
|
|
int pry = ((600 - prlogo->h) / 2);
|
|
|
|
|
|
|
|
int sfx = ((800 - sflogo->w) / 2);
|
|
|
|
int sfy = ((600 - sflogo->h) / 2);
|
|
|
|
|
2011-08-26 23:53:46 +02:00
|
|
|
textSurface(0, "PRESENTS", -1, 300, FONT_WHITE);
|
|
|
|
textSurface(1, "AN SDL GAME", -1, 300, FONT_WHITE);
|
|
|
|
textSurface(2, "START NEW GAME", -1, 350, FONT_WHITE);
|
|
|
|
textSurface(3, "LOAD GAME", -1, 370, FONT_WHITE);
|
|
|
|
textSurface(4, "CONTINUE CURRENT GAME", -1, 390, FONT_WHITE);
|
|
|
|
textSurface(5, "OPTIONS", -1, 410, FONT_WHITE);
|
|
|
|
textSurface(6, "CHEAT OPTIONS", -1, 430, FONT_WHITE);
|
|
|
|
textSurface(7, "QUIT", -1, 430, FONT_WHITE);
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
createOptionsMenu();
|
2011-08-26 23:53:46 +02:00
|
|
|
textSurface(12, "BACK TO MAIN MENU", -1, 0, FONT_WHITE);
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
createCheatMenu();
|
|
|
|
|
|
|
|
// Set the star motion
|
|
|
|
engine.ssx = -0.5;
|
|
|
|
engine.ssy = 0;
|
|
|
|
|
|
|
|
int then = SDL_GetTicks();
|
|
|
|
int now;
|
|
|
|
|
|
|
|
for (int i = 0 ; i < 15 ; i++)
|
|
|
|
{
|
|
|
|
enemy[i] = defEnemy[rand() % 3];
|
|
|
|
if ((rand() % 5) == 0)
|
|
|
|
enemy[i] = defEnemy[CD_TRANSPORTSHIP];
|
|
|
|
if ((rand() % 5) == 0)
|
|
|
|
enemy[i] = defEnemy[CD_MINER];
|
|
|
|
enemy[i].x = rand() % 800;
|
|
|
|
enemy[i].y = rand() % 560;
|
|
|
|
enemy[i].dx = 1 + rand() % 3;
|
|
|
|
enemy[i].face = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int redGlow = 255;
|
|
|
|
signed char redDir = -2;
|
|
|
|
char buildVersion[25];
|
|
|
|
sprintf(buildVersion, "Version "VERSION);
|
|
|
|
|
|
|
|
SDL_Rect optionRec;
|
|
|
|
|
|
|
|
optionRec.x = 290;
|
|
|
|
optionRec.y = 345;
|
|
|
|
optionRec.h = 22;
|
|
|
|
optionRec.w = 215;
|
|
|
|
|
|
|
|
signed char selectedOption = 1;
|
|
|
|
if (continueSaveSlot > 0)
|
|
|
|
{selectedOption = 3; optionRec.y += 40;}
|
|
|
|
|
2011-08-26 16:55:46 +02:00
|
|
|
bool skip = false;
|
2011-08-24 14:14:44 +02:00
|
|
|
signed char listLength = 5; // menu list length
|
|
|
|
signed char menuType = 0;
|
|
|
|
|
2011-08-26 23:53:46 +02:00
|
|
|
drawBackGround();
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
engine.done = 0;
|
|
|
|
flushInput();
|
|
|
|
engine.keyState[SDLK_LCTRL] = engine.keyState[SDLK_RCTRL] = 0;
|
|
|
|
|
2011-08-26 22:48:52 +02:00
|
|
|
if ((engine.useMusic) && (engine.useAudio))
|
2011-08-24 14:14:44 +02:00
|
|
|
Mix_PlayMusic(engine.music, 1);
|
|
|
|
|
|
|
|
while (!engine.done)
|
|
|
|
{
|
2011-08-26 23:53:46 +02:00
|
|
|
updateScreen();
|
|
|
|
unBuffer();
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
now = SDL_GetTicks();
|
|
|
|
|
|
|
|
doStarfield();
|
|
|
|
doExplosions();
|
|
|
|
|
|
|
|
for (int i = 0 ; i < 15 ; i++)
|
|
|
|
{
|
|
|
|
addEngine(&enemy[i]);
|
|
|
|
enemy[i].x += enemy[i].dx;
|
2011-08-26 23:53:46 +02:00
|
|
|
blit(enemy[i].image[0], (int)enemy[i].x, (int)enemy[i].y);
|
2011-08-24 14:14:44 +02:00
|
|
|
if (enemy[i].x > 830)
|
|
|
|
{
|
|
|
|
enemy[i].x = -10;
|
|
|
|
enemy[i].y = rand() % 580;
|
|
|
|
enemy[i].dx = 1 + rand() % 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((now - then > 2000) && (now - then < 8000) && (!skip))
|
|
|
|
{
|
2011-08-26 23:53:46 +02:00
|
|
|
blit(prlogo, prx, pry);
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
|
|
|
else if ((now - then > 9000) && (now - then < 15000) && (!skip))
|
|
|
|
{
|
2011-08-26 23:53:46 +02:00
|
|
|
blitText(0);
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
|
|
|
else if ((now - then > 16000) && (now - then < 21000) && (!skip))
|
|
|
|
{
|
2011-08-26 23:53:46 +02:00
|
|
|
blitText(1);
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
|
|
|
else if ((now - then > 25500) || (skip))
|
|
|
|
{
|
2011-08-26 23:53:46 +02:00
|
|
|
blit(sflogo, sfx, sfy);
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
if ((now - then >= 27500) || (skip))
|
|
|
|
{
|
2011-08-26 23:53:46 +02:00
|
|
|
addBuffer(280, 345, 235, 145);
|
2011-08-24 14:14:44 +02:00
|
|
|
|
2011-08-26 23:53:46 +02:00
|
|
|
blevelRect(optionRec.x, optionRec.y, optionRec.w, optionRec.h, redGlow, 0x00, 0x00);
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
switch(menuType)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
listLength = showGameMenu(continueSaveSlot);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
listLength = showLoadMenu();
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
listLength = showOptionsMenu();
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
listLength = showCheatMenu();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
redGlow += redDir;
|
|
|
|
if (redGlow <= 0) {redDir = 2; redGlow = 0;}
|
|
|
|
if (redGlow >= 255) {redDir = -2; redGlow = 255;}
|
|
|
|
|
|
|
|
if (engine.keyState[SDLK_UP])
|
|
|
|
{
|
|
|
|
engine.keyState[SDLK_UP] = 0;
|
2011-08-26 23:27:16 +02:00
|
|
|
wrapChar(&(--selectedOption), 1, listLength);
|
2011-08-24 14:14:44 +02:00
|
|
|
if (menuType == 0)
|
|
|
|
if ((selectedOption == 2) || (selectedOption == 3))
|
|
|
|
if (continueSaveSlot == 0)
|
|
|
|
selectedOption = 1;
|
|
|
|
}
|
|
|
|
if (engine.keyState[SDLK_DOWN])
|
|
|
|
{
|
|
|
|
engine.keyState[SDLK_DOWN] = 0;
|
2011-08-26 23:27:16 +02:00
|
|
|
wrapChar(&(++selectedOption), 1, listLength);
|
2011-08-24 14:14:44 +02:00
|
|
|
if (menuType == 0)
|
|
|
|
if ((selectedOption == 2) || (selectedOption == 3))
|
|
|
|
if (continueSaveSlot == 0)
|
|
|
|
selectedOption = 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
optionRec.y = 326 + (20 * selectedOption);
|
|
|
|
if (menuType > 0)
|
|
|
|
if (selectedOption == listLength)
|
|
|
|
optionRec.y += 20;
|
|
|
|
|
|
|
|
if (!skip)
|
|
|
|
{
|
2011-08-26 23:53:46 +02:00
|
|
|
drawString("Copyright Parallel Realities 2003", 5, 580, FONT_WHITE, background);
|
|
|
|
drawString(buildVersion, 695, 580, FONT_WHITE, background);
|
|
|
|
addBuffer(0, 580, 800, 20);
|
2011-08-26 16:55:46 +02:00
|
|
|
skip = true;
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
getPlayerInput();
|
|
|
|
|
|
|
|
// if someone has invoked the credits cheat
|
|
|
|
if (engine.cheatCredits)
|
|
|
|
{
|
|
|
|
doCredits();
|
2011-08-26 16:14:58 +02:00
|
|
|
engine.cheatCredits = false;
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((engine.keyState[SDLK_LCTRL]) || (engine.keyState[SDLK_RCTRL]) || (engine.keyState[SDLK_SPACE]))
|
|
|
|
{
|
|
|
|
if ((now - then <= 27500) && (!skip))
|
|
|
|
{
|
2011-08-26 23:53:46 +02:00
|
|
|
drawString("Copyright Parallel Realities 2003", 5, 580, FONT_WHITE, background);
|
|
|
|
drawString(buildVersion, 695, 580, FONT_WHITE, background);
|
|
|
|
addBuffer(0, 580, 800, 20);
|
2011-08-26 16:55:46 +02:00
|
|
|
skip = true;
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
switch(menuType)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
if ((selectedOption == 1) || (selectedOption == 3))
|
|
|
|
engine.done = 1;
|
|
|
|
else if (selectedOption == 2)
|
|
|
|
{menuType = 1; selectedOption = 1;}
|
|
|
|
else if (selectedOption == 4)
|
|
|
|
{menuType = 2; selectedOption = 1;}
|
|
|
|
else if (selectedOption == 5)
|
|
|
|
{
|
|
|
|
if (engine.cheat)
|
|
|
|
{menuType = 3; selectedOption = 1;}
|
|
|
|
else
|
|
|
|
engine.done = 1;
|
|
|
|
}
|
|
|
|
else if (selectedOption == 6)
|
|
|
|
engine.done = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
if (selectedOption != listLength)
|
|
|
|
{engine.done = 1; continueSaveSlot = selectedOption; selectedOption = 3;}
|
|
|
|
else
|
|
|
|
{menuType = 0; selectedOption = 1;}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
if ((selectedOption == 1) && (engine.useAudio))
|
2011-08-26 22:48:52 +02:00
|
|
|
engine.useSound = !engine.useSound;
|
2011-08-24 14:14:44 +02:00
|
|
|
else if ((selectedOption == 2) && (engine.useAudio))
|
|
|
|
{
|
2011-08-26 22:48:52 +02:00
|
|
|
engine.useMusic = !engine.useMusic;
|
2011-08-24 14:14:44 +02:00
|
|
|
|
2011-08-26 22:48:52 +02:00
|
|
|
if (engine.useMusic)
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
|
|
|
if (Mix_PausedMusic() == 1)
|
|
|
|
Mix_ResumeMusic();
|
|
|
|
else
|
|
|
|
Mix_PlayMusic(engine.music, 1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Mix_PauseMusic();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (selectedOption == 3)
|
|
|
|
{
|
2011-08-26 22:48:52 +02:00
|
|
|
engine.fullScreen = !engine.fullScreen;
|
2011-08-24 14:14:44 +02:00
|
|
|
#if LINUX
|
2011-08-26 23:53:46 +02:00
|
|
|
SDL_WM_ToggleFullScreen(screen);
|
2011-08-24 14:14:44 +02:00
|
|
|
#else
|
2011-08-26 22:48:52 +02:00
|
|
|
if (engine.fullScreen)
|
2011-08-26 23:53:46 +02:00
|
|
|
screen = SDL_SetVideoMode(800, 600, 0, SDL_DOUBLEBUF|SDL_HWPALETTE|SDL_FULLSCREEN);
|
2011-08-24 14:14:44 +02:00
|
|
|
else
|
2011-08-26 23:53:46 +02:00
|
|
|
screen = SDL_SetVideoMode(800, 600, 0, SDL_DOUBLEBUF|SDL_HWPALETTE);
|
2011-08-24 14:14:44 +02:00
|
|
|
|
2011-08-26 23:53:46 +02:00
|
|
|
drawBackground();
|
2011-08-24 14:14:44 +02:00
|
|
|
flushBuffer();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
else if (selectedOption == 4)
|
2011-08-26 23:27:16 +02:00
|
|
|
wrapChar(&(++currentGame.autoSaveSlot), -1, 4);
|
2011-08-24 14:14:44 +02:00
|
|
|
else if (selectedOption == listLength)
|
|
|
|
{menuType = 0; selectedOption = 1;}
|
|
|
|
createOptionsMenu();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
if (selectedOption == 1)
|
2011-08-26 16:14:58 +02:00
|
|
|
engine.cheatShield = !engine.cheatShield;
|
2011-08-24 14:14:44 +02:00
|
|
|
else if (selectedOption == 2)
|
2011-08-26 16:14:58 +02:00
|
|
|
engine.cheatAmmo = !engine.cheatAmmo;
|
2011-08-24 14:14:44 +02:00
|
|
|
else if (selectedOption == 3)
|
2011-08-26 16:14:58 +02:00
|
|
|
engine.cheatCash = !engine.cheatCash;
|
2011-08-24 14:14:44 +02:00
|
|
|
else if (selectedOption == 4)
|
2011-08-26 16:14:58 +02:00
|
|
|
engine.cheatTime = !engine.cheatTime;
|
2011-08-24 14:14:44 +02:00
|
|
|
else if (selectedOption == listLength)
|
|
|
|
{menuType = 0; selectedOption = 1;}
|
|
|
|
createCheatMenu();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
if (selectedOption == listLength)
|
|
|
|
{menuType = 0; selectedOption = 1;}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
engine.keyState[SDLK_LCTRL] = engine.keyState[SDLK_RCTRL] = engine.keyState[SDLK_SPACE] = 0;
|
|
|
|
}
|
|
|
|
|
2011-08-26 23:53:46 +02:00
|
|
|
delayFrame();
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Mix_HaltMusic();
|
|
|
|
|
|
|
|
SDL_FreeSurface(prlogo);
|
|
|
|
SDL_FreeSurface(sflogo);
|
|
|
|
|
|
|
|
engine.keyState[SDLK_LCTRL] = engine.keyState[SDLK_RCTRL] = engine.keyState[SDLK_SPACE] = 0;
|
|
|
|
|
|
|
|
resetLists();
|
|
|
|
|
|
|
|
if (selectedOption == 1)
|
|
|
|
selectedOption = 2; // go straight to mission 0
|
|
|
|
|
|
|
|
if (selectedOption == 3)
|
|
|
|
{
|
|
|
|
newGame();
|
|
|
|
selectedOption = loadGame(continueSaveSlot);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Send back a negative number...
|
|
|
|
if (selectedOption > 4)
|
|
|
|
{
|
|
|
|
selectedOption = -1;
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
return selectedOption;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Scrolls the intro text up the screen and nothing else. The text will be placed
|
|
|
|
into a data file when the game is finished.
|
|
|
|
*/
|
|
|
|
void showStory()
|
|
|
|
{
|
2011-08-26 23:53:46 +02:00
|
|
|
freeGraphics();
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
int y = 620;
|
|
|
|
|
|
|
|
FILE *fp;
|
|
|
|
|
|
|
|
#if USEPACK
|
|
|
|
int dataLocation = locateDataInPak("data/intro.txt", 1);
|
|
|
|
fp = fopen(PACKLOCATION, "rb");
|
|
|
|
fseek(fp, dataLocation, SEEK_SET);
|
|
|
|
#else
|
|
|
|
fp = fopen("data/intro.txt", "rb");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
int i = 0;
|
|
|
|
int nextPos = -1;
|
|
|
|
char string[255];
|
|
|
|
|
|
|
|
fscanf(fp, "%d ", &nextPos);
|
|
|
|
|
|
|
|
while (nextPos != -1)
|
|
|
|
{
|
|
|
|
fscanf(fp, "%[^\n]%*c", string);
|
|
|
|
|
|
|
|
y += nextPos;
|
2011-08-26 23:53:46 +02:00
|
|
|
textSurface(i, string, -1, y, FONT_WHITE);
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
i++;
|
|
|
|
|
|
|
|
fscanf(fp, "%d ", &nextPos);
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose(fp);
|
|
|
|
|
|
|
|
loadBackground("gfx/startUp.jpg");
|
2011-08-26 23:53:46 +02:00
|
|
|
blit(background, 0, 0);
|
|
|
|
flushBuffer();
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
flushInput();
|
|
|
|
engine.keyState[SDLK_LCTRL] = engine.keyState[SDLK_RCTRL] = engine.keyState[SDLK_SPACE] = 0;
|
|
|
|
|
|
|
|
while (true)
|
|
|
|
{
|
2011-08-26 23:53:46 +02:00
|
|
|
updateScreen();
|
|
|
|
unBuffer();
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
getPlayerInput();
|
|
|
|
|
|
|
|
if ((engine.keyState[SDLK_LCTRL]) || (engine.keyState[SDLK_RCTRL]) || (engine.keyState[SDLK_SPACE]))
|
|
|
|
break;
|
|
|
|
|
2011-08-26 23:53:46 +02:00
|
|
|
if (textShape[8].y > 450)
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
|
|
|
for (int i = 0 ; i < 9 ; i++)
|
|
|
|
{
|
2011-08-26 23:53:46 +02:00
|
|
|
textShape[i].y -= 0.33333;
|
|
|
|
blitText(i);
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SDL_Delay(3000);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-08-26 23:53:46 +02:00
|
|
|
delayFrame();
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
The game over screen :(
|
|
|
|
*/
|
|
|
|
void gameover()
|
|
|
|
{
|
2011-08-26 23:53:46 +02:00
|
|
|
flushBuffer();
|
|
|
|
freeGraphics();
|
|
|
|
SDL_FillRect(background, NULL, black);
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
engine.keyState[SDLK_LCTRL] = engine.keyState[SDLK_RCTRL] = engine.keyState[SDLK_SPACE] = 0;
|
|
|
|
engine.gameSection = SECTION_INTERMISSION;
|
|
|
|
|
|
|
|
loadMusic("music/Wybierak.mod");
|
|
|
|
|
|
|
|
SDL_Surface *gameover = loadImage("gfx/gameover.png");
|
|
|
|
|
2011-08-26 23:53:46 +02:00
|
|
|
clearScreen(black);
|
|
|
|
updateScreen();
|
|
|
|
clearScreen(black);
|
2011-08-24 14:14:44 +02:00
|
|
|
SDL_Delay(1000);
|
|
|
|
|
2011-08-26 22:48:52 +02:00
|
|
|
if ((engine.useMusic) && (engine.useAudio))
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
|
|
|
Mix_VolumeMusic(100);
|
|
|
|
Mix_PlayMusic(engine.music, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
int x = (800 - gameover->w) / 2;
|
|
|
|
int y = (600 - gameover->h) / 2;
|
|
|
|
|
2011-08-26 23:53:46 +02:00
|
|
|
updateScreen();
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
flushInput();
|
|
|
|
engine.keyState[SDLK_LCTRL] = engine.keyState[SDLK_RCTRL] = engine.keyState[SDLK_SPACE] = 0;
|
|
|
|
|
|
|
|
while (true)
|
|
|
|
{
|
|
|
|
getPlayerInput();
|
|
|
|
|
|
|
|
if ((engine.keyState[SDLK_LCTRL]) || (engine.keyState[SDLK_RCTRL]) || (engine.keyState[SDLK_SPACE]))
|
|
|
|
break;
|
|
|
|
|
2011-08-26 23:53:46 +02:00
|
|
|
updateScreen();
|
2011-08-24 14:14:44 +02:00
|
|
|
|
2011-08-26 23:53:46 +02:00
|
|
|
unBuffer();
|
2011-08-26 23:27:16 +02:00
|
|
|
x = ((800 - gameover->w) / 2) - rrand(-2, 2);
|
|
|
|
y = ((600 - gameover->h) / 2) - rrand(-2, 2);
|
2011-08-26 23:53:46 +02:00
|
|
|
blit(gameover, x, y);
|
2011-08-24 14:14:44 +02:00
|
|
|
|
2011-08-26 23:53:46 +02:00
|
|
|
delayFrame();
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
SDL_FreeSurface(gameover);
|
|
|
|
|
2011-08-26 22:48:52 +02:00
|
|
|
if ((engine.useMusic) && (engine.useAudio))
|
2011-08-24 14:14:44 +02:00
|
|
|
Mix_HaltMusic();
|
|
|
|
|
2011-08-26 23:53:46 +02:00
|
|
|
flushBuffer();
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void doCredits()
|
|
|
|
{
|
|
|
|
loadBackground("gfx/credits.jpg");
|
2011-08-26 23:53:46 +02:00
|
|
|
flushBuffer();
|
|
|
|
freeGraphics();
|
2011-08-24 14:14:44 +02:00
|
|
|
|
2011-08-26 22:48:52 +02:00
|
|
|
if ((engine.useMusic) && (engine.useAudio))
|
2011-08-24 14:14:44 +02:00
|
|
|
loadMusic("music/Solace.s3m");
|
|
|
|
|
|
|
|
FILE *fp;
|
|
|
|
int numberOfCredits = 0;
|
|
|
|
int lastCredit = 0;
|
|
|
|
|
|
|
|
int yPos = 0;
|
2011-08-27 00:29:23 +02:00
|
|
|
int yPos2 = 600;
|
2011-08-24 14:14:44 +02:00
|
|
|
char text[255];
|
|
|
|
|
|
|
|
textObject *credit;
|
|
|
|
|
2011-08-26 23:53:46 +02:00
|
|
|
clearScreen(black);
|
|
|
|
updateScreen();
|
|
|
|
clearScreen(black);
|
2011-08-24 14:14:44 +02:00
|
|
|
|
2011-08-26 23:53:46 +02:00
|
|
|
drawBackGround();
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
#if USEPACK
|
|
|
|
int dataLocation = locateDataInPak("data/credits.txt", 1);
|
|
|
|
fp = fopen(PACKLOCATION, "rb");
|
|
|
|
fseek(fp, dataLocation, SEEK_SET);
|
|
|
|
#else
|
|
|
|
fp = fopen("data/credits.txt", "rb");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
for (int i = 0 ; i < 6 ; i++)
|
|
|
|
{
|
|
|
|
fscanf(fp, "%[^\n]%*c", text);
|
2011-08-26 23:53:46 +02:00
|
|
|
drawString(text, -1, 240 + (i * 20), FONT_WHITE);
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
fscanf(fp, "%d%*c", &numberOfCredits);
|
|
|
|
|
|
|
|
credit = (textObject*) malloc(sizeof(textObject) * numberOfCredits);
|
|
|
|
|
|
|
|
for (int i = 0 ; i < numberOfCredits ; i++)
|
|
|
|
{
|
|
|
|
fscanf(fp, "%d %[^\n]%*c", &yPos, text);
|
2011-08-26 23:53:46 +02:00
|
|
|
credit[i].image = textSurface(text, FONT_WHITE);
|
2011-08-24 14:14:44 +02:00
|
|
|
credit[i].x = (800 - credit[i].image->w) / 2;
|
|
|
|
yPos2 += yPos;
|
|
|
|
credit[i].y = yPos2;
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose(fp);
|
|
|
|
|
2011-08-26 22:48:52 +02:00
|
|
|
if ((engine.useMusic) && (engine.useAudio))
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
|
|
|
Mix_VolumeMusic(100);
|
|
|
|
Mix_PlayMusic(engine.music, 1);
|
|
|
|
}
|
|
|
|
|
2011-08-26 23:53:46 +02:00
|
|
|
updateScreen();
|
2011-08-24 14:14:44 +02:00
|
|
|
SDL_Delay(10000);
|
2011-08-26 23:53:46 +02:00
|
|
|
drawBackGround();
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
engine.done = 0;
|
|
|
|
|
|
|
|
lastCredit = numberOfCredits - 1;
|
|
|
|
|
|
|
|
engine.keyState[SDLK_ESCAPE] = 0;
|
|
|
|
flushInput();
|
|
|
|
|
|
|
|
while (true)
|
|
|
|
{
|
2011-08-26 23:53:46 +02:00
|
|
|
updateScreen();
|
|
|
|
unBuffer();
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
getPlayerInput();
|
|
|
|
if (engine.keyState[SDLK_ESCAPE])
|
|
|
|
break;
|
|
|
|
|
2011-08-27 00:29:23 +02:00
|
|
|
float speed = 0.5;
|
|
|
|
if(engine.keyState[SDLK_DOWN])
|
|
|
|
speed = 2;
|
|
|
|
else if(engine.keyState[SDLK_UP])
|
|
|
|
speed = -2;
|
|
|
|
|
2011-08-24 14:14:44 +02:00
|
|
|
for (int i = 0 ; i < numberOfCredits ; i++)
|
|
|
|
{
|
2011-08-27 00:29:23 +02:00
|
|
|
if ((credit[i].y > -10) && (credit[i].y < 610))
|
2011-08-26 23:53:46 +02:00
|
|
|
blit(credit[i].image, (int)credit[i].x, (int)credit[i].y);
|
2011-08-27 00:29:23 +02:00
|
|
|
if (speed > 0 && credit[lastCredit].y > 400)
|
|
|
|
credit[i].y -= speed;
|
|
|
|
else if(speed < 0 && credit[0].y < 600)
|
|
|
|
credit[i].y -= speed;
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
|
|
|
|
2011-08-26 23:53:46 +02:00
|
|
|
delayFrame();
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0 ; i < numberOfCredits ; i++)
|
|
|
|
{
|
|
|
|
SDL_FreeSurface(credit[i].image);
|
|
|
|
}
|
|
|
|
|
|
|
|
free(credit);
|
|
|
|
}
|
|
|
|
|