ST_engine  0.3-ALPHA
Public Member Functions | Public Attributes | List of all members
game_manager Class Reference

This class is responsible for managing all levels and the lua backend, it is the heart of the engine. More...

#include <game_manager.hpp>

Public Member Functions

 game_manager (message_bus &msg_bus)
 
 ~game_manager ()
 
std::string get_active_level () const
 
bool key_pressed (uint16_t arg) const
 
bool key_held (uint16_t arg) const
 
bool key_released (uint16_t arg) const
 
int32_t get_mouse_x () const
 
int32_t get_mouse_y () const
 
int16_t get_left_trigger () const
 
int16_t get_right_trigger () const
 
int16_t get_left_stick_horizontal () const
 
int16_t get_left_stick_vertical () const
 
int16_t get_right_stick_vertical () const
 
int16_t get_right_stick_horizontal () const
 
void update ()
 
bool game_is_running () const
 
ST::levelget_level () const
 
void center_camera_on_entity (uint64_t id)
 
uint16_t get_window_width () const
 
uint16_t get_window_height () const
 
uint16_t get_internal_width () const
 
uint16_t get_internal_height () const
 
void save_state (const std::string &filepath)
 
 game_manager (message_bus *msg_bus, task_manager *tsk_mngr)
 
std::string get_active_level () const
 
ST::levelget_level ()
 
bool key_pressed (size_t arg) const
 
bool key_held (size_t arg) const
 
bool key_released (size_t arg) const
 
int32_t get_mouse_x () const
 
int32_t get_mouse_y () const
 
void update ()
 
bool game_is_running () const
 
void center_camera_on_entity (uint64_t id)
 
int16_t get_left_trigger () const
 
int16_t get_right_trigger () const
 
int16_t get_left_stick_horizontal () const
 
int16_t get_left_stick_vertical () const
 
int16_t get_right_stick_vertical () const
 
int16_t get_right_stick_horizontal () const
 
void save_state (const std::string &filepath)
 
uint16_t get_internal_width () const
 
uint16_t get_internal_height () const
 
uint16_t get_window_width () const
 
uint16_t get_window_height () const
 

Public Attributes

bool vsync_flag = true
 
bool fullscreen_status = false
 
uint8_t music_volume_level = 100
 
uint8_t sounds_volume_level = 100
 
bool audio_enabled = true
 
int8_t gravity = 0
 
uint8_t get_level_calls = 0
 
uint8_t center_camera_on_entity_calls = 0
 

Detailed Description

This class is responsible for managing all levels and the lua backend, it is the heart of the engine.

MOCK: contained in game_manager_mock.hpp This is a mock class of the game_manager. It contains the exact same function definitions as the real game_manager, but not the implementations. This is need to properly test the lua_backend. GMock is not used as it requires to use virtual methods (interfaces) to create mocks. We assume that this mock contains the same definitions as the real thing, but this is not checked anywhere and is done per hand. (A compile time error will occur if a method/attribute is not found, but things like wrong data types in the method arguments may not be noticed easily).

Definition at line 20 of file game_manager.hpp.

Constructor & Destructor Documentation

◆ game_manager()

game_manager::game_manager ( message_bus gMessageBus)
explicit

initializes the game_manager and loads the level specified as first ("main" is default)

Parameters
msg_busA pointer to the global message bus.
tsk_mngrA pointer to the global task_mngr.

Definition at line 23 of file game_manager.cpp.

◆ ~game_manager()

game_manager::~game_manager ( )

Closes the game manager and the lua backend.

Definition at line 308 of file game_manager.cpp.

Member Function Documentation

◆ center_camera_on_entity()

void game_manager::center_camera_on_entity ( uint64_t  id)

Center the camera on an entity.

Parameters
idThe ID of the entity to center on.

Definition at line 360 of file game_manager.cpp.

◆ game_is_running()

bool game_manager::game_is_running ( ) const

Tells is if the game is still running or not. This is the main condition for running the main loop (the entire engine).

Returns
True if running, false otherwise.

Definition at line 438 of file game_manager.cpp.

◆ get_active_level()

std::string game_manager::get_active_level ( ) const

Get the name of the active level.

Returns
The name of the current level.

Definition at line 415 of file game_manager.cpp.

◆ get_internal_height()

uint16_t game_manager::get_internal_height ( ) const
Returns
The internal rendering height.

Definition at line 590 of file game_manager.cpp.

◆ get_internal_width()

uint16_t game_manager::get_internal_width ( ) const
Returns
The internal rendering width.

Definition at line 583 of file game_manager.cpp.

◆ get_left_stick_horizontal()

int16_t game_manager::get_left_stick_horizontal ( ) const
Returns
The value of the left analog stick horizontal axis on a controller

Definition at line 331 of file game_manager.cpp.

◆ get_left_stick_vertical()

int16_t game_manager::get_left_stick_vertical ( ) const
Returns
The value of the left analog stick vertical axis on a controller

Definition at line 338 of file game_manager.cpp.

◆ get_left_trigger()

int16_t game_manager::get_left_trigger ( ) const
Returns
The value of the left trigger button on a controller

Definition at line 317 of file game_manager.cpp.

◆ get_level()

ST::level * game_manager::get_level ( ) const
Returns
A pointer to the current level.

Definition at line 429 of file game_manager.cpp.

◆ get_mouse_x()

int32_t game_manager::get_mouse_x ( ) const

Get the current mouse X position.

Returns
The X position of the mouse cursor.

Definition at line 446 of file game_manager.cpp.

◆ get_mouse_y()

int32_t game_manager::get_mouse_y ( ) const

Get the current mouse Y position.

Returns
The Y position of the mouse cursor.

Definition at line 454 of file game_manager.cpp.

◆ get_right_stick_horizontal()

int16_t game_manager::get_right_stick_horizontal ( ) const
Returns
The value of the right analog stick horizontal axis on a controller

Definition at line 352 of file game_manager.cpp.

◆ get_right_stick_vertical()

int16_t game_manager::get_right_stick_vertical ( ) const
Returns
The value of the right analog stick vertical axis on a controller

Definition at line 345 of file game_manager.cpp.

◆ get_right_trigger()

int16_t game_manager::get_right_trigger ( ) const
Returns
The value of the right trigger button on a controller

Definition at line 324 of file game_manager.cpp.

◆ get_window_height()

uint16_t game_manager::get_window_height ( ) const
Returns
The height of the game window.

Definition at line 576 of file game_manager.cpp.

◆ get_window_width()

uint16_t game_manager::get_window_width ( ) const
Returns
The width of the game window.

Definition at line 569 of file game_manager.cpp.

◆ key_held()

bool game_manager::key_held ( uint16_t  arg) const

Tells if a key corresponding to a certain action has been held.

Parameters
argA hash of the name of the action.
Returns
True if held, false otherwise.

Definition at line 477 of file game_manager.cpp.

◆ key_pressed()

bool game_manager::key_pressed ( uint16_t  arg) const

Tells if a key corresponding to a certain action has been pressed.

Parameters
argA hash of the name of the action.
Returns
True if pressed, false otherwise.

Definition at line 463 of file game_manager.cpp.

◆ key_released()

bool game_manager::key_released ( uint16_t  arg) const

Tells if a key corresponding to a certain action has been released.

Parameters
argA hash of the name of the action.
Returns
True if released, false otherwise.

Definition at line 491 of file game_manager.cpp.

◆ update()

void game_manager::update ( )

Listens to messages and runs one iteration of loop.lua for the specific level.

Definition at line 406 of file game_manager.cpp.


The documentation for this class was generated from the following files: