2 ms·
I've also been enjoying building My First Game™ in Bevy using ECS. The community around Bevy really shines, but Flecs (https://github.com/SanderMertens/flecs ht
by SeanAnderson 3y ago
I've also been enjoying building My First Game™ in Bevy using ECS. The community around Bevy really shines, but Flecs (https://github.com/SanderMertens/flecs https://github.com/SanderMertens/flecs) is arguably a more mature, open-source ECS implementation (notably, it supports relationships). You don't get to write in Rust, though, which makes it less cool in my book :)
I'm not very proud of the code I've written because I've found writing a game to be much more confusing than building websites + backends, but, as the author notes, it certainly feels more elegant than OOP or globals given the context. I couldn't imagine trying to build a large game using a more rigid organizational approach.
I'm building for WASM and Bevy's parallelism isn't supported in that context (yet? https://github.com/bevyengine/bevy/issues/4078 https://github.com/bevyengine/bevy/issues/4078), so the performance wins are just so-so. Sharing a thread with UI rendering suuucks.
The biggest issues I experience are:
1) How generic should I make my systems? It's easy to make them very specific, but, at a certain specificity, it feels like it's just lazier OOP. More generic and I start spending my time handling edge-cases that don't actually need to exist.
2) Intelligently handling updates when systems run in parallel rather than serially. By default, Bevy runs everything in parallel, and it's heavily encouraged, but my brain finds it a lot easier to just force everything to run serially and to not rely on frame-buffering. This doesn't seem necessarily ECS-specific, though, but is a problem I'm made more aware of due to the defaults given to me.
If anyone wants to browse some code or ask questions, feel free! https://github.com/MeoMix/symbiants https://github.com/MeoMix/symbiants
- meheleventyone 3y ago> How generic should I make my systems? It's easy to make them very specific, but, at a certain specificity, it feels like it's just lazier OOP. More generic and I start spending my time handling edge-cases that don't actually need to exist. Making a game is already hard so my advice is to “make the game” and get specific. Personally it doesn’t matter if you go top-down or bottom-up you really want to go from simple->complex at all levels. Doing this will help structure the game and make it easier to restructure as you go. You can also always generalize later. Managing dependencies is definitely trickier in the parallel ECS context because often you’re naturally inclined to thinking about Entities interacting but systems update across all Entities in a piece-wise manner so it’s very easy to end up with implicit ordering dependencies between systems that cause subtle weirdness in the game when evaluated out of order. Especially when the execution order isn’t fixed. In some respects the Actor model would be a better fit.
- whateveracct 3y ago> parallel feels like this opens up your game to become nondeterministic, right? :/ I consider nondeterminism to be a game logic anti-pattern. I enjoy games that are truly deterministic FSMs that can be understood frame-over-frame.
- SeanAnderson 3y agoYeah, it's non-deterministic by default. They provide some helpers for organization though: https://bevyengine.org/news/bevy-0-10/#base-sets-getting-default-behavior-right https://bevyengine.org/news/bevy-0-10/#base-sets-getting-def...