#include #include #include namespace snake::scene { int highScore = 0; bool GameOver::Init() { if (snake::score > highScore) highScore = snake::score; return true; } bool GameOver::Update() { if (IsKeyPressed(KEY_ENTER)) { snake::PlaySFX(snake::Confirm, 1.f); snake::Close(); snake::s = snake::GameMain; snake::Init(); } ClearBackground(BLACK); int fontSize = 24; int textWidth = MeasureText("GAME OVER", fontSize); DrawText("GAME OVER", GetScreenWidth() / 2 - textWidth / 2, GetScreenHeight() / 2 - 30, fontSize, RED); fontSize = 16; const char *score = TextFormat("SCORE: %d", snake::score); textWidth = MeasureText(score, fontSize); DrawText(score, GetScreenWidth() / 2 - textWidth / 2, GetScreenHeight() / 2 + 30, fontSize, RED); const char *hScore = TextFormat("HIGH SCORE: %d", highScore); textWidth = MeasureText(hScore, fontSize); DrawText(hScore, GetScreenWidth() / 2 - textWidth / 2, GetScreenHeight() / 2 + 60, fontSize, RED); textWidth = MeasureText("PRESS ENTER TO TRY AGAIN", fontSize); DrawText("PRESS ENTER TO TRY AGAIN", GetScreenWidth() / 2 - textWidth / 2, GetScreenHeight() / 2 + 90, fontSize, RED); return true; } void GameOver::Close() { } } // namespace snake::scene