Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   Related Pages  

Details: The Entities

Here you will find some detail about game entities: Entity types, Entity containers and Some warnings.

Entity types

It is likely you'll want entities of different types. In simple cases you can have one entity class, and fiddle with bit flags (like CMyEntity initially does). But there are more complex cases, where you'll want different classes for entities.

The first problem is: base game entity CEntity does not support virtual methods. You can't have them in your derived classes.

The second problem: if entity objects are of different sizes, it's not easy to hold them in fast container (array or pool).

We propose such method: you can have different classes for your entities. Just have them without virtual methods and put their objects into separate containers. Then, while processing entities, you process all the containers separately, hence practically no need for virtual methods. And as different class entities are in different containers, there's no problem with different object sizes.

Entity containers

You'll need to manage your entities somehow, so you'll need some container for them (keep in mind, that entity management is not engine's responsibility). Theoretically, you could have your entities wherever you like, and only register them for rendering via CEntityRenderer.

In practice, because we deal with lots of entities, some simple solutions just don't work:

Remaining possible solutions: Both of these methods don't preserve traversal order of the entities. That is, you are guaranteed to traverse all the entities, but can't be sure of traversal order.

Some warnings

When remove entity from CEntityRenderer, you lose all base CEntity information. In fact, nearly all CEntity methods become invalid and will cause a segmentation fault. If you want to preserve the information - remember it somewhere before removing the entity.


Prev: Details: Using the Grid.
Next: TBD.


Generated on Thu Dec 5 17:27:58 2002 for LT Game Jam Session by doxygen1.2.17