More cleanup.

This commit is contained in:
onpon4 2016-11-25 17:10:08 -05:00
parent 5b4fa64360
commit b43c52dc23
6 changed files with 63 additions and 64 deletions

View File

@ -120,7 +120,7 @@ int main(int argc, char **argv)
gfx_free();
audio_loadSounds();
initWeapons();
weapons_init();
srand(time(NULL));
@ -145,7 +145,7 @@ int main(int argc, char **argv)
switch (section)
{
case 0:
section = doTitle();
section = title_show();
break;
case 1:

View File

@ -177,7 +177,7 @@ void game_init()
stars[i].speed = 1 + (rand() % 3);
}
initWeapons();
weapons_init();
mission_init();
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);
}
/*
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()
{
engine_resetLists();
@ -2437,7 +2488,7 @@ int game_mainLoop()
cutscene_init(6);
break;
case MISN_VENUS:
doCredits();
title_showCredits();
break;
}
@ -2454,7 +2505,7 @@ int game_mainLoop()
}
else
{
gameover();
game_showGameOver();
rtn = 0;
}

View File

@ -188,7 +188,7 @@ static int showCheatMenu()
This is the main title screen, with the stars whirling past and the
"Parallel Realities, Present..." text. Nothing too special.
*/
int doTitle()
int title_show()
{
int continueSaveSlot;
@ -421,7 +421,7 @@ int doTitle()
// if someone has invoked the credits cheat
if (engine.cheatCredits)
{
doCredits();
title_showCredits();
engine.cheatCredits = 0;
}
@ -602,58 +602,7 @@ int doTitle()
return selectedOption;
}
/*
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()
void title_showCredits()
{
gfx_loadBackground("gfx/credits.jpg");
screen_flushBuffer();

View File

@ -20,8 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef TITLE_H
#define TITLE_H
extern int doTitle();
extern void gameover();
extern void doCredits();
int title_show();
void title_showCredits();
#endif

View File

@ -24,7 +24,7 @@ Object weapons[W_MAX];
/*
A list of predefined weaponary.
*/
void initWeapons()
void weapons_init()
{
// Player's weapon (this NEVER allocated to anything else)
weapons[W_PLAYER_WEAPON].id = WT_PLASMA;

View File

@ -22,6 +22,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
extern Object weapons[W_MAX];
extern void initWeapons();
void weapons_init();
#endif