Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
SDL Game Development

You're reading from  SDL Game Development

Product type Book
Published in Jun 2013
Publisher Packt
ISBN-13 9781849696821
Pages 256 pages
Edition 1st Edition
Languages
Author (1):
Shaun Mitchell Shaun Mitchell
Profile icon Shaun Mitchell

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 chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}