| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- #ifndef __ENGINE_H__
- #define __ENGINE_H__
- #include <SDL2/SDL.h>
- #include <imgui.h>
- #include <imgui_impl_sdl2.h>
- #include <imgui_impl_sdlrenderer2.h>
- #include <entt/entt.hpp>
- #include <sol/sol.hpp>
- #include "EngineConfig.h"
- #include "states/StateManager.h"
- #include <pybind11/embed.h>
- namespace py = pybind11;
- class Engine
- {
- public:
- Engine();
- ~Engine();
- void Run();
-
- // Getters / Setters
- SDL_Renderer* GetRenderer() const { return renderer; }
- SDL_Window* GetWindow() const { return window; }
- bool IsRunning() const { return isRunning; }
- void StopRunning() { isRunning = false; }
-
- // StateManager
- StateManager stateManager;
-
- // Safe State transition
- void RequestStateChange(std::unique_ptr<BaseState> newState);
- void RequestPopState();
-
- private:
- SDL_Window* window = nullptr;
- SDL_Renderer* renderer = nullptr;
- bool isRunning = true;
- SDL_Rect camera = { 0, 0, EngineConfig::DEFAULT_WINDOW_WIDTH, EngineConfig::DEFAULT_WINDOW_HEIGHT };
-
- // General functions
- void InitSDL();
- void InitImGui();
- void InitAudio();
- void HandleEvents();
- void Update(float dt);
- void Render();
- // Python support
- void InitPython();
- void ShutdownPython();
- void RunPythonScript(const std::string& filename);
- std::unique_ptr<py::scoped_interpreter> pythonInterpreter;
- // StateManager
- std::unique_ptr<BaseState> pendingNewState = nullptr;
- bool pendingPop = false;
- };
- #endif
|