Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Hello 

Im new at game dev i just started studying it in a small period course, and my question is how can i understand code better in order to have more efficient code, right now most of my code is hard coding i would love some advice, as my goal is to get to those AAA companies :)

(1 edit)

First: Good for you! Learning code is ALWAYS a good thing. (I'm really curious what your "small period course" is.)

Second: When it comes to game dev, "hard coding" isn't always a bad thing. (I do it sometimes.) This industry...has a history of "hacking" together code. With the exception of massively multiplayer games, we generally aren't making games that are intended to withstand the test of time. Most games only have a shelf-life of a few months before it ends up in the "budget" bin and everyone has moved on to the next thing. Financially, we are perversely incentivized to NOT have our games last because we can sell "upgraded" or "remastered" versions later.

That said, if you want to be a AAA coder, I recommend getting into a good college. Digipen, MIT, Stanford, USC - that sort of thing. But even a decent state college can teach you what you need to be a better coder. But look for a school that includes both C++ and at least one "scripting" language in their curriculum (python, lua, etc).

As to how to code better, I'd need a bit more detail about where you are in your coding journey. What languages are you using? Do you know the main principles of coding (Variables, loops, conditionals, functions, etc...)? Or are you struggling with things like inheritance and using lists vs queues?

One rule of thumb I will give: generally the only "hard coded" numbers you should ever use are 0,1, & 2.
For any other number, 99.9% of the time you will want to set it as a variable at the top of your class/function.

Example of a bad use of "hard coding" a number:
       for (x=0; x < 150; x++)
Here the number 150 is a "magic number" because it isn't obvious why you wrote it. Maybe that is how many enemies you plan to have on screen. But what if you decide that is too many, or too few? You'll have to search through all your code to find and change the number.

Here's what it should look like:
       max_enemies = 150
       for (x=0; x < max_enemies; x++)
Here you are still using 0 as a starter number for your counter. This is generally fine. But 150 is no longer a "magic number".

Does this mean I NEVER hard code numbers other than 0, 1, or 2? No, I do it sometimes. But 9 out of 10 times, I end up regretting it.

About what i meant by small period course, is basically i enrolled in this 6-7 month course where if I pass it, i'll be accepted to a gaming company as an internship in Tel aviv.


Can we talk somewhere else?