summaryrefslogtreecommitdiff
path: root/2026/index.html
diff options
context:
space:
mode:
Diffstat (limited to '2026/index.html')
-rw-r--r--2026/index.html20
1 files changed, 13 insertions, 7 deletions
diff --git a/2026/index.html b/2026/index.html
index 061ef97..a5ba2b8 100644
--- a/2026/index.html
+++ b/2026/index.html
@@ -48,7 +48,7 @@
let framing = document.getElementById("jam-framing-iframe");
let microgame_index = 0;
let iframe_parent = document.getElementById("jam-iframe-parent");
- let iframes =[ ...Array(5).keys()].map(i => {
+ let iframes =[ ...Array(2).keys()].map(i => {
let elem = document.createElement("iframe")
elem.id = `jam-game-iframe-${i}`;
elem.classList.add("jam-hidden");
@@ -75,6 +75,7 @@
return mi;
}
}
+ if (ev.source.location.href == framing.src) return "framing";
console.log(`event associated with unknown game: ${ev}`);
return null;
}
@@ -108,7 +109,7 @@
function loadUpcomingGames() {
console.log(`loading upcoming games!`);
let first = true;
- let to_load = Math.min(5, microgames.length);
+ let to_load = Math.min(2, microgames.length);
for (let i = (microgame_index + to_load) % microgames.length; i != microgame_index; i = (i + 1) % microgames.length) {
unloadGame(i)
}
@@ -138,11 +139,15 @@
microgames[idx].loaded.classList.add("jam-hidden");
framing.contentWindow.postMessage({op: "endgame", win: win});
loadUpcomingGames();
- setTimeout(startNextGameIfReady, 4000);
- state = {mode: "finished"};
+ state = {mode: "waitingforlives"};
console.log(state);
}
}
+ function receivedLifeTotal(lives) {
+ setTimeout(startNextGameIfReady, 4000);
+ state = {mode: "finished"};
+ console.log(state);
+ }
function startGame(idx) {
if (state.mode == "waiting" && state.idx === idx) {
console.log(`actually starting game: ${idx}`);
@@ -154,9 +159,9 @@
console.log(state);
}
}
- function confirmStartGame(idx) {
+ function confirmStartGame(idx, verb) {
if (state.mode == "starting" && state.idx === idx) {
- framing.contentWindow.postMessage({op: "startgame"});
+ framing.contentWindow.postMessage({op: "startgame", verb: verb});
microgames[idx].loaded.contentWindow.focus();
state = {mode: "running", idx: idx};
console.log(state);
@@ -193,8 +198,9 @@
console.log(`received message: ${ev.data.op} (from ${ev.source.location.href})`);
switch (ev.data.op) {
case "ready": confirmReadyGame(mi); break;
- case "started": confirmStartGame(mi); break;
+ case "started": confirmStartGame(mi, ev.data.verb); break;
case "done": finishGame(mi, ev.data.win); break;
+ case "lifetotal": receivedLifeTotal(ev.data.lives); break;
default: console.log(`unknown event: ${ev}`); break;
}
});