From b43c52dc23ba48fa115ce784516ec51d93c138e2 Mon Sep 17 00:00:00 2001 From: onpon4 Date: Fri, 25 Nov 2016 17:10:08 -0500 Subject: [PATCH] More cleanup. --- src/Starfighter.cpp | 4 ++-- src/game.cpp | 57 ++++++++++++++++++++++++++++++++++++++++++--- src/title.cpp | 57 +++------------------------------------------ src/title.h | 5 ++-- src/weapons.cpp | 2 +- src/weapons.h | 2 +- 6 files changed, 63 insertions(+), 64 deletions(-) diff --git a/src/Starfighter.cpp b/src/Starfighter.cpp index 12bdcb4..92172c1 100644 --- a/src/Starfighter.cpp +++ b/src/Starfighter.cpp @@ -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: diff --git a/src/game.cpp b/src/game.cpp index 097b983..e639ff3 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -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 !(x1w - 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; } diff --git a/src/title.cpp b/src/title.cpp index 9b0dde4..dd5e694 100644 --- a/src/title.cpp +++ b/src/title.cpp @@ -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(); diff --git a/src/title.h b/src/title.h index 8d56d63..55a853f 100644 --- a/src/title.h +++ b/src/title.h @@ -20,8 +20,7 @@ along with this program. If not, see . #ifndef TITLE_H #define TITLE_H -extern int doTitle(); -extern void gameover(); -extern void doCredits(); +int title_show(); +void title_showCredits(); #endif diff --git a/src/weapons.cpp b/src/weapons.cpp index 681e981..d300bf2 100644 --- a/src/weapons.cpp +++ b/src/weapons.cpp @@ -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; diff --git a/src/weapons.h b/src/weapons.h index 17d72c1..dd60fb7 100644 --- a/src/weapons.h +++ b/src/weapons.h @@ -22,6 +22,6 @@ along with this program. If not, see . extern Object weapons[W_MAX]; -extern void initWeapons(); +void weapons_init(); #endif