Hello SFML community.
Like last year, I attended the truly excellent CppCon 2015 conference (Bellevue, WA) and presented two talks.
The video of my first talk, which is heavily oriented towards game development, is now available on the conference’s official YouTube channel:
The talk shows the audience how to write a simple yet powerful C++14 component-based entity system, from scratch.
I use SFML for window/input management and to render simple 2D graphics.
Modern C++ features and idioms are used.
I’ve tried to make the implementation as cache-friendly and data-oriented as possible while maintaining a reasonable level of simplicity.
It is not an AAA framework, but I think I’ve managed to write a small powerful system that shows the benefits and ideas behind a data-oriented ECS.
Choices I’ve made:- Components are logic-less. (They are simple structs.)
- Entities are implicit. (The Entity class is just an ID with some metadata.)
- Components are stored in separate, contiguous arrays. (Every component type has its own array.)
- Systems are implicit. (Entities are matched using “signatures”.)
- Entity metadata is sorted in memory for efficient iteration. Component data is not sorted or “compressed”. (Think about the storage as a relational table, where the columns are the entities and the rows are the component types.)
There are many open-ended questions and possible improvements of this implementation - my goal was showing people how beneficial and convenient a more data-oriented and component-based approach is, and how C++14 makes coding such a system extremely satisfying (thanks to its modern features and cost-free abstractions.)
I’m very open to feedback and would love to hear what you think.
Hope you find the video interesting!
You can find all the material (slides and code) on my GitHub repository:
https://github.com/SuperV1234/cppcon2015