CreditsState.hxx 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #pragma once
  2. #ifndef SNAKE_CREDITSSTATE_HXX
  3. #define SNAKE_CREDITSSTATE_HXX
  4. #include "GameState.hxx"
  5. #include "AssetManager.hxx"
  6. #include <variant>
  7. #include <vector>
  8. struct External final {
  9. SDL_Texture* texture_;
  10. char const* text_;
  11. };
  12. class CreditsState final : public GameState {
  13. public:
  14. CreditsState();
  15. void on_enter(GameStateManager& gsm) override;
  16. void on_event(GameStateManager& gsm, SDL_Event const& event) override;
  17. void update(GameStateManager& gsm, std::chrono::milliseconds delta_time) override;
  18. void render(SDLRenderer& renderer) override;
  19. private:
  20. Asset<TTF_Font*> font_;
  21. Asset<SDL_Texture*> jetbrains_ai_logo_;
  22. Asset<SDL_Texture*> kenney_logo_;
  23. Asset<SDL_Texture*> sdl_logo_;
  24. Asset<SDL_Texture*> boost_logo_;
  25. std::vector<std::variant<char const*, External, SDL_Texture*>> scroll_items_{};
  26. double scroll_y_{0.0};
  27. double scroll_size_{0.0};
  28. // this is a hack because we detect being done in render() and use that info in update()
  29. bool done_{false};
  30. };
  31. #endif // SNAKE_CREDITSSTATE_HXX