// auto-scale function function resizeGame() { var gameArea = document.getElementById('gameArea'); var gameCanvas = document.getElementById('canvas'); var widthToHeight = 4 / 3; var newWidth = window.innerWidth; var newHeight = window.innerHeight; var newWidthToHeight = newWidth / newHeight;
if (newWidthToHeight > widthToHeight) { newWidth = newHeight * widthToHeight; gameArea.style.height = newHeight + 'px'; gameArea.style.width = newWidth + 'px'; } else { newHeight = newWidth / widthToHeight; gameArea.style.width = newWidth + 'px'; gameArea.style.height = newHeight + 'px'; }
gameArea.style.marginTop = (-newHeight / 2) + 'px'; gameArea.style.marginLeft = (-newWidth / 2) + 'px';
var gameCanvas = document.getElementById('gameCanvas');
//gameCanvas.width = newWidth;
//gameCanvas.height = newHeight;
}
resizeGame();
window.addEventListener('resize', resizeGame, false);
// connect to canvas
var Module = {
TOTAL_MEMORY: 268435456,
filePackagePrefixURL: "Release/",
memoryInitializerPrefixURL: "Release/",
preRun: [],
postRun: [],
print: (function() {
return function(text) {
console.log (text);
};
})(),
printErr: function(text) {
console.error (text);
},
canvas: document.getElementById('canvas'),
progress: null,
setStatus: function(text) {
if (this.progress == null)
{
if (typeof UnityProgress != 'function')
return;
this.progress = new UnityProgress (canvas);
}
if (!Module.setStatus.last) Module.setStatus.last = { time: Date.now(), text: '' };
if (text === Module.setStatus.text) return;
this.progress.SetMessage (text);
var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
if (m)
this.progress.SetProgress (parseInt(m[2])/parseInt(m[4]));
if (text === "")
this.progress.Clear()
},
totalDependencies: 0,
monitorRunDependencies: function(left) {
this.totalDependencies = Math.max(this.totalDependencies, left);
Module.setStatus(left ? 'Preparing... (' + (this.totalDependencies-left) + '/' + this.totalDependencies + ')' : 'All downloads complete.');
}
};
Module.setStatus('Downloading (0.0/1)');