Reader small image

You're reading from  SDL Game Development

Product typeBook
Published inJun 2013
Reading LevelBeginner
PublisherPackt
ISBN-139781849696821
Edition1st Edition
Languages
Tools
Right arrow
Author (1)
Shaun Mitchell
Shaun Mitchell
author image
Shaun Mitchell

Shaun Mitchell is a developer at a high profile online gaming company. He holds a BSc in Game Programming and Development from Qantm College / SAE Institute London. Shaun is also a moderator and active member of the <dream.in.code> programming community.
Read more about Shaun Mitchell

Right arrow

Putting it all together


We can now put all of this knowledge together and implement as much as we can into our framework, with reusability in mind. We have quite a bit of work to do, so let's start with our abstract base class, GameObject. We are going to strip out anything SDL-specific so that we can reuse this class in other SDL projects if needed. Here is our stripped down GameObject abstract base class:

class GameObject
{
public:

  virtual void draw()=0;
  virtual void update()=0;
  virtual void clean()=0;

protected:

  GameObject(const LoaderParams* pParams) {}
  virtual ~GameObject() {}
};

The pure virtual functions have been created, forcing any derived classes to also declare and implement them. There is also now no load function; the reason for this is that we don't want to have to create a new load function for each new project. We can be pretty sure that we will need different values when loading our objects for different games. The approach we will take here is to create a new...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
SDL Game Development
Published in: Jun 2013Publisher: PacktISBN-13: 9781849696821

Author (1)

author image
Shaun Mitchell

Shaun Mitchell is a developer at a high profile online gaming company. He holds a BSc in Game Programming and Development from Qantm College / SAE Institute London. Shaun is also a moderator and active member of the <dream.in.code> programming community.
Read more about Shaun Mitchell