Rendu
A lightweight rendering engine for experimentations
Loading...
Searching...
No Matches
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
Game Class Reference

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.
 

Detailed Description

Handles communication between the different game components (renderers, player, menus) and the player actions.

Constructor & Destructor Documentation

◆ Game()

Game::Game ( GameConfig config)
explicit

Constructor

Parameters
configthe shared game configuration

Member Function Documentation

◆ draw()

void Game::draw ( Window window)

Draw the game.

Parameters
windowthe destination window

◆ handleButton()

Window::Action Game::handleButton ( ButtonAction  tag)
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.

Parameters
tagthe action to perform
Returns
the potential low-level action to perform (fullscreen, vsync,...)

◆ physics()

void Game::physics ( double  frameTime)

Update the physic state of the player snake and items

Parameters
frameTimedelta time since last physics update

◆ resize()

void Game::resize ( unsigned int  width,
unsigned int  height 
)

Resize renderers based on new window size.

Parameters
widthnew width
heightnew height

◆ update()

Window::Action Game::update ( )

Perform once-per-frame update (button clicks, key presses).

Returns
If any, the action the windowing system should perform.

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