Game Object System |
This section describes the game object system provided by the DigitalRune Game library.
A game object is a unit of game logic that manages a part of the game.
For example: An "EnemySoldier" manages the AI, graphics, collision detection, health, etc. of a soldier in a 3D action game. A "Player" object handles the device input and controls the movement of the player.
Traditionally, game objects were created and extended using class inheritance. For example: A class GameObject serves as the base class for all game objects. A class Moveable is derived from GameObject and represents all game objects that can move. The class Enemy derives from Moveable. EnemyTank and EnemySoldier derive from Enemy. And so on. Inheritance-based game object structures can be used for simple games but quickly get unwieldy for non-trivial games with complex inheritance trees or multiple inheritance.
Component-based game object systems have been developed to fight the inherent problems of inheritance-based game object systems. A component-based game object is generic container of components, e.g. a PhysicsComponent, a GraphicsComponent, etc. Game objects communicate using message-passing.
The game object system in the DigitalRune Game library was designed to support both, inheritance-based and component-based systems. The component-based approach is usually used in 2D and 3D games to manage scene objects (players, enemies, level objects, etc.). The inheritance-based approach is, for example, used by the GUI controls in the DigitalRune Game UI library.
To compare with other literature and designs:
The DigitalRune game objects system was built to support the following features:
The following subtopics explain the game object system in more detail.