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

A singleton class that holds a lot of global properties other object require. More...

#include <VGlobal.h>

Public Member Functions

void SetTitle (const char *newTitle)
 
void SetTitle (std::string newTitle)
 
const char * GetTitle ()
 
void SetFullscreen (bool set)
 
void ToggleFullscreen ()
 Toggles from fullscreen to window mode.
 
bool IsFullscreen ()
 
bool IsRunning ()
 
sf::Vector2f GetMousePosition ()
 
void SetMouseCursorVisible (bool set)
 
VStateCurrentState ()
 
void ChangeState (VState *state)
 
void PushState (VState *state)
 
void PopState ()
 Pop the current state from the stack.
 
void ClearState ()
 Clear all states from the stack.
 
void Exit ()
 Close window and close out game.
 
bool OverlapAtPoint (const sf::Vector2f &point, VBase *a)
 
bool Overlaps (VBase *a, VBase *b=nullptr, std::function< void(VObject *, VObject *)>const &responseCall=nullptr, std::function< bool(VObject *, VObject *)>const &processCall=nullptr)
 
bool Collides (VBase *a, VBase *b=nullptr, std::function< void(VObject *, VObject *)>const &responseCall=nullptr)
 
bool OverlapCircleAtPoint (const sf::Vector2f &point, VBase *a)
 
bool OverlapsCircle (VBase *a, VBase *b=nullptr, std::function< void(VObject *, VObject *)>const &responseCall=nullptr, std::function< bool(VObject *, VObject *)>const &processCall=nullptr)
 
bool CollidesCircle (VBase *a, VBase *b=nullptr, std::function< void(VObject *, VObject *)>const &responseCall=nullptr)
 

Static Public Member Functions

static VGlobalp ()
 Access and creation of VGlobal.
 
static void Cleanup ()
 Cleans up all data in VGlobal to NULL.
 

Public Attributes

std::unique_ptr< sf::RenderWindow > App
 Window the game is rendered on.
 
sf::RenderStates RenderState
 sf::RenderStates object used for rendering the target to the scene with additional features like transform and blend mode.
 
sf::Vector2f ViewportOffset
 Offset for the main game's viewport, important for the game window being resized and the screen needing to be repositioned in the window.
 
sf::ContextSettings ContextSettings
 The OpenGL Context Settings.
 
bool Antialiasing = false
 Should pixels be smooth or pixellated when the screen is resized?
 
bool VSync = false
 Should the game use Verticle Syncing (where the framerate is based on the monitor refresh rate) instead of the variable framerate?
 
sf::Color BackgroundColor = sf::Color::Black
 Colour of the Window's background prior to rendering.
 
float TimeScale = 1.0f
 Speed of GameTime by manipulating the Delta Time. (e.g. 1 is default speed, 2 is 2x speed)
 
bool FocusPause = true
 Set the game to pause when going out of focus.
 
unsigned int Width = 0
 VGame Area Width (Read Only)
 
unsigned int Height = 0
 VGame Area Height (Read Only)
 
unsigned int WindowWidth = 0
 Width of the game's Window.
 
unsigned int WindowHeight = 0
 Height of the game's Window.
 
sf::FloatRect WorldBounds
 Bounderies of the game world regardless of state. Especially important for collision handling.
 
std::unique_ptr< VMusicMusic
 Allows streamed audio files to be played between states (typically for music).
 
std::unique_ptr< VSoundManagerSound
 Allows loaded audio files to be played between states (typically for sound effects).
 
std::unique_ptr< VContentContent
 Content Management System for handling asset files (i.e. Textures, Fonts ect)
 
std::unique_ptr< VPostEffectBasePostProcess
 PostEffect used for the entire game, applied after the state is drawn.
 
float FPS = 0
 Frames Per Second - used to calculate average framerate.
 
bool IfChangedState = false
 Value is true if the current VState is being changed in the state manager.
 
bool IfPushedState = false
 Value is true if the a new VState is being pushed onto the stack in the state manager.
 
std::unique_ptr< VRandomRandom
 Random Number Generator.
 
std::unique_ptr< VInputHandlerInput
 Input Handling for Keyboard, Mouse and Controllers.
 
std::unique_ptr< VAsyncAsync
 Asynchronous Function Handler for Multithreaded Functionality.
 
int WindowStyle
 Current Window Style being used (set with sf::Style).
 

Detailed Description

A singleton class that holds a lot of global properties other object require.

Member Function Documentation

◆ ChangeState()

void VGlobal::ChangeState ( VState state)
Parameters
stateThe new VState to change to.

◆ Collides()

