10#include <SFML/Graphics/RenderWindow.hpp>
22struct _SDL_GameController;
24namespace Imago::Engine
45 bool _isRunning =
false;
46 sf::RenderWindow _window;
47 bool _hasFocus =
true;
50 bool _gamepadReady =
false;
51 _SDL_GameController* _controller =
nullptr;
52 int32_t _controllerId = -1;
81 void poll_gamepad_events();
90 void process_requests();
97 bool try_open_controller(
int index);
102 void close_controller();
107 void adopt_any_controller();
125 Game& operator=(
const Game&) =
delete;
134 template <
typename T>
135 void register_scene(
const std::string& name) { _sceneManager.register_scene<T>(name); }
144 void add_input(
const std::string& action, sf::Keyboard::Scancode scancode);
145 void add_input(
const std::string& action, sf::Mouse::Button button);
146 void add_input(
const std::string& action, GamepadButton button);
153 void add_input(
const std::string& action, GamepadAxis axis,
float deadZone = 0.2f,
float threshold = 0.5f);
Define EngineControl which is the object that the user calls quit and scene change methdos through.
Defines the settings Game is constructed with.
Defines the SceneContext, how systems reach persistent engine objects.
Defines the SceneManager, which is responsible for creating, switching between, and updating Scenes.
The user's only way to talk to the Game from inside a system or Scene load/unload.
Definition EngineControl.hpp:20
void register_scene(const std::string &name)
Registers a Scene type under a name. Simply forwards to its SceneManager.
Definition Game.hpp:135
void add_input(const std::string &action, sf::Keyboard::Scancode scancode)
adds a key press, mouse button, or gamepad button to an action.
Definition Game.cpp:405
Game(const GameConfig &config)
Construct a new Game object, building a new window based on GameSettings and filling in the SceneCont...
Definition Game.cpp:95
~Game()
closes any controllers and quits SDL
Definition Game.cpp:118
ActionId register_action(const std::string &name)
Registers an action name and returns its id. Forwards to the InputHandler.
Definition Game.cpp:400
void run()
Starts config.firstScene and runs the main loop until the game quits.
Definition Game.cpp:338
The manager is the only object that creates, switches, and updates Scenes.
Definition SceneManager.hpp:25
Everything the Game needs to start. Default values for now but will later be filled by a YAML config ...
Definition GameConfig.hpp:17
Gives systems access to the persistent engine objects they could need.
Definition SceneContext.hpp:30