Jump to content
  • Advertisement
Sign in to follow this  

implementing entity component system in current engine...

This topic is 1389 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi All,


Thanks to a lot of help from this forum I have gotten my 'game' to this stage:



Its time to add some enemies and make a proper 'level'. This is where I have been stuck for a while now, because up until here it has been pretty straight forward. There seems to be only really one way to have a general game loop, and to draw some sprites to the screen (I am using directX TK).


So I have been reading about this so called entity component system and it sounds like the way to go from here. What I have absolutely no clue about is how to implement it into my current engine.


In order to test adding ECS to my engine I would like to add what I consider to be a simple example of it: Adding three different enemy types. Each type will appear on screen using a timer, each enemy will have a different color, and a different weapon. My ship too, will have different weapons, selectable with 1-3. Id like my ship and the enemy ships to have health, and weapons to deal different damage.


As it stands now all sprites are an instance of my sprite class, the particle system is its own class particleSys, collision detection is done using a rectangle class, where methods in the rectangle class generate the bounding boxes and then test them for intersection. The map draws from its MapRenderer::draw() method .Apart from that, my game does the usual


update()  handles input(), then each sprite updates() itself




I am extremely confused from here:


What makes up the Entity, components and systems in this example? Are the Entitiys class PlayerShip{}, and class EnemyShip{}. Would their components be something like:


struct shipComponent


    int life;                //Everyone's health

    int projectile;  //Damage each projectile does



Do I keep my current code and then add this ECS system in, or does it require a rewrite of the game engine from scratch? Or can I mix and match sections?


I would greatly appreciate a point in the right direction of how to implement the so called ECS. I am the kind of person who learns a lot more from reading source code too, so any examples of it in place in a small scale game would be interesting to me too. I feel I have read every post on gamedev and S.E on this but really wont fully grasp whats going on until I get down and dirty in some code.


Thanks for your time.

Share this post

Link to post
Share on other sites

Thanks for your replies guys. I will need a bit of time to follow these links and digest this information.


@Jonnie This is the kind of example I needed. And the link your posted does have a very clear description on some of the higher level info I was not understanding.


@BeerNutts That guy in that post sounds exactly what I was struggling with. I will have a read of that topic.


I will post back once I (hopefully) get something in place.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!