Game Development Reference
In-Depth Information
{
public:
using Pointer = std::shared_ptr< EnemyBase >;
private:
EnemyType m_type;
bool m_alive{ true };
public:
EnemyBase (EnemyType type, const uint32_t serializableId)
: m_type{ type }
, Serializable(serializableId)
{
}
EnemyType GetType() const
{
return m_type;
}
bool IsAlive() const
{
return m_alive;
}
void Kill()
{
m_alive = false;
}
virtual void OnSave(std::ofstream& file)
{
file << m_alive;
}
virtual void OnLoad(std::ifstream& file)
{
file >>m_alive;
}
};
The class isn't pure virtual as we don't actually have any platform-specific code to add as this is an
exercise for illustrative purposes. You can imagine that a proper base class for platform abstraction
would have pure virtual methods that would have platform-specific code added.
The next step is to create three classes for our different platforms. These are shown in Listing 26-6.
Search WWH ::




Custom Search