From ebe4a92027aabc9c01caf0fbe791d22773abfe75 Mon Sep 17 00:00:00 2001 From: fschildt Date: Sat, 13 Dec 2025 04:12:10 +0100 Subject: snake: add score/highscore --- src/games/snake/Snake.hpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/games/snake/Snake.hpp') diff --git a/src/games/snake/Snake.hpp b/src/games/snake/Snake.hpp index 81fd30f..0303238 100644 --- a/src/games/snake/Snake.hpp +++ b/src/games/snake/Snake.hpp @@ -2,6 +2,7 @@ #include "games/Game.hpp" #include "common/math.hpp" +#include "common/Font.hpp" #include @@ -29,18 +30,23 @@ private: void MaybeMoveSnake(float dt_in_seconds); void SpawnFood(); + void HandleGameOver(); + private: static constexpr int32_t max_map_width = 16; static constexpr int32_t max_map_height = 16; static constexpr float tiles_per_second = 4.0f; + static constexpr char highscore_path[] = "snake_highscore.txt"; + + Font m_font; static std::mt19937 s_rng; std::uniform_int_distribution m_dist; - int32_t m_starting_map_width = 16; - int32_t m_starting_map_height = 16; + int32_t m_starting_map_width = 12; + int32_t m_starting_map_height = 12; Direction m_direction; Direction m_last_advanced_direction; @@ -52,6 +58,9 @@ private: uint64_t m_body_bitmap[max_map_height]; V2I32 m_body_positions[max_map_width * max_map_height]; V2I32 m_food_position; + + int32_t m_score; + int32_t m_highscore; }; -- cgit v1.2.3