|
Rendu
A lightweight rendering engine for experimentations
|
Handles communication between the different game components (renderers, player, menus) and the player actions. More...
#include <Game.hpp>
Public Member Functions | |
| Game (GameConfig &config) | |
| void | draw (Window &window) |
| Window::Action | update () |
| void | physics (double frameTime) |
| void | resize (unsigned int width, unsigned int height) |
Private Types | |
| enum class | Status { MAINMENU , INGAME , PAUSED , DEAD , OPTIONS } |
| Game state: either a specific menu or in-game. | |
| enum | ButtonAction : int { NEWGAME , OPTIONS , QUIT , PAUSE , RESUME , BACKTOMENU , OPTION_FULLSCREEN , OPTION_VSYNC , OPTION_HALFRES } |
| Action that can be performed by pressing a button or a key. | |
Private Member Functions | |
| Window::Action | handleButton (ButtonAction tag) |
Private Attributes | |
| GameConfig & | _config |
| Reference to the shared game configuration. | |
| std::unique_ptr< Player > | _player |
| The player state. | |
| GameRenderer | _inGameRenderer |
| In-game renderer. | |
| GameMenuRenderer | _menuRenderer |
| Menus renderer. | |
| std::unique_ptr< GaussianBlur > | _bgBlur |
| Blurring pass for the paused/dead menus background. | |
| Texture | _gameResult |
| Game scene texture. | |
| Texture | _bgBlurTexture |
| Blurred game scene texture. | |
| Program * | _finalProgram |
| Final upscaling program. | |
| Status | _status = Status::MAINMENU |
| Current game sattus (specific menu or in-game) | |
| std::map< Status, GameMenu > | _menus |
| Menus for each game status. | |
| double | _playTime = 0.0 |
| Current playtime. | |
| bool | _overrideTime = false |
| Debug pause. | |
Handles communication between the different game components (renderers, player, menus) and the player actions.
|
explicit |
Constructor
| config | the shared game configuration |
| void Game::draw | ( | Window & | window | ) |
Draw the game.
| window | the destination window |
|
private |
For a given button action tag, perform the corresponding internal operations and indicates if any low-level action should be performed by the windowing system/hardware.
| tag | the action to perform |
| void Game::physics | ( | double | frameTime | ) |
Update the physic state of the player snake and items
| frameTime | delta time since last physics update |
| void Game::resize | ( | unsigned int | width, |
| unsigned int | height | ||
| ) |
Resize renderers based on new window size.
| width | new width |
| height | new height |
| Window::Action Game::update | ( | ) |
Perform once-per-frame update (button clicks, key presses).