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
collisions()
render()
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.