Where To Go From Here?
Now that you have a firm understanding of how to make components and systems that use components, converting the rest of the project to the Entity System model is a fairly straightforward port - but time consuming.
It would take forever to explain each step in this tutorial, so instead I have done this for you. Go ahead and download the completed port and check it out. You can also look at the git history that comes with the project to see how I built it up one piece at a time.
Note I'm not convinced this is the most elegant way to do this, but it is a full working example of a simple component based game - which are in rare supply! :]
As I mentioned earlier, if any of you have ideas for how to make this project better, feel free to update the project and send me an updated version! As mentioned earlier, I'll post any alternative versions here so others can learn and benefit.
I hope this article has helped you learn the basics about component based architecture and get some ideas for how you might like to approach it with your games. Remember, the key is to prefer composition over inhertance - how you make that happen is a matter of style and preference! :]
Huge thanks to Adam Martin for tech reviewing this tutorial.
If you have any comments, questions, or suggestions for this tutorial, please join the forum discussion below!
This is a blog post by site administrator Ray Wenderlich, an independent software developer and gamer.