3 ms·
There's something about games as your motivation for learning to code that is quite unfortunate: Games, especially the popular ones, are monstrously difficult t
by lordnacho 6y ago
There's something about games as your motivation for learning to code that is quite unfortunate: Games, especially the popular ones, are monstrously difficult to write.
And I say this as a C++ HFT guy who's written a load of programs for all sorts of other things.
- Games will break your OOP tutorial learnings. If you're starting out with a game, it is gonna get mighty difficult to fit whatever it is into a set of objects. By the time you come around to an ECS, you've probably got a fair bit of experience under your belt.
- A lot of games have a realtime component. So now you need to know about performance, so that you can draw a frame in a few ms. To do that, you need an abstraction of the machine that includes things like cache misses and branch prediction.
- Syntax for c++ is probably the weirdest among common languages, and you need to know it in order to do all the allocations and type safe calls. You'll need a bunch of knowledge about how the thing builds, which also isn't trivial. (Why h files?)
- Games might have 3D graphics. Now you'll need a math course, and a bit of reading about some particular lib.
- Games tend to have multiple abstraction layers. If you need a high performance data structure, you'll have to spend time on writing that while also thinking about the thing you're using it for. You might end up mixing the game logic with your data structure if your thinking is muddled.
- You'll need some artwork. It's not as easy as you might think to come up with some nice colors for your characters. Textures, see 3D graphics.
- Gameplay itself is a huge topic straddling coding, design and culture.
- Want to play with the computer? Game AI is another huge one.
I'm not surprised if 99% of kids who thought they'd learn c++ gave up.
As for my own journey, it tended to be connected to trading. Before I did that, there were moments when I wrote code, including at uni, but they never amounted to a whole that could be used for anything useful. I think having a domain problem helped focus things a lot, in that certain things are prioritized. I still don't know how to do graphics, game AI, and artwork, because trading systems tend not to have those.
Once I got to a comfortable place in terms of skill, I branched out into apps and websites, though I don't consider myself an expert on those. That's also a useful journey, bringing in large areas of experience that I hadn't started with.
- asdfman123 6y agoI was tinkering around in the Minecraft code and man, I have no idea how people use inheritance when designing complex games without completely losing their minds. I know composition vs. inheritance is a nuanced debate, and there are people who can tell me exactly how to do inheritance the right way and why they feel it's better -- but after I learned how much cleaner composition feels I went with it and never seriously looked back.
- imtringued 6y agoI'm not sure what you mean. Subtyping is primarily used for polymorphism. A pretty common mistake is doing polymorphism at the wrong layer but not using polymorphism at all is also a mistake.
- rcxdude 6y agoWhile it's true there's a lot of deep coding that can go into games (especially ones which push the capabilities of the hardware), it's also quite possible with the tools we have to make very successful (and quite good) games with fairly little coding ability. A lot of indie games are a complete trainwreck at the source code level and yet very fun to play. For a good example, see the source code for VVVVVV[0], which is not elegant or high quality C++ code (and it was ported from not particularly elegant ActionScript) but it clearly did the job. [0] https://github.com/TerryCavanagh/VVVVVV https://github.com/TerryCavanagh/VVVVVV