More cleanup.
This commit is contained in:
parent
5b4fa64360
commit
b43c52dc23
|
@ -120,7 +120,7 @@ int main(int argc, char **argv)
|
||||||
gfx_free();
|
gfx_free();
|
||||||
audio_loadSounds();
|
audio_loadSounds();
|
||||||
|
|
||||||
initWeapons();
|
weapons_init();
|
||||||
|
|
||||||
srand(time(NULL));
|
srand(time(NULL));
|
||||||
|
|
||||||
|
@ -145,7 +145,7 @@ int main(int argc, char **argv)
|
||||||
switch (section)
|
switch (section)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
section = doTitle();
|
section = title_show();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
|
|
57
src/game.cpp
57
src/game.cpp
|
@ -177,7 +177,7 @@ void game_init()
|
||||||
stars[i].speed = 1 + (rand() % 3);
|
stars[i].speed = 1 + (rand() % 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
initWeapons();
|
weapons_init();
|
||||||
mission_init();
|
mission_init();
|
||||||
intermission_initPlanets(game.system);
|
intermission_initPlanets(game.system);
|
||||||
}
|
}
|
||||||
|
@ -2068,6 +2068,57 @@ int game_collision(float x0, float y0, int w0, int h0, float x2, float y2, int w
|
||||||
return !(x1<x2 || x3<x0 || y1<y2 || y3<y0);
|
return !(x1<x2 || x3<x0 || y1<y2 || y3<y0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
The game over screen :(
|
||||||
|
*/
|
||||||
|
static void game_showGameOver()
|
||||||
|
{
|
||||||
|
screen_flushBuffer();
|
||||||
|
gfx_free();
|
||||||
|
SDL_FillRect(gfx_background, NULL, black);
|
||||||
|
|
||||||
|
engine.keyState[KEY_FIRE] = engine.keyState[KEY_ALTFIRE] = 0;
|
||||||
|
engine.gameSection = SECTION_INTERMISSION;
|
||||||
|
|
||||||
|
SDL_Surface *gameover = gfx_loadImage("gfx/gameover.png");
|
||||||
|
|
||||||
|
screen_clear(black);
|
||||||
|
renderer_update();
|
||||||
|
screen_clear(black);
|
||||||
|
SDL_Delay(1000);
|
||||||
|
|
||||||
|
audio_playMusic("music/death.ogg", -1);
|
||||||
|
|
||||||
|
int x = (screen->w - gameover->w) / 2;
|
||||||
|
int y = (screen->h - gameover->h) / 2;
|
||||||
|
|
||||||
|
renderer_update();
|
||||||
|
|
||||||
|
flushInput();
|
||||||
|
engine.keyState[KEY_FIRE] = engine.keyState[KEY_ALTFIRE] = 0;
|
||||||
|
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
getPlayerInput();
|
||||||
|
|
||||||
|
if (engine.keyState[KEY_FIRE] || engine.keyState[KEY_ALTFIRE])
|
||||||
|
break;
|
||||||
|
|
||||||
|
renderer_update();
|
||||||
|
|
||||||
|
screen_unBuffer();
|
||||||
|
x = ((screen->w - gameover->w) / 2) - RANDRANGE(-2, 2);
|
||||||
|
y = ((screen->h - gameover->h) / 2) - RANDRANGE(-2, 2);
|
||||||
|
screen_blit(gameover, x, y);
|
||||||
|
|
||||||
|
game_delayFrame();
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_FreeSurface(gameover);
|
||||||
|
audio_haltMusic();
|
||||||
|
screen_flushBuffer();
|
||||||
|
}
|
||||||
|
|
||||||
int game_mainLoop()
|
int game_mainLoop()
|
||||||
{
|
{
|
||||||
engine_resetLists();
|
engine_resetLists();
|
||||||
|
@ -2437,7 +2488,7 @@ int game_mainLoop()
|
||||||
cutscene_init(6);
|
cutscene_init(6);
|
||||||
break;
|
break;
|
||||||
case MISN_VENUS:
|
case MISN_VENUS:
|
||||||
doCredits();
|
title_showCredits();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2454,7 +2505,7 @@ int game_mainLoop()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gameover();
|
game_showGameOver();
|
||||||
rtn = 0;
|
rtn = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -188,7 +188,7 @@ static int showCheatMenu()
|
||||||
This is the main title screen, with the stars whirling past and the
|
This is the main title screen, with the stars whirling past and the
|
||||||
"Parallel Realities, Present..." text. Nothing too special.
|
"Parallel Realities, Present..." text. Nothing too special.
|
||||||
*/
|
*/
|
||||||
int doTitle()
|
int title_show()
|
||||||
{
|
{
|
||||||
int continueSaveSlot;
|
int continueSaveSlot;
|
||||||
|
|
||||||
|
@ -421,7 +421,7 @@ int doTitle()
|
||||||
// if someone has invoked the credits cheat
|
// if someone has invoked the credits cheat
|
||||||
if (engine.cheatCredits)
|
if (engine.cheatCredits)
|
||||||
{
|
{
|
||||||
doCredits();
|
title_showCredits();
|
||||||
engine.cheatCredits = 0;
|
engine.cheatCredits = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -602,58 +602,7 @@ int doTitle()
|
||||||
return selectedOption;
|
return selectedOption;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
void title_showCredits()
|
||||||
The game over screen :(
|
|
||||||
*/
|
|
||||||
void gameover()
|
|
||||||
{
|
|
||||||
screen_flushBuffer();
|
|
||||||
gfx_free();
|
|
||||||
SDL_FillRect(gfx_background, NULL, black);
|
|
||||||
|
|
||||||
engine.keyState[KEY_FIRE] = engine.keyState[KEY_ALTFIRE] = 0;
|
|
||||||
engine.gameSection = SECTION_INTERMISSION;
|
|
||||||
|
|
||||||
SDL_Surface *gameover = gfx_loadImage("gfx/gameover.png");
|
|
||||||
|
|
||||||
screen_clear(black);
|
|
||||||
renderer_update();
|
|
||||||
screen_clear(black);
|
|
||||||
SDL_Delay(1000);
|
|
||||||
|
|
||||||
audio_playMusic("music/death.ogg", -1);
|
|
||||||
|
|
||||||
int x = (screen->w - gameover->w) / 2;
|
|
||||||
int y = (screen->h - gameover->h) / 2;
|
|
||||||
|
|
||||||
renderer_update();
|
|
||||||
|
|
||||||
flushInput();
|
|
||||||
engine.keyState[KEY_FIRE] = engine.keyState[KEY_ALTFIRE] = 0;
|
|
||||||
|
|
||||||
while (1)
|
|
||||||
{
|
|
||||||
getPlayerInput();
|
|
||||||
|
|
||||||
if (engine.keyState[KEY_FIRE] || engine.keyState[KEY_ALTFIRE])
|
|
||||||
break;
|
|
||||||
|
|
||||||
renderer_update();
|
|
||||||
|
|
||||||
screen_unBuffer();
|
|
||||||
x = ((screen->w - gameover->w) / 2) - RANDRANGE(-2, 2);
|
|
||||||
y = ((screen->h - gameover->h) / 2) - RANDRANGE(-2, 2);
|
|
||||||
screen_blit(gameover, x, y);
|
|
||||||
|
|
||||||
game_delayFrame();
|
|
||||||
}
|
|
||||||
|
|
||||||
SDL_FreeSurface(gameover);
|
|
||||||
audio_haltMusic();
|
|
||||||
screen_flushBuffer();
|
|
||||||
}
|
|
||||||
|
|
||||||
void doCredits()
|
|
||||||
{
|
{
|
||||||
gfx_loadBackground("gfx/credits.jpg");
|
gfx_loadBackground("gfx/credits.jpg");
|
||||||
screen_flushBuffer();
|
screen_flushBuffer();
|
||||||
|
|
|
@ -20,8 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#ifndef TITLE_H
|
#ifndef TITLE_H
|
||||||
#define TITLE_H
|
#define TITLE_H
|
||||||
|
|
||||||
extern int doTitle();
|
int title_show();
|
||||||
extern void gameover();
|
void title_showCredits();
|
||||||
extern void doCredits();
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -24,7 +24,7 @@ Object weapons[W_MAX];
|
||||||
/*
|
/*
|
||||||
A list of predefined weaponary.
|
A list of predefined weaponary.
|
||||||
*/
|
*/
|
||||||
void initWeapons()
|
void weapons_init()
|
||||||
{
|
{
|
||||||
// Player's weapon (this NEVER allocated to anything else)
|
// Player's weapon (this NEVER allocated to anything else)
|
||||||
weapons[W_PLAYER_WEAPON].id = WT_PLASMA;
|
weapons[W_PLAYER_WEAPON].id = WT_PLASMA;
|
||||||
|
|
|
@ -22,6 +22,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
extern Object weapons[W_MAX];
|
extern Object weapons[W_MAX];
|
||||||
|
|
||||||
extern void initWeapons();
|
void weapons_init();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue