Ned's Turkey Farm
A Simple 2.5D Side Scroller
Loading...
Searching...
No Matches
CCommon Class Reference

The common variables class. More...

#include <Common.h>

Inheritance diagram for CCommon:
Collaboration diagram for CCommon:

Public Member Functions

float Wrap (float)
 Wrap horizontal distance.
 

Static Protected Attributes

static CRendererm_pRenderer = nullptr
 Pointer to the renderer.
 
static CObjectManagerm_pObjectManager = nullptr
 Pointer to the object manager.
 
static CPlaneObjectm_pPlayer = nullptr
 Pointer to player character.
 
static float m_fWorldScale = 2.0f
 World scale.
 
static Vector3 m_vCellSize = Vector3::Zero
 Cell size.
 
static UINT m_nNumCells = 3
 Number of cells.
 
static float m_fWorldWidth = 0.0f
 World width.
 
static eDrawMode m_eDrawMode = eDrawMode::Playing
 Draw mode.
 
static eGameState m_eGameState = eGameState::Loading
 Game state.
 

Detailed Description

CCommon is a singleton class that encapsulates things that are common to different game components, including game state variables. Making it a singleton class means that we can avoid passing its member variables around as parameters, which makes the code minisculely faster, and more importantly, makes the code more readable by reducing function clutter.

Member Function Documentation

◆ Wrap()

float CCommon::Wrap ( float x)

Wrap a horizontal distance to plus or minus half the world width. This will be used to normalize the distances from various objects to the plane.

Parameters
xHorizontal distance.
Returns
Horizontal distance normalized to half the world width.
Here is the caller graph for this function: