adityaravishankar / command-and-conquer

Command & Conquer in HTML5/Javascript
775 stars 168 forks source link

Split code into multiple files #30

Open jakemac53 opened 12 years ago

jakemac53 commented 12 years ago

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...

adityaravishankar commented 12 years ago

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....

jakemac53 commented 12 years ago

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....

cincauhangus commented 12 years ago

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.

adityaravishankar commented 12 years ago

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....