Vigilante Game Framework  1.0.0.8
A 2D/3D C++ Game Framework using SFML.
Public Member Functions | Protected Member Functions | List of all members
VGame Class Reference

The main game class that initialises and cleans up data as well as runs the game loop. More...

#include <VGame.h>

Public Member Functions

int Run (const sf::String &title, VState *initialState, int windowwidth, int windowheight, float fps=60, int flags=sf::Style::Default, const sf::ContextSettings &settings=sf::ContextSettings())
 
int Run (const sf::String &title, VState *initialState, int windowwidth, int windowheight, int screenwidth, int screenheight, float fps=60, int flags=sf::Style::Default, const sf::ContextSettings &settings=sf::ContextSettings())
 

Protected Member Functions

virtual int Init ()
 
virtual void HandleEvents ()
 
virtual void Update (float dt)
 
virtual void PreRender ()
 
virtual void Render (VCamera *camera)
 
virtual void PostRender ()
 
virtual int Cleanup ()
 

Detailed Description

The main game class that initialises and cleans up data as well as runs the game loop.

Member Function Documentation

◆ Cleanup()

virtual int VGame::Cleanup ( )
protectedvirtual

Cleans up any remaining game data, including all global properties. Occurs when the game will shut down.

Returns
An integer returning the result of the cleanup. If 0, there were no errors, else will output the result.

◆ HandleEvents()

virtual void VGame::HandleEvents ( )
protectedvirtual

Handle any polled events in the form of sf::Event objects during the game loop. Some events such as sf::Event::Close and sf::Event::Resize are handled in VGame.

◆ Init()

virtual int VGame::Init ( )
protectedvirtual

Initialises the game, such as setting up the window and initial state for example.

Returns
An integer returning the result of the intialisation. If 0, there were no errors, else will result in the game automatically closing and output the result.

◆ PostRender()

virtual void VGame::PostRender ( )
protectedvirtual

Applies the rendered scene to the window, after applying any post effects currently enabled.

◆ PreRender()

virtual void VGame::PreRender ( )
protectedvirtual

Prepares the game for rendering in the game loop, specifically clearing the current window.

◆ Render()

virtual void VGame::Render ( VCamera camera)
protectedvirtual

Renders the game state, called for each camera currently active in a state.

Parameters
cameraThe current camera object being rendered to.

◆ Run() [1/2]

int VGame::Run ( const sf::String &  title,
VState initialState,
int  windowwidth,
int  windowheight,
float  fps = 60,
int  flags = sf::Style::Default,
const sf::ContextSettings &  settings = sf::ContextSettings() 
)

Runs a new game.

Parameters
titleWindow Title.
initialStateFirst VState object to run the game with. Cannot be NULL.
windowwidthWidth of the Game Window.
windowheightHeight of the Game Window.
fpsFramerate in Frames Per Second.
flagsWindow Style Flags using one or more of the sf::Style flags. Default = Titlebar | Resize | Close
settingsOpenGL Context settings. Default = 0 Depth + 0 Stencil + Version 1.1 + Default Attributes + No sRGB
Returns
An integer returning the result of the game. If 0, there were no errors.

◆ Run() [2/2]

int VGame::Run ( const sf::String &  title,
VState initialState,
int  windowwidth,
int  windowheight,
int  screenwidth,
int  screenheight,
float  fps = 60,
int  flags = sf::Style::Default,
const sf::ContextSettings &  settings = sf::ContextSettings() 
)

Runs a new game.

Parameters
titleWindow Title.
initialStateFirst VState object to run the game with. Cannot be NULL.
windowwidthWidth of the Game Window.
windowheightHeight of the Game Window.
screenwidthWidth of the Game Screen.
screenheightHeight of the Game Screen.
fpsFramerate in Frames Per Second.
flagsWindow Style Flags using one or more of the sf::Style flags. Default = Titlebar | Resize | Close
settingsOpenGL Context settings. Default = 0 Depth + 0 Stencil + Version 1.1 + Default Attributes + No sRGB
Returns
An integer returning the result of the game. If 0, there were no errors.

◆ Update()

virtual void VGame::Update ( float  dt)
protectedvirtual

Runs the update stage of the game loop.

Parameters
dtDelta Time between the previous and current update. Value depends on whether VSync is enabled or not and what the fps value is set to.

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