melonjs/melonJS — pull request #457 by DuckyCrayfish (2014-03-11 06:28:13+00:00)
Title: 1.0.0 dev better structure

This is my first pull request, so please nudge me in the right direction if I'm doing anything wrong D:

Anyways, I noticed that every code segment was wrapped in an anonymous function, whether it was necessary or not. What I have done is gone through each file, and if the function's scope does not have any local variables, I removed the code from the anonymous function. If the function DID contain local variables, I kept the code in it, but removed the unnecessary window argument. (accounts for changes in all src files except new header.js, new footer.js, and core.js. If entire file shows a change, it's most likely an added indentation)

The second thing I did was add a header and footer file, which encapsulates the entire engine in an anonymous function, to which i passed the window variable to, and a safe undefined variable. I also declared "me" as a local variable within this function, so the (many) references to "me" do not have to look through the global scope, which takes longer.

core.js has more changes than the rest of the src files. Within core I rearranged some functions to allow for tighter encapsulations to reduce the amount of local variables needed.

and lastly i added a path variable to the grunt file to organize it better

anyways i hope this won't be too hard to implement! D: