The entry point into the game. The constructor is used to specify the basic settings such as the size of the drawing area in pixels. Finally, a first game scene can be started via the Run() method.
More...
#include <game.h>
|
void | UpdateMousePosition () const |
| Update virtual mouse position. This becomes necessary because the Raylib function GetMousePosition can no longer work correctly due to the scaling of the graphics output. More...
|
|
void | DrawRenderTexture () const |
| Draws the correctly scaled and, if necessary, letterboxed graphic on the screen. More...
|
|
|
static Vector2 | ClampValue (Vector2 value, Vector2 MIN, Vector2 MAX) |
| Clamp Vector2 value with MIN and MAX and return a new vector2. Required for virtual mouse, to clamp inside virtual game size. More...
|
|
|
int | stage_width_ |
| Width of the game scene (unscaled). Fixed for the entire run time of the game. More...
|
|
int | stage_height_ |
| Height of the game scene (unscaled). Fixed for the entire run time of the game. More...
|
|
bool | audio_ |
| Defines whether the audio device is initialized. More...
|
|
bool | mouse_ |
| Defines if the mouse support should be activated. More...
|
|
RenderTexture2D | render_target_ = { } |
| Temporary render target, which will later be output correctly scaled on the screen. More...
|
|
The entry point into the game. The constructor is used to specify the basic settings such as the size of the drawing area in pixels. Finally, a first game scene can be started via the Run() method.
Definition at line 15 of file game.h.
◆ Game() [1/3]
game::core::Game::Game |
( |
| ) |
|
|
delete |
◆ Game() [2/3]
game::core::Game::Game |
( |
int |
stage_width, |
|
|
int |
stage_height, |
|
|
bool |
full_screen, |
|
|
int |
target_fps, |
|
|
int |
window_flags, |
|
|
int |
exit_key, |
|
|
bool |
mouse, |
|
|
bool |
audio, |
|
|
const char * |
project_name |
|
) |
| |
Constructor.
Create a new Game instance
- Parameters
-
stage_width | Width of the game scene (unscaled). Fixed for the entire run time of the game. |
stage_height | Height of the game scene (unscaled). Fixed for the entire run time of the game. |
full_screen | Start in full screen or window mode. |
target_fps | Target fps, usually 60 fps. |
window_flags | Raylib window flags, preffered: GAME_CONFIG_FLAGS FLAG_WINDOW_RESIZABLE | FLAG_VSYNC_HINT | FLAG_MSAA_4X_HINT |
exit_key | Game exit key. E.g. KEY_ESCAPE. Set it to KEY_NULL if the game app should not stop directly by pressing a key. |
mouse | If true, the mouse position is available in game::core::Store::mouse_position. Please do not use the Raylib function GetMousePosition() which will not wok because of the scaling and letterboxing system. |
audio | If true, Raylib will initialize the audio device. |
project_name | Project name to be displayed as window title in Window mode. |
Definition at line 10 of file game.cpp.
◆ Game() [3/3]
◆ ~Game()
game::core::Game::~Game |
( |
| ) |
|
◆ ClampValue()
Vector2 game::core::Game::ClampValue |
( |
Vector2 |
value, |
|
|
Vector2 |
MIN, |
|
|
Vector2 |
MAX |
|
) |
| |
|
staticprivate |
Clamp Vector2 value with MIN and MAX and return a new vector2. Required for virtual mouse, to clamp inside virtual game size.
Definition at line 83 of file game.cpp.
◆ DrawRenderTexture()
void game::core::Game::DrawRenderTexture |
( |
| ) |
const |
|
private |
Draws the correctly scaled and, if necessary, letterboxed graphic on the screen.
Definition at line 105 of file game.cpp.
◆ operator=()
Game & game::core::Game::operator= |
( |
const Game & |
| ) |
|
|
delete |
◆ Run()
void game::core::Game::Run |
( |
const std::string & |
scene_name, |
|
|
std::unique_ptr< game::core::Scene > |
scene |
|
) |
| const |
Starts the first game scene.
The method creates the main stage object of the game, which is accessible under game::core::Store::stage and transfers the scene object to the stage.
The method also implements the main game loop. In this, the contents of the current game scene are drawn via the stage object game::core::Store::stage.
Furthermore, the method increments the global game counter game::core::Store::ticks and updates the mouse pointer coordinates in game::core::Store::mouse_position if mouse support was enabled when instantiating the game object.
The method is also responsible for correctly scaling the displayed scene and inserting letterboxes if necessary to preserve the aspect ratio.
Definition at line 51 of file game.cpp.
◆ UpdateMousePosition()
void game::core::Game::UpdateMousePosition |
( |
| ) |
const |
|
private |
Update virtual mouse position. This becomes necessary because the Raylib function GetMousePosition can no longer work correctly due to the scaling of the graphics output.
Definition at line 94 of file game.cpp.
◆ audio_
bool game::core::Game::audio_ |
|
private |
Defines whether the audio device is initialized.
Definition at line 65 of file game.h.
◆ mouse_
bool game::core::Game::mouse_ |
|
private |
Defines if the mouse support should be activated.
Definition at line 67 of file game.h.
◆ render_target_
RenderTexture2D game::core::Game::render_target_ = { } |
|
private |
Temporary render target, which will later be output correctly scaled on the screen.
Definition at line 70 of file game.h.
◆ stage_height_
int game::core::Game::stage_height_ |
|
private |
Height of the game scene (unscaled). Fixed for the entire run time of the game.
Definition at line 63 of file game.h.
◆ stage_width_
int game::core::Game::stage_width_ |
|
private |
Width of the game scene (unscaled). Fixed for the entire run time of the game.
Definition at line 61 of file game.h.
The documentation for this class was generated from the following files: