aboutsummaryrefslogtreecommitdiff
path: root/src/games/Game.hpp
diff options
context:
space:
mode:
authorfschildt <florian.schildt@protonmail.com>2025-12-11 02:26:56 +0100
committerfschildt <florian.schildt@protonmail.com>2025-12-11 02:56:04 +0100
commit6fffbbed46b903223f752faee7bbb870557665c9 (patch)
tree11c52ccd5fc3a6e3bae142052fa54c49bc6ba853 /src/games/Game.hpp
parent69f46d34e9c6a25c63668423fd984d07c1f099a3 (diff)
refactor Game.hpp, add unfinished pong
Diffstat (limited to 'src/games/Game.hpp')
-rw-r--r--src/games/Game.hpp42
1 files changed, 27 insertions, 15 deletions
diff --git a/src/games/Game.hpp b/src/games/Game.hpp
index 8a44ba9..a97d26c 100644
--- a/src/games/Game.hpp
+++ b/src/games/Game.hpp
@@ -1,5 +1,7 @@
#pragma once
+#include "common/math.hpp"
+
#include <SDL3/SDL.h>
#include <imgui.h>
@@ -13,14 +15,15 @@ public:
no_game,
minesweeper,
snake,
- tetris
+ tetris,
+ pong
};
enum GameStatus {
- game_starting,
- game_resuming,
+ game_start,
+ game_resume,
game_over,
- game_paused,
+ game_pause,
game_exit
};
@@ -36,24 +39,27 @@ public:
static std::unique_ptr<Game> Select(GameType type);
-
-
Game() = default;
virtual ~Game() = default;
- virtual bool Update(std::vector<SDL_Event>& events) = 0;
+ bool Update(std::vector<SDL_Event>& events);
-protected:
- void DrawDefaultGameOverMenu();
- void DrawDefaultGamePausedMenu();
- float ProcessDt();
- uint32_t PushFrameString32(std::u32string&& str);
-
- GameStatus m_game_status {game_starting};
+protected:
+ GameStatus m_game_status {game_start};
float m_dt_remaining_seconds {0.0f};
uint64_t m_tlast_milliseconds {SDL_GetTicks()};
- std::vector<std::u32string> m_frame_strings;
+ Color m_clear_color {0.2f, 0.2f, 0.2f, 1.0f};
+
+
+protected:
+ virtual void Start() = 0;
+ virtual void ProcessEvent(SDL_Event& event) = 0;
+ virtual void FinishUpdate(float dt) = 0;
+ virtual void Draw() = 0;
+
+ virtual void DrawGameStartMenu();
+ virtual void DrawGameOverMenu();
protected:
@@ -62,5 +68,11 @@ protected:
static constexpr ImGuiWindowFlags s_imgui_window_flags_menu = ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_AlwaysAutoResize;
static constexpr ImGuiWindowFlags s_imgui_window_flags_default = ImGuiWindowFlags_NoNav | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoBackground | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoScrollbar;
+
+
+private:
+ void DrawGamePauseMenu();
+ void ProcessEventDuringPause(SDL_Event& event);
+ float ProcessDt();
};