ECS in Python by brianbruggeman
I didn't have much time at all to do anything. So I implemented an Entity Component System that I think is pretty close to what might be needed for someone just getting started with ECS. I think there's room for improvement, and I'll certainly update more later.
| Source | http://learnpythonandmakegames.github.io/ecs |
| Original URL | https://ludumdare.com/compo/ludum-dare-33/?action=preview&uid=34227 |
Ratings
| Coolness | 58% | 3 |
| Fun(Jam) | 1.88 | 1095 |
| Innovation(Jam) | 2.81 | 676 |
Having "factory" classes and that sort of thing isn't very Pythonic. The docstrings are nice but it could do with a few more comments.
I might use this some time and return better feedback, that's just what stood out from skimming the code.
I might
If you want to continue focusing on architecture from a performance angle I recommend thinking about how your system will treat memory allocation as that is the main thing separating "great" entity systems from "good enough" ones; zero runtime allocation is a good goal. If the entity system ends up being worse than just hand-rolling allocation strategies for each piece of data in the game, it loses by default.
Bottom line, though: you will get more done in gamedev, especially in game-jam scenarios, by writing a single large main loop that does everything in a semi-customized fashion. It is inelegant and CS Professors Hate It, but it has the result of making the code more like an art asset - fluid, easy to change, easy to toggle or cut bits out, or make one-off variations.
@xgeovanni - I'll be adding more examples in the near future. Factory is really for fast/simple generation of a component. My first example avoids the use of the factory and uses the Component class a more traditional sense.
@triplefox - My goal was to make the interface easy to understand and use for rapid development. But I appreciate the constraints and considerations you've mentioned.
Next steps seem to be things like adding a serialization engine, visual editor, asset importer, graphics pipeline and all the various parts necessary to support the "drawing system".
Python totally needs better game engines!
I don't use Python for gamedev but I can see this being quite useful, you should work on it and release for the community to use in the next LD. Good job!