Essential Javascript Code for Canvas Based Desktop and Mobile Game - Not Namespaced