refactoring game.js to engine.js