class
#include <include/redhand/engine.hpp>
engine This class basically handles all the setup need for games to work.
Contents
Constructors, destructors, conversion operators
Public functions
-
void setConfig(engine_
config conf) - Set the Config of the game engine to the given configuration.
-
auto getConfig() -> engine_
config - Get the current configuration of the engine.
- void init()
- This function initilizes the engine like specified in the configuration.
-
auto changeWorld(std::shared_ptr<complex_
world> newWorld) -> int - change the world to the given new world
-
auto getActiveWorld() -> std::shared_ptr<complex_
world> - Get the Active World object.
- auto getWindow() -> GLFWwindow*
- Get the Window object.
- auto getErrorCode() -> int
- this function returns the error code
- void clearBuffers()
- This functions clears the currently bound buffers.
-
void addGameLoopHandler(std::function<int(redhand::
game_loop_event)> handle) - Add a new game_
loop_ event handler to the engine, to get called every game tick the handler_key is func. -
void addGameLoopHandler(std::function<int(redhand::
game_loop_event)> handle, std::string handler_key) - Add a new game_
loop_ event handler to the engine, to get called every game tick. - auto removeGameLoopHandler(std::string handler_key) -> int
- remove a handler with a given key
- auto runGame() -> int
- This function runs the game, the engine handles all the logic to keep everything wunning for you.
- auto isRunning() -> bool
- returns true if the game is running
- void stopGame(int error = 0)
- stops the game when called
- auto getReference() -> engine&
- Get a reference to the engine object.
Function documentation
void redhand:: engine:: setConfig(engine_ config conf)
Set the Config of the game engine to the given configuration.
engine_ config redhand:: engine:: getConfig()
Get the current configuration of the engine.
Returns | engine_ |
---|
void redhand:: engine:: init()
This function initilizes the engine like specified in the configuration.
int redhand:: engine:: changeWorld(std::shared_ptr<complex_ world> newWorld)
change the world to the given new world
Parameters | |
---|---|
newWorld | a shared pointer to the new world. An error will accour if it is a nullptr. |
Returns | int |
std::shared_ptr<complex_ world> redhand:: engine:: getActiveWorld()
Get the Active World object.
Returns | std::shared_ptr<world> A pointer to the currently active world |
---|
GLFWwindow* redhand:: engine:: getWindow()
Get the Window object.
Returns | GLFWwindow* a pointer to the currently active window |
---|
int redhand:: engine:: getErrorCode()
this function returns the error code
Returns | negative if something bad happened |
---|
void redhand:: engine:: clearBuffers()
This functions clears the currently bound buffers.
void redhand:: engine:: addGameLoopHandler(std::function<int(redhand:: game_loop_event)> handle)
Add a new game_
Parameters | |
---|---|
handle | The function that should handle the game_ |
void redhand:: engine:: addGameLoopHandler(std::function<int(redhand:: game_loop_event)> handle,
std::string handler_key)
Add a new game_
Parameters | |
---|---|
handle | The function that should handle the game_ |
handler_key | A handler_key of your choice except for "". |
int redhand:: engine:: removeGameLoopHandler(std::string handler_key)
remove a handler with a given key
Parameters | |
---|---|
handler_key | the key of the function |
Returns | int 0 if successful -1 if key not found |
int redhand:: engine:: runGame()
This function runs the game, the engine handles all the logic to keep everything wunning for you.
Returns | int negative if something bad happend, otherwise a positive return code |
---|
void redhand:: engine:: stopGame(int error = 0)
stops the game when called
Parameters | |
---|---|
error | the error code which the game should be set to, 0 if none is given. |
engine& redhand:: engine:: getReference()
Get a reference to the engine object.
Returns | engine& the reference to the object (*this) |
---|