Migrate to SDL2 and deploy as WASM
All checks were successful
Build & deploy web version / Build WebAssembly & deploy (push) Successful in 1m8s

This commit is contained in:
Andras Schmelczer 2026-08-09 20:00:56 +01:00
commit c9b542eccf
2 changed files with 1411 additions and 483 deletions

60
web/pre.js Normal file
View file

@ -0,0 +1,60 @@
Module.preRun = Module.preRun || [];
Module.preRun.push(function () {
var released = false;
var exists = function (path) {
try {
FS.stat(path);
return true;
} catch (e) {
return false;
}
};
var release = function (err) {
if (released) return;
released = true;
if (err) console.warn('A mentesek betoltese nem sikerult:', err);
try {
if (!exists('/saves/rang.lst')) FS.writeFile('/saves/rang.lst', '');
if (!exists('/rang.lst')) FS.symlink('/saves/rang.lst', '/rang.lst');
} catch (e) {
console.warn('A ranglista nem elerheto:', e);
}
Module.removeRunDependency('persist');
};
Module.addRunDependency('persist');
try {
if (!exists('/saves')) FS.mkdir('/saves');
FS.mount(IDBFS, {}, '/saves');
} catch (e) {
console.warn('A tartos tarolas nem erheto el, a mentesek nem maradnak meg:', e);
release();
return;
}
setTimeout(release, 3000);
FS.syncfs(true, release);
});
Module.postRun = Module.postRun || [];
Module.postRun.push(function () {
var flushing = false;
var flush = function () {
if (flushing) return;
flushing = true;
FS.syncfs(false, function (err) {
flushing = false;
if (err) console.warn('A mentes nem sikerult:', err);
});
};
setInterval(flush, 4000);
addEventListener('pagehide', flush);
addEventListener('visibilitychange', flush);
});

66
web/shell.html Normal file
View file

@ -0,0 +1,66 @@
<!doctype html>
<html lang="hu">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Platform játék</title>
<style>
html, body {
margin: 0;
height: 100%;
background: #1a0505;
color: #e8d5d5;
font: 16px/1.5 system-ui, sans-serif;
overflow: hidden;
}
#shell {
position: fixed;
inset: 0;
}
canvas {
display: block;
width: 100%;
height: 100%;
cursor: none;
background: #280000;
outline: none;
}
#status {
position: fixed;
bottom: 12px;
font-size: 14px;
opacity: 0.65;
}
</style>
</head>
<body>
<div id="shell">
<canvas id="canvas" tabindex="-1" oncontextmenu="event.preventDefault()"></canvas>
</div>
<div id="status">Betöltés…</div>
<script>
var statusElement = document.getElementById('status');
var canvasElement = document.getElementById('canvas');
var Module = {
canvas: canvasElement,
preRun: [],
postRun: [],
print: function (text) { console.log(text); },
printErr: function (text) { console.error(text); },
setStatus: function (text) {
if (text) statusElement.textContent = text;
}
};
canvasElement.addEventListener('click', function () { canvasElement.focus(); });
window.addEventListener('keydown', function (event) {
if (['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', ' '].indexOf(event.key) >= 0) event.preventDefault();
});
</script>
{{{ SCRIPT }}}
</body>
</html>