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...