I'm not sure if this answers your question, but worth mentioning.
If you intend to store game objects in separate lists based on type, you can still write a lot of common logic. Object storage by type has the best better performance due to read and branch prediction. See this lecture from a guy who needs to know what he is talking about: Multiprocessor game cycles: Uncharted 2: Among Thieves lessons .
For example, if you have defined texture
proc for some types of objects, you can write general draw(t: T) = magicRenderToScreen(texture(t))
proc, which will work for all of them. This is also useful if you are really using resource pools or some general behavior.
You need to include any affected type of object in the render and update cycles, but this is usually not very important in practice. You can even use a simple macro to make it less verbose, so your render cycle just contains something like renderAll(players, enemies, sprites, tiles)
Shared lists are not direct in compiled languages, and nim makes you see this, which is good when you are working on a game. To have shared lists, you usually need to use pointers and dynamic dispatch or some type of union. I seem to remember that nim used to send the correct multi-methods from the parent ref object (which would allow lists to contain several types and dynamically send them at runtime), but I'm honestly not sure if this can be done ...?
Someone more knowledgeable, please let us know!
source share