Wasabi
Public Member Functions | Protected Attributes | List of all members
WGameState Class Reference

#include <WCore.hpp>

Public Member Functions

 WGameState (Wasabi *const a)
 
virtual void Load ()
 
virtual void Update (float fDeltaTime)
 
virtual void OnKeyDown (char c)
 
virtual void OnKeyUp (char c)
 
virtual void OnMouseDown (W_MOUSEBUTTON button, double mx, double my)
 
virtual void OnMouseUp (W_MOUSEBUTTON button, double mx, double my)
 
virtual void OnMouseMove (double mx, double my)
 
virtual void OnInput (char c)
 
virtual void Cleanup ()
 

Protected Attributes

Wasabi *const m_app
 

Detailed Description

This class represents a game state. Game states can be used to completely separate different phases of a game. For example, one can crate a game state for the pre-menu credits, a state for the game menu and a state for the actual game.

States need to be allocated and freed by the user.

Member Function Documentation

◆ Cleanup()

virtual void WGameState::Cleanup ( )
inlinevirtual

This function is called before this state is switched from. This gives the state a chance to clean up its resources before its destroyed.

◆ Load()

virtual void WGameState::Load ( )
inlinevirtual

This function, will be called every time this state is switched to. This gives the state a chance to load its resources.

◆ OnInput()

virtual void WGameState::OnInput ( char  c)
inlinevirtual

This function is called whenever character input is received while this state is active. Character input is supplied by the OS, and is best suitable for capturing input for things like text boxes.

Parameters
c[description]

◆ OnKeyDown()

virtual void WGameState::OnKeyDown ( char  c)
inlinevirtual

This function is called whenever a key is pushed down while this state is active.

Parameters
cThe pushed key

◆ OnKeyUp()

virtual void WGameState::OnKeyUp ( char  c)
inlinevirtual

This function is called whenever a key is released while this state is active.

Parameters
cThe released key

◆ OnMouseDown()

virtual void WGameState::OnMouseDown ( W_MOUSEBUTTON  button,
double  mx,
double  my 
)
inlinevirtual

This function is called whenever a mouse-down is captured while this state is active.

Parameters
buttonMouse button captured
mxMouse X where the event happened
myMouse Y where the event happened

◆ OnMouseMove()

virtual void WGameState::OnMouseMove ( double  mx,
double  my 
)
inlinevirtual

This function is called whenever the mouse moves while this state is active.

Parameters
mxNew mouse X
myNew mouse Y

◆ OnMouseUp()

virtual void WGameState::OnMouseUp ( W_MOUSEBUTTON  button,
double  mx,
double  my 
)
inlinevirtual

This function is called whenever a mouse-down is captured while this state is active.

Parameters
buttonMouse button captured
mxMouse X where the event happened
myMouse Y where the event happened

◆ Update()

virtual void WGameState::Update ( float  fDeltaTime)
inlinevirtual

This function is called every frame (right after Wasabi::Loop()) while the state is active.

Parameters
fDeltaTimeThe step time for this frame (roughly 1 / FPS)

Member Data Documentation

◆ m_app

Wasabi* const WGameState::m_app
protected

Pointer to the application (the Wasabi instance)


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