FlappyBug: Persist high score to disk

Previously, the high score was only in-memory, so only persisted for as
long as the FlappyBug window was open.
This commit is contained in:
Timothy Flynn 2021-06-22 10:50:54 -04:00 committed by Andreas Kling
commit 1a2053781f
Notes: sideshowbarker 2024-07-18 11:38:33 +09:00
3 changed files with 30 additions and 5 deletions

View file

@ -27,9 +27,9 @@ void Game::reset()
void Game::game_over()
{
if (m_highscore.value_or(0) < m_difficulty) {
m_highscore = m_difficulty;
}
if (on_game_end)
m_highscore = on_game_end(static_cast<u32>(m_difficulty));
reset();
}