diff --git a/data/translations/text.dat b/data/translations/text.dat index 83fe9f97b..c61c5d944 100644 --- a/data/translations/text.dat +++ b/data/translations/text.dat @@ -180,7 +180,8 @@ eng=GAME OVER eng=CONTINUE? [STR__BACKEND__PRESS_START] eng=PRESS START - +[STR__BACKEND__CONTINUES_REMAINING] +eng=Continues: diff --git a/source/backend/gameover.cpp b/source/backend/gameover.cpp index 740508624..15494d17a 100644 --- a/source/backend/gameover.cpp +++ b/source/backend/gameover.cpp @@ -26,8 +26,8 @@ #include "pad\pads.h" #endif -#ifndef __GAME_GAME_H__ -#include "game\game.h" +#ifndef __MAP_MAP_H__ +#include "map\map.h" #endif #ifndef __FRONTEND_FRONTEND_H__ @@ -54,6 +54,10 @@ #include "locale\textdbase.h" #endif +#ifndef __GAME_GAMESLOT_H__ +#include "game\gameslot.h" +#endif + /* Std Lib ------- */ @@ -108,7 +112,14 @@ void CGameOverScene::init() initContinue(); initGameOver(); - m_state=STATE__CONTINUE; + if(CGameSlotManager::getSlotData()->m_continues>=1) + { + m_state=STATE__CONTINUE; + } + else + { + m_state=STATE__GAME_OVER; + } } @@ -245,7 +256,9 @@ void CGameOverScene::thinkContinue(int _frames) { m_readyToExit=true; CFader::setFadingOut(); - GameState::setNextScene(&GameScene); + GameState::setNextScene(&MapScene); + CGameSlotManager::getSlotData()->m_lives=CGameSlotManager::INITIAL_LIVES; + CGameSlotManager::getSlotData()->m_continues--; m_state=STATE__EXITING_TO_GAME; } else @@ -287,19 +300,19 @@ void CGameOverScene::thinkContinue(int _frames) } void CGameOverScene::renderContinue() { - int yOfs; - char buf[100]; + int yOfs; + char buf[100]; - m_font->setColour(242/2,245/2,15/2); - yOfs=m_continueFontOffset>>2; + m_font->setColour(242/2,245/2,15/2); + yOfs=m_continueFontOffset>>2; - sprintf(buf,TranslationDatabase::getString(STR__BACKEND__CONTINUE)); - m_font->setScale(((msin(m_continueFontSin)*CONTINUE_FONT_SCALE)>>12)+CONTINUE_FONT_BASE_SIZE); - m_font->print(256,50-m_font->getStringHeight(buf)-yOfs,buf); + sprintf(buf,TranslationDatabase::getString(STR__BACKEND__CONTINUE)); + m_font->setScale(((msin(m_continueFontSin)*CONTINUE_FONT_SCALE)>>12)+CONTINUE_FONT_BASE_SIZE); + m_font->print(256,50-m_font->getStringHeight(buf)-yOfs,buf); - sprintf(buf,"%d",m_continueTimer/COUNTDOWN_TIME_SECOND_LENGTH); - m_font->setScale(CONTINUE_FONT_SCALE+CONTINUE_FONT_BASE_SIZE); - m_font->print(256,80-m_font->getStringHeight(buf)-yOfs,buf); + sprintf(buf,"%d",m_continueTimer/COUNTDOWN_TIME_SECOND_LENGTH); + m_font->setScale(CONTINUE_FONT_SCALE+CONTINUE_FONT_BASE_SIZE); + m_font->print(256,80-m_font->getStringHeight(buf)-yOfs,buf); if(!CFader::isFading()) { @@ -310,6 +323,11 @@ void CGameOverScene::renderContinue() m_font->print(256,200-m_font->getStringHeight(buf),buf); } } + + sprintf(buf,"%s%d",TranslationDatabase::getString(STR__BACKEND__CONTINUES_REMAINING),CGameSlotManager::getSlotData()->m_continues); + m_font->setScale(256); + m_font->setColour(100,100,100); + m_font->print(490-(m_font->getStringWidth(buf)/2),210,buf); } @@ -326,19 +344,21 @@ void CGameOverScene::initGameOver() } void CGameOverScene::thinkGameOver(int _frames) { - if(!m_finishedGrowingText) + if(!CFader::isFading()) { - m_gameOverTimer+=_frames; - } - else - { - if(!CFader::isFading()&&!m_readyToExit&& - PadGetDown(0)&(PAD_START|PAD_CROSS)) + if(!m_finishedGrowingText) { - m_readyToExit=true; - CFader::setFadingOut(); - GameState::setNextScene(&FrontEndScene); - m_state=STATE__EXITING_TO_FRONT_END; + m_gameOverTimer+=_frames; + } + else + { + if(!m_readyToExit&&PadGetDown(0)&(PAD_START|PAD_CROSS)) + { + m_readyToExit=true; + CFader::setFadingOut(); + GameState::setNextScene(&FrontEndScene); + m_state=STATE__EXITING_TO_FRONT_END; + } } } } diff --git a/source/frontend/start.cpp b/source/frontend/start.cpp index d4fb50256..3045b550c 100644 --- a/source/frontend/start.cpp +++ b/source/frontend/start.cpp @@ -451,6 +451,8 @@ void CFrontEndStart::think(int _frames) int chapter,level; gameSlot->getHighestLevelOpen(&chapter,&level); CMapScene::setLevelToStartOn(chapter,level); + gameSlot->m_lives=CGameSlotManager::INITIAL_LIVES; + gameSlot->m_continues=CGameSlotManager::INITIAL_CONTINUES; m_state=STATE_EXITING_TO_GAME; CFader::setFadingOut(); CSoundMediator::playSfx(CSoundMediator::SFX_FRONT_END__OK); diff --git a/source/game/game.cpp b/source/game/game.cpp index c2249912f..6fb66d70e 100644 --- a/source/game/game.cpp +++ b/source/game/game.cpp @@ -87,6 +87,10 @@ #include "fma\fma.h" #endif +#ifndef __BACKEND_GAMEOVER_H__ +#include "backend\gameover.h" +#endif + #ifndef __GAME_GAMESLOT_H__ #include "game\gameslot.h" #endif @@ -291,6 +295,7 @@ void CGameScene::render() void CGameScene::render_showing_lives() { int colour; + char buf[20]; POLY_F4 *f4; POLY_FT3 *ft3; @@ -318,7 +323,8 @@ void CGameScene::render_showing_lives() s_genericFont->print(256,50,"Now entering:"); s_genericFont->print(256,80,Level.getChapterLoadingText()); s_genericFont->print(256,100,Level.getLevelLoadingText()); - s_genericFont->print(256,140,"Lives x 5"); + sprintf(buf,"Lives x %d",CGameSlotManager::getSlotData()->m_lives); + s_genericFont->print(256,140,buf); // Black background f4=GetPrimF4(); @@ -641,14 +647,14 @@ void CGameScene::think_playing(int _frames) #endif else if (s_restartLevel) { - if(m_player->getLivesLeft()!=0) + if(m_player->getLivesLeft()>=0) { respawnLevel(); } else { s_readyToExit=true; - GameState::setNextScene(&FrontEndScene); + GameState::setNextScene(&GameOverScene); CFader::setFadingOut(); } s_restartLevel=false; diff --git a/source/game/gameslot.h b/source/game/gameslot.h index 35c292614..2966e31ff 100644 --- a/source/game/gameslot.h +++ b/source/game/gameslot.h @@ -66,8 +66,8 @@ public: typedef struct { unsigned char m_isInUse; - unsigned char m_lives; - unsigned char m_continues; + signed char m_lives; + signed char m_continues; unsigned char m_hasSeenOpeningFMA; unsigned char m_spatulaCollectedCounts[NUM_CHAPTERS*NUM_LEVELS_WITH_SPATULAS]; unsigned char m_kelpTokenCollectedFlags[NUM_CHAPTERS][16]; // Enuf space for 128 tokens per level diff --git a/source/memcard/saveload.h b/source/memcard/saveload.h index 0e1c484cc..ef609004f 100644 --- a/source/memcard/saveload.h +++ b/source/memcard/saveload.h @@ -92,7 +92,7 @@ private: enum { - SAVELOAD_HEADERID=0, + SAVELOAD_HEADERID=1, }; diff --git a/source/player/player.cpp b/source/player/player.cpp index 32b7a59be..693d77682 100644 --- a/source/player/player.cpp +++ b/source/player/player.cpp @@ -626,11 +626,9 @@ m_animFrame=0; setFacing(FACING_RIGHT); m_currentPlayerModeClass=NULL; m_lastModeBeforeDeath=PLAYER_MODE_BASICUNARMED; // Player will then respawn into this mode - m_lives++;respawn(); + respawn(); m_canExitLevel=false; - m_lives=CGameSlotManager::getSlotData()->m_lives; - m_lastPadInput=m_padInput=PI_NONE; s_screenPos=128; @@ -1535,10 +1533,13 @@ int CPlayer::getHeightFromGroundNoPlatform(int _x,int _y,int _maxHeight=32) ---------------------------------------------------------------------- */ void CPlayer::addLife() { - m_lives++; - if(m_lives>MAX_LIVES) + CGameSlotManager::GameSlot *gameSlot; + + gameSlot=CGameSlotManager::getSlotData(); + + if(gameSlot->m_livesm_lives++; } } @@ -1834,8 +1835,6 @@ void CPlayer::respawn() updateCollisionArea(); - m_lives--; - m_ignoreNewlyPressedButtonsOnPadThisThink=true; } @@ -2161,6 +2160,17 @@ void CPlayer::collectedQuestItem() m_currentPlayerModeClass->setState(STATE_CELEBRATE); } +/*---------------------------------------------------------------------- + Function: + Purpose: + Params: + Returns: + ---------------------------------------------------------------------- */ +int CPlayer::getLivesLeft() +{ + return CGameSlotManager::getSlotData()->m_lives; +} + /*---------------------------------------------------------------------- Function: Purpose: @@ -2174,6 +2184,10 @@ void CPlayer::dieYouPorousFreak(DEATH_TYPE _deathType) m_deathType=_deathType; CSoundMediator::playSfx(CSoundMediator::SFX_SPONGEBOB_DEFEATED_JINGLE); setMode(PLAYER_MODE_DEAD); + + // Take a life off.. + CGameSlotManager::getSlotData()->m_lives--; +PAUL_DBGMSG("lives now %d",CGameSlotManager::getSlotData()->m_lives); } diff --git a/source/player/player.h b/source/player/player.h index 3593e4c05..37883c14d 100644 --- a/source/player/player.h +++ b/source/player/player.h @@ -299,7 +299,7 @@ public: int getCanExitLevelNow() {return m_canExitLevel;} void collectedQuestItem(); - int getLivesLeft() {return m_lives;} + int getLivesLeft(); public: @@ -354,7 +354,6 @@ public: DEATH_TYPE getDeathType() {return m_deathType;} private: - int m_lives; int m_numSpatulasHeld; int m_healthWaterLevel; int m_helmetSoundTimer; // Timer for breathing sound when using the helmet