Improve resizing behavior of JavaScript game template