bool VGlobal::Collides ( VBase a,
VBase b = nullptr,
std::function< void(VObject *, VObject *)>const &  responseCall = nullptr 
)

Test if two objects are colliding by testing an overlap and applying the VObject::separate function as a process call to separate the objects.

Parameters
aThe base object to test overlap with.
bThe other base object to test overlap with. If you only want to test overlap with a itself (like in a VGroup), set this to null.
responseCallAn optional response callback if an overlap is found. Only gets called if an overlap is true.
Returns
Function returns true if an overlap has been found to be true.

◆ CollidesCircle()

bool VGlobal::CollidesCircle ( VBase a,
VBase b = nullptr,
std::function< void(VObject *, VObject *)>const &  responseCall = nullptr 
)

Test if two objects are colliding by testing an overlap with circle overlap testing and applying the VObject::separateCircle function as a process call to separate the objects.

Parameters
aThe base object to test overlap with.
bThe other base object to test overlap with. If you only want to test overlap with a itself (like in a VGroup), set this to null.
responseCallAn optional response callback if an overlap is found. Only gets called if an overlap is true.
Returns
Function returns true if an overlap has been found to be true.

◆ CurrentState()

VState* VGlobal::CurrentState ( )
Returns
The Current Gameplay State.

◆ GetMousePosition()

sf::Vector2f VGlobal::GetMousePosition ( )
Returns
Position of the mouse relative to the game screen (even when resized).

◆ GetTitle()

const char* VGlobal::GetTitle ( )
Returns
The current text on the window's title bar.

◆ IsFullscreen()

bool VGlobal::IsFullscreen ( )
Returns
If the game is in fullscreen mode, function returns true.

◆ IsRunning()

bool VGlobal::IsRunning ( )
Returns
True if the game is running.

◆ OverlapAtPoint()

bool VGlobal::OverlapAtPoint ( const sf::Vector2f &  point,
VBase a 
)

Test if an object is overlapping at a specified point.

Parameters
pointThe position in the game world to test with.
aThe base object to test overlap with.
Returns
True if there is an overlap.

◆ OverlapCircleAtPoint()

bool VGlobal::OverlapCircleAtPoint ( const sf::Vector2f &  point,
VBase a 
)

Test if an object is overlapping at a specified point using circle overlap testing.

Parameters
pointThe position in the game world to test with.
aThe base object to test overlap with.
Returns
True if there is an overlap.

◆ Overlaps()

bool VGlobal::Overlaps ( VBase a,
VBase b = nullptr,
std::function< void(VObject *, VObject *)>const &  responseCall = nullptr,
std::function< bool(VObject *, VObject *)>const &  processCall = nullptr 
)

Test if two objects are overlapping.

Parameters
aThe base object to test overlap with.
bThe other base object to test overlap with. If you only want to test overlap with a itself (like in a VGroup), set this to null.
responseCallAn optional response callback if an overlap is found. Only gets called if an overlap is true.
processCallAn optional process callback if an overlap is found and there is a need to handle further tests and changes to the objects. Only gets called if an overlap is true, and should return true further collision tests are true.
Returns
Function returns true if an overlap has been found to be true.

◆ OverlapsCircle()

bool VGlobal::OverlapsCircle ( VBase a,
VBase b = nullptr,
std::function< void(VObject *, VObject *)>const &  responseCall = nullptr,
std::function< bool(VObject *, VObject *)>const &  processCall = nullptr 
)

Test if two objects are overlapping using circle overlap testing.

Parameters
aThe base object to test overlap with.
bThe other base object to test overlap with. If you only want to test overlap with a itself (like in a VGroup), set this to null.
responseCallAn optional response callback if an overlap is found. Only gets called if an overlap is true.
processCallAn optional process callback if an overlap is found and there is a need to handle further tests and changes to the objects. Only gets called if an overlap is true, and should return true further collision tests are true.
Returns
Function returns true if an overlap has been found to be true.

◆ PushState()

void VGlobal::PushState ( VState state)
Parameters
stateA new VState to push onto the stack to run without changing the current one.

◆ SetFullscreen()

void VGlobal::SetFullscreen ( bool  set)
Parameters
setSet the game to fullscreen mode or not.

◆ SetMouseCursorVisible()

void VGlobal::SetMouseCursorVisible ( bool  set)
Parameters
setSets mouse cursor to be visible or not, depending of if you want an in-game cursor.

◆ SetTitle() [1/2]

void VGlobal::SetTitle ( const char *  newTitle)
Parameters
newTitleThe new text the window should display in the title bar.

◆ SetTitle() [2/2]

void VGlobal::SetTitle ( std::string  newTitle)
Parameters
newTitleThe new text the window should display in the title bar.

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