Game Development Reference
In-Depth Information
Any functionality that all game objects should share, regardless of type, could be
placed in this base class. Then we could declare two interfaces, one for drawable
objects and one for updatable objects:
interface
Drawable
function
Draw()
end
interface
Updateable
function
Update (
float
deltaTime
)
end
Once we have these two interfaces, we can then declare our three types of game
objects relative to both the base class and said interfaces:
// Update-only Game Object
class
UGameObject
inherits
GameObject
,
implements
Updateable
// Overload Update function
...
end
// Draw-only Game Object
class
DGameObject
inherits
GameObject
,
implements
Drawable
// Overload Draw function
...
end
// Update and Draw Game Object
class
DUGameObject
inherits
UGameObject
,
implements
Drawable
// Inherit overloaded Update, overload Draw
function
...
end