void Game::onTimeElapsed() { Inventory inventory; inventory.addItem(InventoryItem(SWAP_BONUS_IDENTIFIER, swapRemaining)); inventory.addItem(InventoryItem(CHANGE_BONUS_IDENTIFIER, changeRemaining)); inventory.addItem(InventoryItem(REMOVE_BONUS_IDENTIFIER, removeRemaining)); gameSpice->updateInventory(inventory); auto gameSpice = GameSpice::getInstance(); gameSpice->addFund(Fund(score), [&] (Fund f) {}); gameSpice->getHighScore(GAMESPICE_LEADERBOARD_ID, [&] (HighScore s) { submitScore(); int oldScore = s.getScore(); bool isNewHighScore = score > oldScore; auto scene = isNewHighScore ? NewHighScore::scene() : GameOver::scene(); GameManager::sharedGameManager()->runScene(scene); }); }
void postGame() { PA_PauseMod(1); bool submitted = false; while(!Pad.Newpress.Start && !Stylus.DblClick && !submitted) { PA_ClearTextBg(SCREEN_TOP); PA_OutputSimpleText(SCREEN_TOP,0,0,"GAME OVER"); PA_OutputText(SCREEN_TOP,0,1,"YOUR SCORE: %d", game.score); if(game.score<highscore.points) { PA_OutputText(SCREEN_TOP,0,2,"%s's High Score: %d", highscore.name, highscore.points); PA_OutputSimpleText(SCREEN_TOP,0,4,"Press Start to Play Again"); }else{ PA_OutputText(SCREEN_TOP,0,2,"NEW HIGH SCORE!!!"); highscore.points=game.score; highscore.name=(char*)PA_UserInfo.Name; PA_OutputSimpleText(SCREEN_TOP,0,3,"Press Y To submit score online."); PA_OutputSimpleText(SCREEN_TOP,0,4,"Press Start to Play Again"); if(Pad.Newpress.Y) { PA_OutputSimpleText(SCREEN_TOP,0,5,"Ranking globally..."); // Init Network PA_InitWifi(); if(PA_ConnectWifiWFC()) { submitScore(); getHighScores(); submitted=true; Wifi_DisconnectAP(); }else{ PA_OutputSimpleText(SCREEN_TOP,0,6,"Wifi Connection Failed."); } Wifi_DisableWifi(); } } // Sleep PA_CheckLid(); PA_WaitForVBL(); } }