command-and-conquer icon indicating copy to clipboard operation
command-and-conquer copied to clipboard

Split code into multiple files

Open jakemac53 opened this issue 13 years ago • 4 comments

Especially since this is on git and you probably will want to merge changes with other peoples branches (or your own) the main game file should probably be split up into multiple files. This way you won't constantly run into merge conflicts and also it just makes it way easier to go directly to the code you want to edit.

A simple structure would just be like game.js which holds the basic game object and its global properties. Then each unit category can have its own file like vehicles.js, infantry.js. The structure for splitting up the files doesn't matter that much as long as its consistent. Also you can have like mouse.js, sidebar.js, etc...

jakemac53 avatar Jan 24 '12 20:01 jakemac53

That was the plan behind organizing them in separate objects.... The reason they remained in the same file was because it was easier to navigate and to minify.... The plan was to break it out when needed....

adityaravishankar avatar Jan 24 '12 20:01 adityaravishankar

Yeah in my opinion at 4k lines its needed now ;). I guess I don't see a reason not to do it? If a lot of people are working on the code at the same time and they are all editing the same file its going to get pretty unmanageable... Since the objects are already organized pretty well it would be pretty easy to split it up....

jakemac53 avatar Jan 24 '12 20:01 jakemac53

I agree entirely. If it's too much, maybe firstly separate out the units and buildings and other movable parts, then the AI and the UI creation, and your sample skirmish, etc.

cincauhangus avatar Jan 30 '12 19:01 cincauhangus

Not yet... I need to do some reorganizing within the code which is easier
the way it is now...

Will break it out soon though....

adityaravishankar avatar Jan 30 '12 20:01 adityaravishankar