![]() |
The Blank Game
A Blank 2D Game with Sound and Graphics
|
The game object. More...
#include <Object.h>
Public Member Functions | |
CObject (eSprite, const Vector2 &) | |
Constructor. More... | |
void | move () |
Move object. More... | |
void | draw () |
Draw object. More... | |
Friends | |
class | CObjectManager |
Object manager needs access so it can manage. | |
Additional Inherited Members | |
![]() | |
static LSpriteRenderer * | m_pRenderer = nullptr |
Pointer to renderer. | |
static CObjectManager * | m_pObjectManager = nullptr |
Pointer to object manager. | |
The abstract representation of an object. CObjectManager
is a friend of this class so that it can access any private members as needed to manage the objects without the need for reader and set functions for each private or protected member variable. This class must contain public member functions move()
and draw()
to move and draw the object, respectively.
CObject::CObject | ( | eSprite | t, |
const Vector2 & | p | ||
) |
Create an object, given its sprite type and initial position.
t | Type of sprite. |
p | Initial position of object. |
void CObject::draw | ( | ) |
Ask the renderer to draw the sprite described in the sprite descriptor. Note that CObject
is derived from LBaseObject
which is inherited from LSpriteDesc2D
. Therefore LSpriteRenderer::Draw(const LSpriteDesc2D*)
will accept this
as a parameter, automatically down-casting it from CObject*
to LSpriteDesc2D*
, effectively drawing the object from its sprite descriptor.
void CObject::move | ( | ) |
The only object in this game is the text wheel, which slowly rotates at 1/8 revolutions per second. This is achieved by adding a small amount to its roll angle, proportional to frame time.