adityaravishankar/command-and-conquer — pull request #64 by Kingsquare (2012-02-01 22:42:56+00:00)
Title: Coding standards

Hi Aditya,

Wow, fantastic job on this game! Really amazing how close it gets to 'the real thing' ;-) . Brings back some good memories... Thanks for that! All we need now is an EVA installer ;-)

I was reading through your blog where you stated you would be interested in turning this more into a 'community project'. I'ld love the idea of that. So, as a start, i was looking through the source and had some ideas.

First of all, i think as a team project there should be some sort of 'coding standard'. Jslint is pretty strict so imho a good starting point. This commit gets the source to comply to this coding standard. (You've made a couple of commits since i checked out and started coding, but i guess it's pretty straightforward for you to re-implement these features, if you like the idea...) A couple of things i fixed along the way:

- Moved 'var' declarations to the top of the functions and remove doubles and added missing ones.
- Fixed indenting, mixed tabs and spaces (that pretty much messed up the 'diff', sorry for that)
- Bugfix in function 'preloadImage' (typ0)
- Added a few todo's , e.g.
- 'Infantery.draw' (function drawSprite doesn't exist?)
- Bugfix in function 'vehicles -> moveTo -> processOrders' (var collDirection doesn't exist?)
- And a few more minor cleanups, no big things...

While scrolling through the code, i had some ideas too i'ld like to share with you:
- What about implementing a nice debugger-console-thingy. This way we can uncomment all alerts() / console.logs(), give them a priority and disable / enable them with a single flag!
- Splitting cnc.js into modules would be nice and give some structure to the code. How about settings up a simple js-loading-mechanism en setup a build process to minify and build releases? Or do you have such a script already? Some node.js script or something?
- And while we're at it, we make it Google Closure compatible to squeeze the last bit of speed outof the browser ;-)
- I did not have enough time yet to look into this, but i have feeling there's pretty much 'code duplication' that could be removed... Are the any quick wins in that, that would make the code more structured too?
- And how about the copyright issues? Any thoughts on that?

Anyway, just interested in your view on this. I love the project and would like to help this to the next step. Can't wait to get the original music back, and how about an online websockets based C&C MMO :-))) Thanks again for your efforts!

Tim