new file: Files/flashplayer_32_sa.exe new file: favicon.ico new file: globe.gif new file: imgs/download.png new file: imgs/zuck.jpg new file: index.html new file: other.ico new file: script.js new file: site.webmanifest new file: sitemap.html new file: styles/backround.css new file: styles/border.css new file: styles/fonts/Titillium_Web/OFL.txt new file: styles/fonts/Titillium_Web/TitilliumWeb-Black.ttf new file: styles/fonts/Titillium_Web/TitilliumWeb-Bold.ttf new file: styles/fonts/Titillium_Web/TitilliumWeb-BoldItalic.ttf new file: styles/fonts/Titillium_Web/TitilliumWeb-ExtraLight.ttf new file: styles/fonts/Titillium_Web/TitilliumWeb-ExtraLightItalic.ttf new file: styles/fonts/Titillium_Web/TitilliumWeb-Italic.ttf new file: styles/fonts/Titillium_Web/TitilliumWeb-Light.ttf new file: styles/fonts/Titillium_Web/TitilliumWeb-LightItalic.ttf new file: styles/fonts/Titillium_Web/TitilliumWeb-Regular.ttf new file: styles/fonts/Titillium_Web/TitilliumWeb-SemiBold.ttf new file: styles/fonts/Titillium_Web/TitilliumWeb-SemiBoldItalic.ttf new file: styles/fonts/webfontkit-20221027-163353/generator_config.txt new file: styles/fonts/webfontkit-20221027-163353/specimen_files/grid_12-825-55-15.css new file: styles/fonts/webfontkit-20221027-163353/specimen_files/specimen_stylesheet.css new file: styles/fonts/webfontkit-20221027-163353/stylesheet.css new file: styles/fonts/webfontkit-20221027-163353/titilliumweb-extralight-demo.html new file: styles/fonts/webfontkit-20221027-163353/titilliumweb-extralight-webfont.woff new file: styles/fonts/webfontkit-20221027-163353/titilliumweb-extralight-webfont.woff2 new file: styles/fonts/webfontkit-20221027-165950/generator_config.txt new file: styles/fonts/webfontkit-20221027-165950/specimen_files/grid_12-825-55-15.css new file: styles/fonts/webfontkit-20221027-165950/specimen_files/specimen_stylesheet.css new file: styles/fonts/webfontkit-20221027-165950/stylesheet.css new file: styles/fonts/webfontkit-20221027-165950/titilliumweb-bold-demo.html new file: styles/fonts/webfontkit-20221027-165950/titilliumweb-bold-webfont.woff new file: styles/fonts/webfontkit-20221027-165950/titilliumweb-bold-webfont.woff2 new file: styles/style.css new file: tools/2048/.gitignore new file: tools/2048/.jshintrc new file: tools/2048/CONTRIBUTING.md new file: tools/2048/LICENSE.txt new file: tools/2048/README.md new file: tools/2048/Rakefile new file: tools/2048/favicon.ico new file: tools/2048/index.html new file: tools/2048/js/animframe_polyfill.js new file: tools/2048/js/application.js new file: tools/2048/js/bind_polyfill.js new file: tools/2048/js/classlist_polyfill.js new file: tools/2048/js/game_manager.js new file: tools/2048/js/grid.js new file: tools/2048/js/html_actuator.js new file: tools/2048/js/keyboard_input_manager.js new file: tools/2048/js/local_storage_manager.js new file: tools/2048/js/tile.js new file: tools/2048/meta/apple-touch-icon.png new file: tools/webretro/cores/neocd_libretro.js new file: tools/webretro/cores/neocd_libretro.wasm new file: tools/webretro/cores/nestopia_libretro.js new file: tools/webretro/cores/nestopia_libretro.wasm new file: tools/webretro/cores/o2em_libretro.js new file: tools/webretro/cores/o2em_libretro.wasm new file: tools/webretro/cores/opera_libretro.js new file: tools/webretro/cores/opera_libretro.wasm
145 lines
4.8 KiB
JavaScript
145 lines
4.8 KiB
JavaScript
(function () {
|
|
var CANVAS_ID = 'application-canvas';
|
|
|
|
var canvas, devices, app;
|
|
|
|
var createCanvas = function () {
|
|
canvas = document.createElement('canvas');
|
|
canvas.setAttribute('id', CANVAS_ID);
|
|
canvas.setAttribute('tabindex', 0);
|
|
// canvas.style.visibility = 'hidden';
|
|
|
|
// Disable I-bar cursor on click+drag
|
|
canvas.onselectstart = function () { return false; };
|
|
|
|
document.body.appendChild(canvas);
|
|
|
|
return canvas;
|
|
};
|
|
|
|
var createInputDevices = function (canvas) {
|
|
var devices = {
|
|
elementInput: new pc.ElementInput(canvas, {
|
|
useMouse: INPUT_SETTINGS.useMouse,
|
|
useTouch: INPUT_SETTINGS.useTouch
|
|
}),
|
|
keyboard: INPUT_SETTINGS.useKeyboard ? new pc.Keyboard(window) : null,
|
|
mouse: INPUT_SETTINGS.useMouse ? new pc.Mouse(canvas) : null,
|
|
gamepads: INPUT_SETTINGS.useGamepads ? new pc.GamePads() : null,
|
|
touch: INPUT_SETTINGS.useTouch && pc.platform.touch ? new pc.TouchDevice(canvas) : null
|
|
};
|
|
|
|
return devices;
|
|
};
|
|
|
|
var configureCss = function (fillMode, width, height) {
|
|
// Configure resolution and resize event
|
|
if (canvas.classList) {
|
|
canvas.classList.add('fill-mode-' + fillMode);
|
|
}
|
|
|
|
// css media query for aspect ratio changes
|
|
var css = "@media screen and (min-aspect-ratio: " + width + "/" + height + ") {";
|
|
css += " #application-canvas.fill-mode-KEEP_ASPECT {";
|
|
css += " width: auto;";
|
|
css += " height: 100%;";
|
|
css += " margin: 0 auto;";
|
|
css += " }";
|
|
css += "}";
|
|
|
|
// append css to style
|
|
if (document.head.querySelector) {
|
|
document.head.querySelector('style').innerHTML += css;
|
|
}
|
|
};
|
|
|
|
var reflow = function () {
|
|
app.resizeCanvas(canvas.width, canvas.height);
|
|
canvas.style.width = '';
|
|
canvas.style.height = '';
|
|
|
|
var fillMode = app._fillMode;
|
|
|
|
if (fillMode == pc.FILLMODE_NONE || fillMode == pc.FILLMODE_KEEP_ASPECT) {
|
|
if ((fillMode == pc.FILLMODE_NONE && canvas.clientHeight < window.innerHeight) || (canvas.clientWidth / canvas.clientHeight >= window.innerWidth / window.innerHeight)) {
|
|
canvas.style.marginTop = Math.floor((window.innerHeight - canvas.clientHeight) / 2) + 'px';
|
|
} else {
|
|
canvas.style.marginTop = '';
|
|
}
|
|
}
|
|
};
|
|
|
|
var displayError = function (html) {
|
|
var div = document.createElement('div');
|
|
|
|
div.innerHTML = [
|
|
'<table style="background-color: #8CE; width: 100%; height: 100%;">',
|
|
' <tr>',
|
|
' <td align="center">',
|
|
' <div style="display: table-cell; vertical-align: middle;">',
|
|
' <div style="">' + html + '</div>',
|
|
' </div>',
|
|
' </td>',
|
|
' </tr>',
|
|
'</table>'
|
|
].join('\n');
|
|
|
|
document.body.appendChild(div);
|
|
};
|
|
|
|
canvas = createCanvas();
|
|
devices = createInputDevices(canvas);
|
|
|
|
try {
|
|
app = new pc.Application(canvas, {
|
|
elementInput: devices.elementInput,
|
|
keyboard: devices.keyboard,
|
|
mouse: devices.mouse,
|
|
gamepads: devices.gamepads,
|
|
touch: devices.touch,
|
|
graphicsDeviceOptions: window.CONTEXT_OPTIONS,
|
|
assetPrefix: window.ASSET_PREFIX || "",
|
|
scriptPrefix: window.SCRIPT_PREFIX || "",
|
|
scriptsOrder: window.SCRIPTS || []
|
|
});
|
|
} catch (e) {
|
|
if (e instanceof pc.UnsupportedBrowserError) {
|
|
displayError('This page requires a browser that supports WebGL.<br/>' +
|
|
'<a href="http://get.webgl.org">Click here to find out more.</a>');
|
|
} else if (e instanceof pc.ContextCreationError) {
|
|
displayError("It doesn't appear your computer can support WebGL.<br/>" +
|
|
'<a href="http://get.webgl.org/troubleshooting/">Click here for more information.</a>');
|
|
} else {
|
|
displayError('Could not initialize application. Error: ' + e);
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
app.configure(CONFIG_FILENAME, function (err) {
|
|
if (err) {
|
|
console.error(err);
|
|
}
|
|
|
|
configureCss(app._fillMode, app._width, app._height);
|
|
reflow();
|
|
|
|
window.addEventListener('resize', reflow, false);
|
|
window.addEventListener('orientationchange', reflow, false);
|
|
|
|
app.preload(function (err) {
|
|
if (err) {
|
|
console.error(err);
|
|
}
|
|
|
|
app.loadScene(SCENE_PATH, function (err, scene) {
|
|
if (err) {
|
|
console.error(err);
|
|
}
|
|
|
|
app.start();
|
|
});
|
|
});
|
|
});
|
|
}());
|