The LARC Game Engine
A Simple Game Engine from the Laboratory for Recreational Computing
Public Member Functions | List of all members
CSprite Class Reference

The sprite. More...

#include <Sprite.h>

Inheritance diagram for CSprite:
CComponent

Public Member Functions

 CSprite (size_t)
 Contructor. More...
 
 ~CSprite ()
 Destructor. More...
 
CTextureDesc & GetTextureDesc (const size_t=0)
 Get texture descriptor. More...
 
const float GetWidth (const UINT=0) const
 Get sprite width. More...
 
const float GetHeight (const UINT=0) const
 Get sprite height. More...
 
void GetSize (const UINT, float &, float &) const
 Get sprite width and height. More...
 
const size_t GetNumFrames () const
 Get number of frames. More...
 

Additional Inherited Members

- Static Protected Attributes inherited from CComponent
static CStepTimer * m_pStepTimer = &cStepTimer
 Pointer to a step timer. More...
 
static CRandom * m_pRandom = &cRandom
 Pointer to a PRNG. More...
 
static CKeyboard * m_pKeyboard = &cKeyboard
 Pointer to a keyboard handler. More...
 
static CXBoxController * m_pController = &cController
 Pointer to a XBox controller. More...
 
static CAudio * m_pAudio = &cAudio
 Pointer to an audio player. More...
 

Detailed Description

A sprite consists of textures for its animation frames and the associated texture information.

Constructor & Destructor Documentation

◆ CSprite()

CSprite::CSprite ( size_t  n)

Create the texture descriptor array.

Parameters
nNumber of animation frames.

◆ ~CSprite()

CSprite::~CSprite ( )

Clean up the texture descriptor array.

Member Function Documentation

◆ GetHeight()

const float CSprite::GetHeight ( const UINT  n = 0) const

Reader function for the height of a frame.

Parameters
nFrame number, assumed to be in range, defaults to zero.
Returns
Height of frame in pixels.

◆ GetNumFrames()

const size_t CSprite::GetNumFrames ( ) const

Reader function for the number of animation frames.

Returns
Number of animation frames.

◆ GetSize()

void CSprite::GetSize ( const UINT  n,
float &  x,
float &  y 
) const

Reader function for the width and height of a frame.

Parameters
n[in] Frame number, assumed to be in range.
x[out] Width of frame in pixels.
y[out] Height of frame in pixels.

◆ GetTextureDesc()

CTextureDesc & CSprite::GetTextureDesc ( const size_t  i = 0)

Reference function for the texture descriptor for an animation frame. Note that the texture descriptor can be modified using the reference returned by this function.

Parameters
iFrame number, defaults to zero.
Returns
Reference to the texture descriptor for frame i.

◆ GetWidth()

const float CSprite::GetWidth ( const UINT  n = 0) const

Reader function for the width of a frame.

Parameters
nFrame number, assumed to be in range, defaults to zero.
Returns
Width of frame in pixels.