3 ms·
That is definitly true for your first game. My first game was written in processing, which is a wonderfully visual way of learning to program. Obviously I had a
by atoav 8y ago
That is definitly true for your first game. My first game was written in processing, which is a wonderfully visual way of learning to program. Obviously I had a huge loop with a myriad of nested if statements.
Next thing I did was in Pyglet, this time I used Scene objectes that represented a statemachine that could switch arbitraily between other scene objects. Was much more comfortable to work with but slightly more complex. But where the real difference showed up was when I tried to extend: in the first thing I basically had to have all the code in my head, in the second I could just inherit from the Scene Class and make a new one with completely new rules.
If I were to do something now I would give a ECS a go, especially in Rust which really lends itself to ECS. I don’t think a ECS is any more complicated than relying on Object orientation. The problems you will have to solve with OOP will get incredibly hairy incredibly fast and I say that as someone who came to Rust from a OOP background.
Of course you can just use my first approach and write a huge loop with a lot of if else clauses and deal with every new thing in a new way.
This is the way I’d recommend it to a real beginner, who cares about pixels on the screen and doesn’t mind if they have to rewrite half of the code if they want to change or add a tiny detail.
- meheleventyone 8y agoFWIW I don't think Jon is suggesting an OOP approach either. ECS advocates definitely promote that as the dichotomy though. There are lots of ways to structure game state without having to go the fine grained route.
- pjmlp 8y agoSpecially since many just learned it by doing, instead of reading the OOP literature regarding ECS systems. https://www.amazon.com/Component-Software-Object-Oriented-Programming-Szyperski/dp/B011DCDV40/ref=sr_1_fkmrnull_2 https://www.amazon.com/Component-Software-Object-Oriented-Pr...
- meheleventyone 8y agoECS as meant here though is definitely imperative/functionally structured. Although there is a lot of familial resemblance with other component approaches.
- pjmlp 8y agoSoA and AoS are othorgonal to components implementation.
- emsy 8y agoYou can have a non-ECS system without a giant inlined loop. If you look at an ECS for a typical 2D game what do you need? Components for: Sprites, Animation, Sound, Physics, Scripts, Pathfinding. All of which can be accomplished by function calls split up into separate source files. You can even begin with having everything inlined and pull the code out later once you've figured out what you want to do. ECS is overengineered abstraction to fit the set of all possible use cases instead of your specific use case. And if you write an engine that way you end up with an undebuggable mess of indirection for everything.