Entity System with C++

Posted by Dono on Game Development See other posts from Game Development or by Dono
Published on 2012-09-07T15:21:45Z Indexed on 2012/09/07 21:51 UTC
Read the original article Hit count: 475

Filed under:
|
|

I'm working on a game engine using the Entity System and I have some questions.

How I see Entity System :

Components : A class with attributs, set and get.

  1. Sprite
  2. Physicbody
  3. SpaceShip
  4. ...

System : A class with a list of components. (Component logic)

  1. EntityManager
  2. Renderer
  3. Input
  4. Camera
  5. ...

Entity : Just a empty class with a list of components.

What I've done :

Currently, I've got a program who allow me to do that :

// Create a new entity/
Entity* entity = game.createEntity();

// Add some components.
entity->addComponent( new TransformableComponent() )
            ->setPosition( 15, 50 )
            ->setRotation( 90 )
        ->addComponent( new PhysicComponent() )
            ->setMass( 70 )
        ->addComponent( new SpriteComponent() )
            ->setTexture( "name.png" )
            ->addToSystem( new RendererSystem() );

My questions

  1. Did the system stock a list of components or a list of entities ?
  2. In the case where I stock a list of entities, I need to get the component of this entities on each frame, that's probably heavy isn't it ?
  3. Did the system stock a list of components or a list of entities ? In the case where I stock a list of entities, I need to get the component of this entities on each frame, that's probably heavy isn't it ?

© Game Development or respective owner

Related posts about c++

Related posts about architecture