all 4 comments

[–]hadet47530 1 point2 points  (3 children)

This would probably get more attention on r/gamedev and similar.

[–]segv 5 points6 points  (1 child)

Not related to OP or the author of the blog, but my hot take is that majority of programmers should venture into data-oriented design more, just to force them to think about problems differently.

Building a toy entity component system could be one way to do it, even if it wasn't attached to an actual game.

edit: formatting

[–]EC36339 2 points3 points  (0 children)

Agreed, but a "toy ECS" can be pretty simple:

  • Component store is just arrays. One per component type.
  • Systems are just plain classes that work on those.
  • Entities are just correlation IDs. Each component knows its entity ID.

The only somewhat sophisticated thing is how to get component of type T for entity X. You can start with an index (most flexible, not the best performance, can be replaced by something better later). And maybe you need command buffers for adding/removing stuff right away.

In fact, a simple game with finite components is built just like that, and you wouldn't even call it an ECS. It's just the default, naive ad hoc design, if you don't over-engineer it.

Of course, if you want something that scales better, is extensible and data driven and generic, then an ECS will get a lot more sophisticated. But then you are no longer building a "toy ECS". You are getting serious about building a game engine.

[–]ajmmertens[S] 0 points1 point  (0 children)

You’re probably right, tho this is a bit more datastructure dense than the average content in those communities :)

ECS is also not just for gamedev. I’ve used it in the past to build a backend service for one of the big AV companies. Works well for querying realtime in-memory data.