Entity Component System and Map Tiles



  • After listening to podcast 27 and having so many things ECS click in my head I was wondering if you could include a few thoughts on the map tiles and whether they belong in the ECS or not. I’ve read many discussions that advocate both ways and I was curious how you handled it (if you are willing to share).


  • LDG

    Treating your tiles as game entities is almost always going to be a performance hit, in my experience. It’s pretty easy to heavily optimize the rendering and collision of simple tilemaps. Much of that experience came from our HTML5 work where the ceiling for performance is much lower, though.

    It might help to think about it like this: Since one of the primary strengths of ECS is composing entities of simple pieces, how much would your game’s tiles benefit from this system? Are your tiles going to have lots of different properties and behaviors?

    Even when your game requires something like tilemap destruction, I’d still lean towards simple tiles instead of entities. However, if you were making a game like Minecraft, where blocks have a lot of interactivity (switches, rails, power, etc), it starts to sound like a better idea.

    Again, it depends on your game, but in my experience if you can get away with the more simple solution, do so.