creada secció de jugar en wasm en coffee_crisis
This commit is contained in:
@@ -35,6 +35,22 @@ layout: base.njk
|
|||||||
</section>
|
</section>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{% if game.wasm %}
|
||||||
|
<div id="wasm-player" data-wasm-js="{{ game.wasm.js }}">
|
||||||
|
<div class="wasm-player" id="wasm-canvas-wrap" style="display:none;">
|
||||||
|
<canvas class="wasm-player__canvas" id="canvas" oncontextmenu="event.preventDefault()" tabindex="-1"></canvas>
|
||||||
|
<div class="wasm-player__progress" id="wasm-progress" style="display:none;">
|
||||||
|
<div class="wasm-player__progress-bar" id="wasm-progress-bar"></div>
|
||||||
|
<span class="wasm-player__progress-text" id="wasm-progress-text">Carregant...</span>
|
||||||
|
</div>
|
||||||
|
<div class="wasm-player__controls" id="wasm-controls" style="display:none;">
|
||||||
|
<span class="wasm-player__status" id="wasm-status"></span>
|
||||||
|
<button class="wasm-player__fullscreen" id="wasm-fullscreen" title="Pantalla completa">⛶</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<section class="game-detail__description">
|
<section class="game-detail__description">
|
||||||
{{ game.description | markdown | safe }}
|
{{ game.description | markdown | safe }}
|
||||||
</section>
|
</section>
|
||||||
@@ -42,6 +58,12 @@ layout: base.njk
|
|||||||
<section class="game-detail__downloads">
|
<section class="game-detail__downloads">
|
||||||
<h2>Descarregar</h2>
|
<h2>Descarregar</h2>
|
||||||
<div class="download-buttons">
|
<div class="download-buttons">
|
||||||
|
{% if game.wasm %}
|
||||||
|
<button class="download-btn download-btn--play" id="wasm-play-btn">
|
||||||
|
<span class="download-btn__platform">▶ Navegador</span>
|
||||||
|
<span class="download-btn__size">WebAssembly</span>
|
||||||
|
</button>
|
||||||
|
{% endif %}
|
||||||
{% for dl in game.downloads %}
|
{% for dl in game.downloads %}
|
||||||
<a href="{{ dl.file }}" class="download-btn" download>
|
<a href="{{ dl.file }}" class="download-btn" download>
|
||||||
<span class="download-btn__platform">{{ dl.platform }}</span>
|
<span class="download-btn__platform">{{ dl.platform }}</span>
|
||||||
@@ -62,3 +84,7 @@ layout: base.njk
|
|||||||
<a href="/" class="back-link">← Tornar al catàleg</a>
|
<a href="/" class="back-link">← Tornar al catàleg</a>
|
||||||
|
|
||||||
</article>
|
</article>
|
||||||
|
|
||||||
|
{% if game.wasm %}
|
||||||
|
<script src="/js/wasm-loader.js"></script>
|
||||||
|
{% endif %}
|
||||||
|
|||||||
@@ -475,6 +475,122 @@ h1, h2, h3 {
|
|||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* =============================================
|
||||||
|
WASM PLAYER
|
||||||
|
============================================= */
|
||||||
|
.download-btn--play {
|
||||||
|
background-color: var(--color-success);
|
||||||
|
cursor: pointer;
|
||||||
|
border: none;
|
||||||
|
font-family: var(--font-main);
|
||||||
|
}
|
||||||
|
|
||||||
|
.download-btn--play:hover {
|
||||||
|
background-color: #3db88a;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wasm-player {
|
||||||
|
position: relative;
|
||||||
|
max-width: 800px;
|
||||||
|
margin: 0 auto 1.5rem;
|
||||||
|
background-color: #000;
|
||||||
|
border-radius: var(--radius-lg);
|
||||||
|
overflow: hidden;
|
||||||
|
border: 2px solid var(--color-border);
|
||||||
|
aspect-ratio: 4 / 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wasm-player__canvas {
|
||||||
|
display: block;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
background-color: #000;
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wasm-player__progress {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
height: 36px;
|
||||||
|
background-color: rgba(0, 0, 0, 0.85);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
z-index: 11;
|
||||||
|
padding: 0 1rem;
|
||||||
|
gap: 0.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wasm-player__progress-bar {
|
||||||
|
flex: 1;
|
||||||
|
height: 6px;
|
||||||
|
background-color: var(--color-border);
|
||||||
|
border-radius: 3px;
|
||||||
|
overflow: hidden;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wasm-player__progress-bar::after {
|
||||||
|
content: "";
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
height: 100%;
|
||||||
|
width: var(--progress, 0%);
|
||||||
|
background-color: var(--color-success);
|
||||||
|
border-radius: 3px;
|
||||||
|
transition: width 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wasm-player__progress-text {
|
||||||
|
font-size: 0.75rem;
|
||||||
|
color: var(--color-text-muted);
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wasm-player__controls {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
height: 36px;
|
||||||
|
background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: flex-end;
|
||||||
|
padding: 0 0.5rem;
|
||||||
|
z-index: 10;
|
||||||
|
opacity: 0;
|
||||||
|
transition: opacity var(--transition);
|
||||||
|
}
|
||||||
|
|
||||||
|
.wasm-player:hover .wasm-player__controls {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wasm-player__status {
|
||||||
|
flex: 1;
|
||||||
|
font-size: 0.75rem;
|
||||||
|
color: var(--color-text-muted);
|
||||||
|
padding-left: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wasm-player__fullscreen {
|
||||||
|
background: none;
|
||||||
|
border: none;
|
||||||
|
color: #fff;
|
||||||
|
font-size: 1.25rem;
|
||||||
|
cursor: pointer;
|
||||||
|
padding: 0.25rem 0.5rem;
|
||||||
|
opacity: 0.8;
|
||||||
|
transition: opacity var(--transition);
|
||||||
|
}
|
||||||
|
|
||||||
|
.wasm-player__fullscreen:hover {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* =============================================
|
/* =============================================
|
||||||
RESPONSIVE — Desktop gran (≥ 1200px)
|
RESPONSIVE — Desktop gran (≥ 1200px)
|
||||||
============================================= */
|
============================================= */
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ description: |
|
|||||||
de cafeïna que reboten per tot arreu. Una sola vida, 10 nivells i l'objectiu
|
de cafeïna que reboten per tot arreu. Una sola vida, 10 nivells i l'objectiu
|
||||||
d'acumular el màxim de punts possible.
|
d'acumular el màxim de punts possible.
|
||||||
|
|
||||||
Desenvolupat a l'estiu de 2020-2021 amb C/SDL3. Compatible amb gamepad i teclat.
|
Desenvolupat a l'estiu de 2020 amb C++ i SDL3. Compatible amb gamepad i teclat.
|
||||||
|
|
||||||
version: "2.3.3"
|
version: "2.3.3"
|
||||||
release_date: "2021-02-18"
|
release_date: "2021-02-18"
|
||||||
@@ -42,6 +42,9 @@ downloads:
|
|||||||
file: "/downloads/coffee-crisis/coffee-crisis-v2.3.3-raspi.tar.gz"
|
file: "/downloads/coffee-crisis/coffee-crisis-v2.3.3-raspi.tar.gz"
|
||||||
size: "4.7 MB"
|
size: "4.7 MB"
|
||||||
|
|
||||||
|
wasm:
|
||||||
|
js: "/games/coffee-crisis/wasm/coffee_crisis.js"
|
||||||
|
|
||||||
engine: "C++ SDL3"
|
engine: "C++ SDL3"
|
||||||
players: "1 jugador"
|
players: "1 jugador"
|
||||||
genre: "Arcade / Reflexos"
|
genre: "Arcade / Reflexos"
|
||||||
|
|||||||
@@ -0,0 +1,90 @@
|
|||||||
|
(function () {
|
||||||
|
var player = document.getElementById("wasm-player");
|
||||||
|
if (!player) return;
|
||||||
|
|
||||||
|
var wasmJs = player.getAttribute("data-wasm-js");
|
||||||
|
if (!wasmJs) return;
|
||||||
|
|
||||||
|
var playBtn = document.getElementById("wasm-play-btn");
|
||||||
|
var canvas = document.getElementById("canvas");
|
||||||
|
var canvasWrap = document.getElementById("wasm-canvas-wrap");
|
||||||
|
var progress = document.getElementById("wasm-progress");
|
||||||
|
var progressBar = document.getElementById("wasm-progress-bar");
|
||||||
|
var progressText = document.getElementById("wasm-progress-text");
|
||||||
|
var controls = document.getElementById("wasm-controls");
|
||||||
|
var statusEl = document.getElementById("wasm-status");
|
||||||
|
var fullscreenBtn = document.getElementById("wasm-fullscreen");
|
||||||
|
|
||||||
|
playBtn.addEventListener("click", function () {
|
||||||
|
playBtn.disabled = true;
|
||||||
|
playBtn.querySelector(".download-btn__size").textContent = "Carregant...";
|
||||||
|
canvasWrap.style.display = "";
|
||||||
|
canvasWrap.scrollIntoView({ behavior: "smooth", block: "center" });
|
||||||
|
progress.style.display = "flex";
|
||||||
|
loadGame();
|
||||||
|
});
|
||||||
|
|
||||||
|
fullscreenBtn.addEventListener("click", function () {
|
||||||
|
if (Module && Module.requestFullscreen) {
|
||||||
|
Module.requestFullscreen(true, false);
|
||||||
|
} else {
|
||||||
|
var el = canvas;
|
||||||
|
var rfs = el.requestFullscreen || el.webkitRequestFullscreen || el.mozRequestFullScreen;
|
||||||
|
if (rfs) rfs.call(el);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function loadGame() {
|
||||||
|
window.Module = {
|
||||||
|
canvas: canvas,
|
||||||
|
locateFile: function (filename) {
|
||||||
|
return wasmJs.substring(0, wasmJs.lastIndexOf("/") + 1) + filename;
|
||||||
|
},
|
||||||
|
print: function () {},
|
||||||
|
printErr: function () {},
|
||||||
|
setStatus: function (text) {
|
||||||
|
if (!text) {
|
||||||
|
progress.style.display = "none";
|
||||||
|
controls.style.display = "flex";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
|
||||||
|
if (m) {
|
||||||
|
var pct = (parseInt(m[2]) / parseInt(m[4])) * 100;
|
||||||
|
progressBar.style.setProperty("--progress", pct + "%");
|
||||||
|
progressText.textContent = m[1].trim();
|
||||||
|
} else {
|
||||||
|
progressText.textContent = text;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
totalDependencies: 0,
|
||||||
|
monitorRunDependencies: function (left) {
|
||||||
|
this.totalDependencies = Math.max(this.totalDependencies, left);
|
||||||
|
if (left) {
|
||||||
|
Module.setStatus(
|
||||||
|
"Preparant... (" +
|
||||||
|
(this.totalDependencies - left) +
|
||||||
|
"/" +
|
||||||
|
this.totalDependencies +
|
||||||
|
")"
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
Module.setStatus("");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
canvas.addEventListener("webglcontextlost", function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
statusEl.textContent = "WebGL context lost";
|
||||||
|
});
|
||||||
|
|
||||||
|
var script = document.createElement("script");
|
||||||
|
script.src = wasmJs;
|
||||||
|
script.async = true;
|
||||||
|
script.onerror = function () {
|
||||||
|
progressText.textContent = "Error carregant el joc";
|
||||||
|
};
|
||||||
|
document.body.appendChild(script);
|
||||||
|
}
|
||||||
|
})();
|
||||||
Binary file not shown.
File diff suppressed because one or more lines are too long
BIN
Binary file not shown.
Reference in New Issue
Block a user