The Blank Game
A Blank 2D Game with Sound and Graphics
Public Member Functions | Friends | List of all members
CObject Class Reference

The game object. More...

#include <Object.h>

Inheritance diagram for CObject:
CCommon

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 Protected Attributes inherited from CCommon
static LSpriteRenderer * m_pRenderer = nullptr
 Pointer to renderer.
 
static CObjectManagerm_pObjectManager = nullptr
 Pointer to object manager.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ CObject()

CObject::CObject ( eSprite  t,
const Vector2 &  p 
)

Create an object, given its sprite type and initial position.

Parameters
tType of sprite.
pInitial position of object.

Member Function Documentation

◆ draw()

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.

◆ move()

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.