diff options
| author | fschildt <florian.schildt@protonmail.com> | 2025-10-06 09:25:04 +0200 |
|---|---|---|
| committer | fschildt <florian.schildt@protonmail.com> | 2025-10-06 09:25:04 +0200 |
| commit | 606d028dac5118329e7561af33b15988db84465f (patch) | |
| tree | 8a5b92b51a88714fee71d7f908283426f70b7dc1 /src/games/snake/Snake.hpp | |
| parent | 7d9500d27fc91356c580e365351ff6e1bc1c95e1 (diff) | |
make everything prettier
Diffstat (limited to 'src/games/snake/Snake.hpp')
| -rw-r--r-- | src/games/snake/Snake.hpp | 50 |
1 files changed, 22 insertions, 28 deletions
diff --git a/src/games/snake/Snake.hpp b/src/games/snake/Snake.hpp index 51d98fb..103255c 100644 --- a/src/games/snake/Snake.hpp +++ b/src/games/snake/Snake.hpp @@ -18,45 +18,39 @@ public: public: Snake(); - bool Update(std::vector<SDL_Event> &events) override; + bool Update(std::vector<SDL_Event>& events) override; private: - void ProcessEventDuringPause(SDL_Event &event); - void ProcessEventDuringResume(SDL_Event &event); + void ProcessEventDuringPause(SDL_Event& event); + void ProcessEventDuringResume(SDL_Event& event); + + void Start(int32_t map_width, int32_t map_height); void MaybeMoveSnake(float dt_in_seconds); void SpawnFood(); void Draw(); - void DoImgui(); - private: - static constexpr int32_t MAX_MAP_WIDTH = 16; - static constexpr int32_t MAX_MAP_HEIGHT = 16; - - bool m_IsPaused; - bool m_IsRunning; - - float m_DtInSecondsRemaining; - uint64_t m_LastMillisecondsSinceT0; - - float m_TilesPerSecond; - Direction m_Direction; - Direction m_LastAdvancedDirection; - - int32_t m_MapWidth; - int32_t m_MapHeight; - int32_t m_Tail; - int32_t m_Head; - uint64_t m_BodyBitmap[MAX_MAP_HEIGHT]; - V2I32 m_BodyPositions[MAX_MAP_WIDTH * MAX_MAP_HEIGHT]; - V2I32 m_FoodPosition; - - std::mt19937 m_Rng; - std::uniform_int_distribution<int32_t> m_Dist; + 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 std::mt19937 s_rng; + std::uniform_int_distribution<int32_t> m_dist; + + Direction m_direction; + Direction m_last_advanced_direction; + + int32_t m_map_width; + int32_t m_map_height; + int32_t m_tail {0}; + int32_t m_head {1}; + uint64_t m_body_bitmap[max_map_height]; + V2I32 m_body_positions[max_map_width * max_map_height]; + V2I32 m_food_position; }; |
