Modularize the javascript for the game