How do you deal with the length of your code?

I need to use only 1 scene for my game. I use only 1 cpp file and all my code is inside that file. So it includes 709 lines at the moment and it’s very long. My cpp file is a mess. Sometimes I can’t find what I search for. I wonder how many files do you use for your game? Do you split your code to many files or do you use just 1 file like me?

Thats okay.

No, its not long for all in one cpp coding.

Thats why you should make multiple files, actually depends on game.

Normally 10+ for any game.

I personally make single cpp file for each scene.
And for game-play scene there could be more than 1 cpp files.
Totally depends on game. (OOPS concept)

Hint: for mess in single file, what you can do is collapse all methods in editor, and open only those methods which you are currently writing in it. Also give proper names to methods/variables so it can be easy to understand what it does.
So after that it will be easy for you to search particular code.

1 Like

Hi. 700 lines of code in one cpp is normal.
You need some structure if your project is big.
There is 54 cpp files in my project and some of them have 400 lines of code.
You need to think about structure before development if the project is big enough.

1 Like