MenuState.hxx 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #pragma once
  2. #ifndef SNAKE_MENUSTATE_HXX
  3. #define SNAKE_MENUSTATE_HXX
  4. #include "GameState.hxx"
  5. #include "ui/Button.hxx"
  6. #include <optional>
  7. class PlayingState;
  8. class MenuState final : public GameState {
  9. public:
  10. void on_enter(GameStateManager& gsm) override;
  11. void on_leave() override;
  12. void on_event(GameStateManager& gsm, SDL_Event const& evt) override;
  13. void update(GameStateManager& gsm, std::chrono::milliseconds delta_time) override;
  14. void render(SDLRenderer& renderer) override;
  15. private:
  16. static int constexpr ACTIVE_SIZE_DIFF = 8;
  17. static int constexpr BUTTON_HEIGHT = 80;
  18. static int constexpr BUTTON_WIDTH = 350;
  19. Button new_game_button_{"New game", 0, 0, BUTTON_WIDTH, BUTTON_HEIGHT, UiColor::Green};
  20. Button continue_button_{"Continue", 0, 0, BUTTON_WIDTH, BUTTON_HEIGHT, UiColor::Blue};
  21. Button high_score_button_{"High Scores", 0, 0, BUTTON_WIDTH, BUTTON_HEIGHT};
  22. Button credits_button_{"Credits", 0, 0, BUTTON_WIDTH, BUTTON_HEIGHT};
  23. Button quit_button_{"Quit", 0, 0, BUTTON_WIDTH, BUTTON_HEIGHT, UiColor::Red};
  24. std::optional<PlayingState*> game_{};
  25. int active_button_{0};
  26. };
  27. #endif // SNAKE_MENUSTATE_HXX