redhand::engine class

This class basically handles all the setup need for games to work.

Constructors, destructors, conversion operators

engine(char* arg)
The constructor for the engine which constructs the object.
~engine()
The destructor for the engine which cleans everything up.

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_config The current configuration of the 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_loop_event handler to the engine, to get called every game tick the handler_key is func.

Parameters
handle The function that should handle the game_loop_event raised by the engine.

void redhand::engine::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.

Parameters
handle The function that should handle the game_loop_event raised by the engine.
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

bool redhand::engine::isRunning()

returns true if the game is running

Returns true running

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)