This commit is contained in:
1 parent
94f1021fd0
commit
2aad61c81f
12 files changed
+2673
No files matched your search
@@ -0,0 +1,749 @@
|
||||
(() => {
|
||||
"use strict";
|
||||
|
||||
const $ = (selector, root = document) => root.querySelector(selector);
|
||||
const $$ = (selector, root = document) => Array.from(root.querySelectorAll(selector));
|
||||
|
||||
const room = $("#room");
|
||||
const shell = $("#game-shell");
|
||||
const log = $("#log");
|
||||
const chips = $("#chips");
|
||||
const progressText = $("#progress-text");
|
||||
const progressPercent = $("#progress-percent");
|
||||
const progressTrack = $("#progress-track");
|
||||
const progressBar = $("#progress-bar");
|
||||
const modal = $("#modal");
|
||||
const voucherCode = $("#voucher-code");
|
||||
const voucherRecipient = $("#voucher-recipient");
|
||||
const voucherDate = $("#voucher-date");
|
||||
const voucherNote = $("#voucher-note");
|
||||
const copyButton = $("#copy-code");
|
||||
const playAgainButton = $("#play-again");
|
||||
const soundButton = $("#sound-toggle");
|
||||
const confettiCanvas = $("#confetti");
|
||||
const confettiContext = confettiCanvas.getContext("2d");
|
||||
|
||||
const reduceMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
||||
const GLASS_OBJECTS = new Set(["spiegel", "klok"]);
|
||||
|
||||
const DEBRIS_COLORS = {
|
||||
spiegel: ["#d9f2f7", "#a9d6e1", "#ffffff", "#7fb3c2"],
|
||||
schilderij: ["#c99a3f", "#4c8b9b", "#f8d9a0", "#6b4425"],
|
||||
klok: ["#f3e4c1", "#c99a3f", "#3d2a1c"],
|
||||
kast: ["#7b5330", "#b9553f", "#d09a45", "#4f7d75"],
|
||||
zetel: ["#4e837d", "#6b9d96", "#39716b"],
|
||||
tafel: ["#8a5b34", "#6d4527", "#d6b15b", "#5f3b20"],
|
||||
deur: ["#8a5b34", "#744924", "#c99a3f"],
|
||||
plant: ["#b2603d", "#4f8747", "#67a05a", "#8d4328"]
|
||||
};
|
||||
|
||||
const TOOL_LABELS = {
|
||||
hamer: "hamer",
|
||||
koevoet: "koevoet"
|
||||
};
|
||||
|
||||
const HIT_LINES = {
|
||||
hamer: ["Bonk!", "Krak!", "Goeie tik!", "Dat klinkt bevredigend."],
|
||||
koevoet: ["Krak!", "Wrikken maar.", "Iets lossers.", "De vijzen geven mee."]
|
||||
};
|
||||
|
||||
const state = {
|
||||
tool: "hamer",
|
||||
config: null,
|
||||
objects: new Map(),
|
||||
brokenCount: 0,
|
||||
soundOn: true,
|
||||
finished: false,
|
||||
audio: null,
|
||||
lastFocus: null,
|
||||
confettiFrame: null,
|
||||
confettiParticles: []
|
||||
};
|
||||
|
||||
try {
|
||||
state.soundOn = window.localStorage.getItem("jos-sloop-geluid") !== "uit";
|
||||
} catch {
|
||||
state.soundOn = true;
|
||||
}
|
||||
|
||||
function pick(list) {
|
||||
return list[Math.floor(Math.random() * list.length)];
|
||||
}
|
||||
|
||||
function wait(ms) {
|
||||
return new Promise((resolve) => window.setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
function setLog(message, kind = "normal") {
|
||||
log.textContent = message;
|
||||
log.classList.toggle("is-warning", kind === "warning");
|
||||
log.classList.toggle("is-done", kind === "done");
|
||||
}
|
||||
|
||||
function updateSoundButton() {
|
||||
soundButton.setAttribute("aria-pressed", String(state.soundOn));
|
||||
const label = state.soundOn ? "Geluid dempen" : "Geluid aanzetten";
|
||||
soundButton.setAttribute("aria-label", label);
|
||||
soundButton.title = label;
|
||||
}
|
||||
|
||||
function ensureAudio() {
|
||||
if (!state.soundOn) {
|
||||
return null;
|
||||
}
|
||||
if (!state.audio) {
|
||||
const AudioContextClass = window.AudioContext || window.webkitAudioContext;
|
||||
if (!AudioContextClass) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
state.audio = new AudioContextClass();
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if (state.audio.state === "suspended") {
|
||||
state.audio.resume().catch(() => {});
|
||||
}
|
||||
return state.audio;
|
||||
}
|
||||
|
||||
function playTone({ freq = 200, endFreq = freq, type = "sine", duration = 0.16, gain = 0.15, delay = 0 }) {
|
||||
const context = ensureAudio();
|
||||
if (!context) {
|
||||
return;
|
||||
}
|
||||
const start = context.currentTime + delay;
|
||||
const oscillator = context.createOscillator();
|
||||
const volume = context.createGain();
|
||||
oscillator.type = type;
|
||||
oscillator.frequency.setValueAtTime(Math.max(20, freq), start);
|
||||
oscillator.frequency.exponentialRampToValueAtTime(Math.max(20, endFreq), start + duration);
|
||||
volume.gain.setValueAtTime(0.0001, start);
|
||||
volume.gain.exponentialRampToValueAtTime(Math.max(0.0001, gain), start + 0.012);
|
||||
volume.gain.exponentialRampToValueAtTime(0.0001, start + duration);
|
||||
oscillator.connect(volume).connect(context.destination);
|
||||
oscillator.start(start);
|
||||
oscillator.stop(start + duration + 0.03);
|
||||
}
|
||||
|
||||
function playNoise({ duration = 0.2, gain = 0.2, frequency = 900, delay = 0 } = {}) {
|
||||
const context = ensureAudio();
|
||||
if (!context) {
|
||||
return;
|
||||
}
|
||||
const frames = Math.max(1, Math.floor(context.sampleRate * duration));
|
||||
const buffer = context.createBuffer(1, frames, context.sampleRate);
|
||||
const data = buffer.getChannelData(0);
|
||||
for (let index = 0; index < frames; index += 1) {
|
||||
data[index] = (Math.random() * 2 - 1) * (1 - index / frames);
|
||||
}
|
||||
const source = context.createBufferSource();
|
||||
source.buffer = buffer;
|
||||
const filter = context.createBiquadFilter();
|
||||
filter.type = "bandpass";
|
||||
filter.frequency.value = frequency;
|
||||
filter.Q.value = 0.8;
|
||||
const volume = context.createGain();
|
||||
volume.gain.value = gain;
|
||||
source.connect(filter).connect(volume).connect(context.destination);
|
||||
source.start(context.currentTime + delay);
|
||||
}
|
||||
|
||||
function playHit(tool) {
|
||||
if (tool === "hamer") {
|
||||
playTone({ freq: 190, endFreq: 58, type: "triangle", duration: 0.18, gain: 0.3 });
|
||||
playNoise({ duration: 0.1, gain: 0.14, frequency: 1400 });
|
||||
} else {
|
||||
playTone({ freq: 95, endFreq: 48, type: "sawtooth", duration: 0.22, gain: 0.18 });
|
||||
playNoise({ duration: 0.16, gain: 0.1, frequency: 620 });
|
||||
}
|
||||
}
|
||||
|
||||
function playWrong() {
|
||||
playTone({ freq: 310, endFreq: 190, type: "square", duration: 0.11, gain: 0.09 });
|
||||
playTone({ freq: 170, endFreq: 120, type: "triangle", duration: 0.16, gain: 0.08, delay: 0.08 });
|
||||
}
|
||||
|
||||
function playBreak(objectId) {
|
||||
if (GLASS_OBJECTS.has(objectId)) {
|
||||
playNoise({ duration: 0.5, gain: 0.32, frequency: 3400 });
|
||||
playTone({ freq: 1750, endFreq: 260, type: "triangle", duration: 0.42, gain: 0.13 });
|
||||
playNoise({ duration: 0.24, gain: 0.12, frequency: 1800, delay: 0.12 });
|
||||
} else {
|
||||
playNoise({ duration: 0.34, gain: 0.26, frequency: 720 });
|
||||
playTone({ freq: 125, endFreq: 42, type: "sawtooth", duration: 0.32, gain: 0.2 });
|
||||
}
|
||||
}
|
||||
|
||||
function playFanfare() {
|
||||
const notes = [523.25, 659.25, 783.99, 1046.5];
|
||||
notes.forEach((frequency, index) => {
|
||||
playTone({
|
||||
freq: frequency,
|
||||
endFreq: frequency,
|
||||
type: "triangle",
|
||||
duration: 0.28,
|
||||
gain: 0.13,
|
||||
delay: index * 0.13
|
||||
});
|
||||
});
|
||||
playTone({ freq: 1318.5, endFreq: 1318.5, type: "sine", duration: 0.6, gain: 0.1, delay: 0.55 });
|
||||
}
|
||||
|
||||
function selectTool(tool) {
|
||||
if (!TOOL_LABELS[tool]) {
|
||||
return;
|
||||
}
|
||||
state.tool = tool;
|
||||
$$(".tool-btn").forEach((button) => {
|
||||
const active = button.dataset.tool === tool;
|
||||
button.classList.toggle("is-active", active);
|
||||
button.setAttribute("aria-pressed", String(active));
|
||||
});
|
||||
}
|
||||
|
||||
function objectCenter(element) {
|
||||
const rect = element.getBoundingClientRect();
|
||||
return { x: rect.left + rect.width / 2, y: rect.top + rect.height / 2 };
|
||||
}
|
||||
|
||||
function spawnSwing(x, y, tool, good) {
|
||||
const source = $(`.tool-btn[data-tool="${tool}"] svg`);
|
||||
if (!source) {
|
||||
return;
|
||||
}
|
||||
const wrap = document.createElement("div");
|
||||
wrap.className = `swing${good ? "" : " bad"}`;
|
||||
wrap.style.left = `${x}px`;
|
||||
wrap.style.top = `${y}px`;
|
||||
wrap.appendChild(source.cloneNode(true));
|
||||
document.body.appendChild(wrap);
|
||||
window.setTimeout(() => wrap.remove(), 460);
|
||||
}
|
||||
|
||||
function spawnDebris(x, y, colors, count, power = 1) {
|
||||
if (reduceMotion) {
|
||||
return;
|
||||
}
|
||||
for (let index = 0; index < count; index += 1) {
|
||||
const size = 5 + Math.random() * 8;
|
||||
const particle = document.createElement("span");
|
||||
particle.className = "debris";
|
||||
particle.style.width = `${size}px`;
|
||||
particle.style.height = `${size}px`;
|
||||
particle.style.left = `${x}px`;
|
||||
particle.style.top = `${y}px`;
|
||||
particle.style.marginLeft = `${-size / 2}px`;
|
||||
particle.style.marginTop = `${-size / 2}px`;
|
||||
particle.style.background = pick(colors);
|
||||
particle.style.clipPath = Math.random() > 0.5
|
||||
? "polygon(50% 0, 100% 100%, 0 72%)"
|
||||
: "polygon(0 15%, 100% 0, 75% 100%, 10% 88%)";
|
||||
document.body.appendChild(particle);
|
||||
|
||||
const angle = Math.random() * Math.PI * 2;
|
||||
const speed = (45 + Math.random() * 135) * power;
|
||||
const dx = Math.cos(angle) * speed;
|
||||
const dy = Math.sin(angle) * speed - (35 + Math.random() * 65) * power;
|
||||
const rotation = (Math.random() * 2 - 1) * 520;
|
||||
|
||||
particle.animate(
|
||||
[
|
||||
{ transform: "translate(0, 0) rotate(0deg)", opacity: 1 },
|
||||
{ transform: `translate(${dx}px, ${dy + 260 * power}px) rotate(${rotation}deg)`, opacity: 0 }
|
||||
],
|
||||
{
|
||||
duration: 520 + Math.random() * 520,
|
||||
easing: "cubic-bezier(.12,.62,.35,1)"
|
||||
}
|
||||
).onfinish = () => particle.remove();
|
||||
}
|
||||
}
|
||||
|
||||
function spawnFloatText(x, y, text, bad = false) {
|
||||
if (reduceMotion) {
|
||||
return;
|
||||
}
|
||||
const node = document.createElement("span");
|
||||
node.className = `float-text${bad ? " bad" : ""}`;
|
||||
node.textContent = text;
|
||||
node.style.left = `${x}px`;
|
||||
node.style.top = `${y}px`;
|
||||
document.body.appendChild(node);
|
||||
window.setTimeout(() => node.remove(), 850);
|
||||
}
|
||||
|
||||
function leaveRubble(object) {
|
||||
const roomRect = room.getBoundingClientRect();
|
||||
const objectRect = object.element.getBoundingClientRect();
|
||||
if (roomRect.width === 0 || roomRect.height === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const x = ((objectRect.left + objectRect.width / 2 - roomRect.left) / roomRect.width) * 100;
|
||||
const objectBottom = ((objectRect.bottom - roomRect.top) / roomRect.height) * 100;
|
||||
const y = Math.min(93, Math.max(78, objectBottom + 1));
|
||||
const colors = DEBRIS_COLORS[object.meta.id] || ["#8a6a49", "#5f452f"];
|
||||
|
||||
const pile = document.createElement("span");
|
||||
pile.className = "rubble";
|
||||
pile.style.left = `${x}%`;
|
||||
pile.style.top = `${y}%`;
|
||||
|
||||
const pieces = 5 + Math.floor(Math.random() * 4);
|
||||
for (let index = 0; index < pieces; index += 1) {
|
||||
const piece = document.createElement("i");
|
||||
piece.style.left = `${8 + Math.random() * 78}%`;
|
||||
piece.style.top = `${12 + Math.random() * 70}%`;
|
||||
piece.style.width = `${12 + Math.random() * 22}%`;
|
||||
piece.style.height = `${14 + Math.random() * 28}%`;
|
||||
piece.style.background = pick(colors);
|
||||
piece.style.transform = `rotate(${Math.random() * 120 - 60}deg)`;
|
||||
piece.style.clipPath = Math.random() > 0.5
|
||||
? "polygon(50% 0, 100% 100%, 0 74%)"
|
||||
: "polygon(0 16%, 100% 0, 76% 100%, 8% 86%)";
|
||||
pile.appendChild(piece);
|
||||
}
|
||||
|
||||
room.appendChild(pile);
|
||||
}
|
||||
|
||||
function shakeShell() {
|
||||
if (reduceMotion) {
|
||||
return;
|
||||
}
|
||||
shell.classList.remove("is-shaking");
|
||||
void shell.offsetWidth;
|
||||
shell.classList.add("is-shaking");
|
||||
window.setTimeout(() => shell.classList.remove("is-shaking"), 260);
|
||||
}
|
||||
|
||||
function updateProgress() {
|
||||
const total = state.objects.size;
|
||||
const percentage = total === 0 ? 0 : Math.round((state.brokenCount / total) * 100);
|
||||
progressText.textContent = `${state.brokenCount} / ${total} stukken gesloopt`;
|
||||
progressPercent.textContent = `${percentage}%`;
|
||||
progressBar.style.width = `${percentage}%`;
|
||||
progressTrack.setAttribute("aria-valuenow", String(percentage));
|
||||
room.style.setProperty("--chaos", total === 0 ? "0" : String(state.brokenCount / total));
|
||||
}
|
||||
|
||||
function hitObject(object, event) {
|
||||
if (!object || object.broken || state.finished || !state.config) {
|
||||
return;
|
||||
}
|
||||
|
||||
ensureAudio();
|
||||
|
||||
const hasPointer = typeof event.clientX === "number" && (event.clientX !== 0 || event.clientY !== 0);
|
||||
const point = hasPointer
|
||||
? { x: event.clientX, y: event.clientY }
|
||||
: objectCenter(object.element);
|
||||
const correctTool = state.tool === object.meta.tool;
|
||||
|
||||
spawnSwing(point.x, point.y, state.tool, correctTool);
|
||||
|
||||
object.element.classList.remove("is-hit");
|
||||
void object.element.offsetWidth;
|
||||
object.element.classList.add("is-hit");
|
||||
window.setTimeout(() => object.element.classList.remove("is-hit"), 300);
|
||||
|
||||
if (!correctTool) {
|
||||
object.wrong += 1;
|
||||
playWrong();
|
||||
shakeShell();
|
||||
spawnDebris(point.x, point.y, ["#c8bda6", "#8f826b"], 6, 0.55);
|
||||
spawnFloatText(point.x, point.y - 12, "BONK?", true);
|
||||
const extra = object.wrong >= 2 ? ` ${object.meta.hint}` : " Probeer eens een ander werktuig.";
|
||||
setLog(`Met de ${TOOL_LABELS[state.tool]} op de ${object.meta.label.toLowerCase()}? Dat werkt niet.${extra}`, "warning");
|
||||
return;
|
||||
}
|
||||
|
||||
object.hits += 1;
|
||||
const stage = Math.min(3, Math.ceil((object.hits / object.meta.hp) * 3));
|
||||
object.element.dataset.stage = String(stage);
|
||||
|
||||
playHit(state.tool);
|
||||
shakeShell();
|
||||
spawnDebris(point.x, point.y, DEBRIS_COLORS[object.meta.id] || ["#c8bda6"], 5 + object.hits * 2, 0.75);
|
||||
spawnFloatText(point.x, point.y - 12, state.tool === "hamer" ? "BONK" : "KRAK");
|
||||
|
||||
const remaining = object.meta.hp - object.hits;
|
||||
if (remaining > 0) {
|
||||
const line = pick(HIT_LINES[state.tool]);
|
||||
const suffix = remaining === 1 ? "nog 1 slag" : `nog ${remaining} slagen`;
|
||||
setLog(`${line} De ${object.meta.label.toLowerCase()} heeft ${suffix} nodig.`);
|
||||
return;
|
||||
}
|
||||
|
||||
breakObject(object, point);
|
||||
}
|
||||
|
||||
function breakObject(object, point) {
|
||||
object.broken = true;
|
||||
state.brokenCount += 1;
|
||||
|
||||
object.element.dataset.stage = "3";
|
||||
object.element.classList.add("is-broken");
|
||||
object.element.disabled = true;
|
||||
|
||||
const center = objectCenter(object.element);
|
||||
const colors = DEBRIS_COLORS[object.meta.id] || ["#c8bda6"];
|
||||
spawnDebris(center.x, center.y, colors, object.meta.id === "spiegel" ? 38 : 26, 1.35);
|
||||
if (object.meta.id === "spiegel") {
|
||||
spawnDebris(center.x, center.y, ["#ffffff", "#e8fbff", "#bfe8f1"], 18, 1.1);
|
||||
}
|
||||
|
||||
playBreak(object.meta.id);
|
||||
leaveRubble(object);
|
||||
setLog(object.meta.done, "done");
|
||||
|
||||
if (object.chip) {
|
||||
object.chip.classList.add("done");
|
||||
}
|
||||
|
||||
updateProgress();
|
||||
|
||||
if (state.brokenCount === state.objects.size) {
|
||||
finishGame();
|
||||
}
|
||||
}
|
||||
|
||||
function buildChips() {
|
||||
chips.innerHTML = "";
|
||||
state.objects.forEach((object) => {
|
||||
const chip = document.createElement("button");
|
||||
chip.type = "button";
|
||||
chip.className = "chip";
|
||||
chip.textContent = object.meta.label;
|
||||
chip.addEventListener("click", () => {
|
||||
if (object.broken) {
|
||||
setLog(`${object.meta.label} is al gesloopt. ${object.meta.done}`);
|
||||
return;
|
||||
}
|
||||
object.element.classList.remove("pulse");
|
||||
void object.element.offsetWidth;
|
||||
object.element.classList.add("pulse");
|
||||
window.setTimeout(() => object.element.classList.remove("pulse"), 700);
|
||||
const hint = object.wrong >= 2 ? ` ${object.meta.hint}` : "";
|
||||
setLog(`Nog te slopen: ${object.meta.label.toLowerCase()}.${hint}`);
|
||||
});
|
||||
object.chip = chip;
|
||||
chips.appendChild(chip);
|
||||
});
|
||||
}
|
||||
|
||||
function applyConfig(config) {
|
||||
const setText = (selector, value) => {
|
||||
const node = $(selector);
|
||||
if (node && value) {
|
||||
node.textContent = value;
|
||||
}
|
||||
};
|
||||
|
||||
setText("#recipient-name", config.recipient);
|
||||
setText("#footer-name", config.recipient);
|
||||
setText("#event-date", config.eventDate);
|
||||
setText("#footer-date", config.eventDate);
|
||||
setText("#game-title", config.title);
|
||||
setText("#game-subtitle", config.subtitle);
|
||||
setText("#voucher-date", config.eventDate);
|
||||
setText("#voucher-recipient", `Voor ${config.recipient}`);
|
||||
|
||||
if (config.title) {
|
||||
document.title = config.title;
|
||||
}
|
||||
}
|
||||
|
||||
function buildObjects(config) {
|
||||
const elements = new Map(
|
||||
$$(".object").map((element) => [element.dataset.id, element])
|
||||
);
|
||||
|
||||
config.objects.forEach((meta) => {
|
||||
const element = elements.get(meta.id);
|
||||
if (!element) {
|
||||
console.warn(`Geen tekenwerk gevonden voor object "${meta.id}".`);
|
||||
return;
|
||||
}
|
||||
|
||||
const object = {
|
||||
meta,
|
||||
element,
|
||||
hits: 0,
|
||||
wrong: 0,
|
||||
broken: false,
|
||||
chip: null
|
||||
};
|
||||
|
||||
element.disabled = false;
|
||||
element.setAttribute("aria-label", `${meta.label} slopen`);
|
||||
element.addEventListener("click", (event) => hitObject(object, event));
|
||||
|
||||
state.objects.set(meta.id, object);
|
||||
elements.delete(meta.id);
|
||||
});
|
||||
|
||||
state.brokenCount = 0;
|
||||
updateProgress();
|
||||
buildChips();
|
||||
}
|
||||
|
||||
async function finishGame() {
|
||||
state.finished = true;
|
||||
room.style.setProperty("--chaos", "1");
|
||||
setLog("Alles is gesloopt. Achter de spiegel zat een envelop met je cadeaubon...", "done");
|
||||
window.setTimeout(() => {
|
||||
openModal();
|
||||
launchConfetti();
|
||||
playFanfare();
|
||||
}, 650);
|
||||
}
|
||||
|
||||
function openModal() {
|
||||
state.lastFocus = document.activeElement;
|
||||
voucherCode.textContent = "code wordt gezocht...";
|
||||
voucherNote.textContent = "";
|
||||
voucherNote.style.color = "";
|
||||
modal.hidden = false;
|
||||
window.setTimeout(() => copyButton.focus(), 80);
|
||||
requestVoucher();
|
||||
}
|
||||
|
||||
async function requestVoucher() {
|
||||
const completed = Array.from(state.objects.values())
|
||||
.filter((object) => object.broken)
|
||||
.map((object) => object.meta.id);
|
||||
|
||||
try {
|
||||
const response = await fetch("/api/reveal", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ completed })
|
||||
});
|
||||
const data = await response.json().catch(() => ({}));
|
||||
|
||||
if (!response.ok || !data.ok) {
|
||||
throw new Error(data.error || "De code kon niet worden opgehaald.");
|
||||
}
|
||||
|
||||
voucherCode.textContent = data.code;
|
||||
voucherRecipient.textContent = `Voor ${data.recipient || state.config.recipient}`;
|
||||
voucherDate.textContent = data.eventDate || state.config.eventDate;
|
||||
voucherNote.textContent = "De code staat klaar. Kopieer hem of houd deze pagina open.";
|
||||
} catch (error) {
|
||||
voucherCode.textContent = "—";
|
||||
voucherNote.textContent = `${error.message} Herlaad de pagina en probeer opnieuw.`;
|
||||
voucherNote.style.color = "#a33b22";
|
||||
}
|
||||
}
|
||||
|
||||
function resetGame() {
|
||||
state.finished = false;
|
||||
state.brokenCount = 0;
|
||||
|
||||
state.objects.forEach((object) => {
|
||||
object.hits = 0;
|
||||
object.wrong = 0;
|
||||
object.broken = false;
|
||||
object.element.disabled = false;
|
||||
object.element.classList.remove("is-broken", "is-hit", "pulse");
|
||||
delete object.element.dataset.stage;
|
||||
if (object.chip) {
|
||||
object.chip.classList.remove("done");
|
||||
}
|
||||
});
|
||||
|
||||
room.style.setProperty("--chaos", "0");
|
||||
updateProgress();
|
||||
setLog("Nieuwe kamer, zelfde sloopwoede. Alles moet weg, ook de spiegel.");
|
||||
modal.hidden = true;
|
||||
voucherCode.textContent = "...";
|
||||
voucherNote.textContent = "";
|
||||
stopConfetti();
|
||||
$$(".debris, .swing, .float-text, .rubble").forEach((node) => node.remove());
|
||||
copyButton.classList.remove("is-copied");
|
||||
copyButton.textContent = "Kopieer";
|
||||
|
||||
const activeTool = $(".tool-btn.is-active");
|
||||
if (activeTool) {
|
||||
activeTool.focus();
|
||||
} else if (state.lastFocus && typeof state.lastFocus.focus === "function") {
|
||||
state.lastFocus.focus();
|
||||
}
|
||||
}
|
||||
|
||||
function resizeConfetti() {
|
||||
const ratio = Math.min(2, window.devicePixelRatio || 1);
|
||||
confettiCanvas.width = Math.floor(window.innerWidth * ratio);
|
||||
confettiCanvas.height = Math.floor(window.innerHeight * ratio);
|
||||
confettiContext.setTransform(ratio, 0, 0, ratio, 0, 0);
|
||||
}
|
||||
|
||||
function launchConfetti() {
|
||||
if (reduceMotion) {
|
||||
return;
|
||||
}
|
||||
resizeConfetti();
|
||||
const colors = ["#ffc93c", "#e86f2b", "#f6ead2", "#6da34d", "#4f837c", "#d2573f"];
|
||||
state.confettiParticles = Array.from({ length: 170 }, () => ({
|
||||
x: Math.random() * window.innerWidth,
|
||||
y: -30 - Math.random() * window.innerHeight * 0.5,
|
||||
vx: (Math.random() - 0.5) * 130,
|
||||
vy: 80 + Math.random() * 170,
|
||||
width: 5 + Math.random() * 7,
|
||||
height: 8 + Math.random() * 10,
|
||||
rotation: Math.random() * Math.PI,
|
||||
spin: (Math.random() - 0.5) * 11,
|
||||
color: pick(colors)
|
||||
}));
|
||||
|
||||
if (state.confettiFrame) {
|
||||
window.cancelAnimationFrame(state.confettiFrame);
|
||||
}
|
||||
|
||||
let last = performance.now();
|
||||
const tick = (now) => {
|
||||
const delta = Math.min(0.05, (now - last) / 1000);
|
||||
last = now;
|
||||
confettiContext.clearRect(0, 0, window.innerWidth, window.innerHeight);
|
||||
|
||||
let visible = 0;
|
||||
state.confettiParticles.forEach((particle) => {
|
||||
particle.vy += 190 * delta;
|
||||
particle.x += particle.vx * delta;
|
||||
particle.y += particle.vy * delta;
|
||||
particle.rotation += particle.spin * delta;
|
||||
|
||||
if (particle.y < window.innerHeight + 40) {
|
||||
visible += 1;
|
||||
}
|
||||
|
||||
confettiContext.save();
|
||||
confettiContext.translate(particle.x, particle.y);
|
||||
confettiContext.rotate(particle.rotation);
|
||||
confettiContext.fillStyle = particle.color;
|
||||
confettiContext.fillRect(-particle.width / 2, -particle.height / 2, particle.width, particle.height);
|
||||
confettiContext.restore();
|
||||
});
|
||||
|
||||
if (visible > 0) {
|
||||
state.confettiFrame = window.requestAnimationFrame(tick);
|
||||
} else {
|
||||
state.confettiFrame = null;
|
||||
confettiContext.clearRect(0, 0, window.innerWidth, window.innerHeight);
|
||||
}
|
||||
};
|
||||
|
||||
state.confettiFrame = window.requestAnimationFrame(tick);
|
||||
window.setTimeout(stopConfetti, 8000);
|
||||
}
|
||||
|
||||
function stopConfetti() {
|
||||
if (state.confettiFrame) {
|
||||
window.cancelAnimationFrame(state.confettiFrame);
|
||||
state.confettiFrame = null;
|
||||
}
|
||||
state.confettiParticles = [];
|
||||
confettiContext.clearRect(0, 0, window.innerWidth, window.innerHeight);
|
||||
}
|
||||
|
||||
function legacyCopy(text) {
|
||||
const field = document.createElement("textarea");
|
||||
field.value = text;
|
||||
field.setAttribute("readonly", "");
|
||||
field.style.position = "fixed";
|
||||
field.style.opacity = "0";
|
||||
document.body.appendChild(field);
|
||||
field.select();
|
||||
try {
|
||||
document.execCommand("copy");
|
||||
} catch {
|
||||
}
|
||||
field.remove();
|
||||
}
|
||||
|
||||
async function copyCode() {
|
||||
const code = voucherCode.textContent.trim();
|
||||
if (!code || code === "..." || code.startsWith("code wordt")) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await navigator.clipboard.writeText(code);
|
||||
} catch {
|
||||
legacyCopy(code);
|
||||
}
|
||||
|
||||
copyButton.textContent = "Gekopieerd";
|
||||
copyButton.classList.add("is-copied");
|
||||
voucherNote.textContent = "De code staat op je klembord.";
|
||||
voucherNote.style.color = "";
|
||||
window.setTimeout(() => {
|
||||
copyButton.textContent = "Kopieer";
|
||||
copyButton.classList.remove("is-copied");
|
||||
}, 2200);
|
||||
}
|
||||
|
||||
function bindEvents() {
|
||||
$$(".tool-btn").forEach((button) => {
|
||||
button.addEventListener("click", () => selectTool(button.dataset.tool));
|
||||
});
|
||||
|
||||
document.addEventListener("keydown", (event) => {
|
||||
if (event.key === "1") {
|
||||
selectTool("hamer");
|
||||
} else if (event.key === "2") {
|
||||
selectTool("koevoet");
|
||||
}
|
||||
});
|
||||
|
||||
soundButton.addEventListener("click", () => {
|
||||
state.soundOn = !state.soundOn;
|
||||
try {
|
||||
window.localStorage.setItem("jos-sloop-geluid", state.soundOn ? "aan" : "uit");
|
||||
} catch {
|
||||
}
|
||||
updateSoundButton();
|
||||
if (state.soundOn) {
|
||||
playTone({ freq: 660, endFreq: 880, type: "triangle", duration: 0.12, gain: 0.09 });
|
||||
}
|
||||
});
|
||||
|
||||
copyButton.addEventListener("click", copyCode);
|
||||
playAgainButton.addEventListener("click", resetGame);
|
||||
window.addEventListener("resize", () => {
|
||||
if (state.confettiParticles.length > 0) {
|
||||
resizeConfetti();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function init() {
|
||||
$$(".object").forEach((element) => {
|
||||
element.disabled = true;
|
||||
});
|
||||
|
||||
updateSoundButton();
|
||||
bindEvents();
|
||||
|
||||
try {
|
||||
const response = await fetch("/api/config", { cache: "no-store" });
|
||||
if (!response.ok) {
|
||||
throw new Error("De spellijn is niet bereikbaar.");
|
||||
}
|
||||
const config = await response.json();
|
||||
state.config = config;
|
||||
applyConfig(config);
|
||||
buildObjects(config);
|
||||
setLog("Kies je werktuig en sla de kamer kort en klein. Alles moet weg, ook de spiegel.");
|
||||
} catch (error) {
|
||||
setLog(`De kamer kon niet geladen worden: ${error.message}`, "warning");
|
||||
progressText.textContent = "Niet geladen";
|
||||
progressPercent.textContent = "—";
|
||||
}
|
||||
}
|
||||
|
||||
init();
|
||||
})();
|
||||
@@ -0,0 +1,355 @@
|
||||
<!doctype html>
|
||||
<html lang="nl">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="theme-color" content="#171512">
|
||||
<meta name="description" content="Sloop de kamer van Jos met hamer en koevoet en vind de cadeaubon.">
|
||||
<title>De Grote Sloop van Jos</title>
|
||||
<link rel="stylesheet" href="style.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="page">
|
||||
<header class="hero">
|
||||
<p class="eyebrow"><span id="recipient-name">Jos</span> wordt gevierd op <span id="event-date">18 oktober</span></p>
|
||||
<h1 id="game-title">De Grote Sloop van Jos</h1>
|
||||
<p class="tagline" id="game-subtitle">Sloop de kamer, vind je cadeaubon</p>
|
||||
</header>
|
||||
|
||||
<main class="game-shell" id="game-shell">
|
||||
<div class="hud">
|
||||
<div class="toolbar" role="group" aria-label="Kies je werktuig">
|
||||
<button type="button" class="tool-btn is-active" data-tool="hamer" aria-pressed="true">
|
||||
<svg viewBox="0 0 48 48" aria-hidden="true" focusable="false">
|
||||
<g fill="currentColor">
|
||||
<path d="M25.6 5.2 38.4 11l-3.1 6.7-12.8-5.8z"/>
|
||||
<path d="m28.2 17.2 5.3 2.4-15.2 25.6-5.3-3.1z"/>
|
||||
</g>
|
||||
</svg>
|
||||
<span class="tool-name">Hamer</span>
|
||||
<kbd>1</kbd>
|
||||
</button>
|
||||
<button type="button" class="tool-btn" data-tool="koevoet" aria-pressed="false">
|
||||
<svg viewBox="0 0 48 48" aria-hidden="true" focusable="false">
|
||||
<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path d="M10 42 29 15" stroke-width="5"/>
|
||||
<path d="M29 15c2.1-4.5 6.5-6.5 10.2-4.2l-3.1 5.1c-1.7-.8-3.2 0-4.2 2.1z" fill="currentColor" stroke-width="1.5"/>
|
||||
<path d="m10 42-2.8 3.4 6 1.4z" fill="currentColor" stroke-width="1.5"/>
|
||||
</g>
|
||||
</svg>
|
||||
<span class="tool-name">Koevoet</span>
|
||||
<kbd>2</kbd>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="progress" aria-live="polite">
|
||||
<div class="progress-copy">
|
||||
<span id="progress-text">0 / 8 stukken gesloopt</span>
|
||||
<span id="progress-percent">0%</span>
|
||||
</div>
|
||||
<div class="progress-track" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0" id="progress-track">
|
||||
<span id="progress-bar"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button type="button" class="icon-btn" id="sound-toggle" aria-pressed="true" aria-label="Geluid dempen" title="Geluid dempen">
|
||||
<svg class="sound-on" viewBox="0 0 32 32" aria-hidden="true" focusable="false">
|
||||
<path d="M5 12h5l6-5v18l-6-5H5z" fill="currentColor"/>
|
||||
<path d="M20 11c1.7 1.2 2.7 3 2.7 5s-1 3.8-2.7 5M23.5 7.5C26.2 9.4 28 12.1 28 16s-1.8 6.6-4.5 8.5" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round"/>
|
||||
</svg>
|
||||
<svg class="sound-off" viewBox="0 0 32 32" aria-hidden="true" focusable="false">
|
||||
<path d="M5 12h5l6-5v18l-6-5H5z" fill="currentColor"/>
|
||||
<path d="m21 12 8 8m0-8-8 8" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round"/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<section class="stage" aria-label="Kamer om te slopen">
|
||||
<div class="room" id="room">
|
||||
<div class="room-decor" aria-hidden="true">
|
||||
<div class="wallpaper"></div>
|
||||
<div class="ceiling-band"></div>
|
||||
<div class="bunting">
|
||||
<span></span><span></span><span></span><span></span><span></span><span></span>
|
||||
</div>
|
||||
<div class="wall-lamp">
|
||||
<span class="lamp-cord"></span>
|
||||
<span class="lamp-shade"></span>
|
||||
</div>
|
||||
<div class="floor"></div>
|
||||
<div class="rug"></div>
|
||||
<div class="baseboard"></div>
|
||||
<div class="wall-stain stain-one"></div>
|
||||
<div class="wall-stain stain-two"></div>
|
||||
<div class="debris-bed"></div>
|
||||
<div class="dust"></div>
|
||||
</div>
|
||||
|
||||
<button type="button" class="object obj-deur" data-id="deur" aria-label="Deur slopen">
|
||||
<span class="art">
|
||||
<svg viewBox="0 0 110 200" aria-hidden="true" focusable="false">
|
||||
<rect x="2" y="3" width="106" height="194" rx="3" fill="#4e331f"/>
|
||||
<rect x="10" y="11" width="90" height="179" rx="2" fill="#8a5b34"/>
|
||||
<rect x="18" y="22" width="74" height="64" rx="2" fill="#744924"/>
|
||||
<rect x="18" y="96" width="74" height="80" rx="2" fill="#744924"/>
|
||||
<rect x="25" y="29" width="60" height="50" rx="1" fill="#9a673c"/>
|
||||
<rect x="25" y="103" width="60" height="66" rx="1" fill="#9a673c"/>
|
||||
<circle cx="88" cy="101" r="4" fill="#e6bd58"/>
|
||||
<rect x="90" y="97" width="8" height="8" rx="3" fill="#c99a3f"/>
|
||||
<rect x="4" y="24" width="6" height="16" rx="2" fill="#b58b45"/>
|
||||
<rect x="4" y="160" width="6" height="16" rx="2" fill="#b58b45"/>
|
||||
|
||||
</svg>
|
||||
</span>
|
||||
<span class="damage" aria-hidden="true">
|
||||
<svg viewBox="0 0 100 100" preserveAspectRatio="none"><path class="c1" d="M49 0 45 25 53 41 44 67 50 100"/><path class="c2" d="M0 46 28 41 45 25M53 41 76 34 100 40"/><path class="c3" d="M20 100 33 74 44 67M76 34 70 57 84 77"/></svg>
|
||||
</span>
|
||||
</button>
|
||||
|
||||
<button type="button" class="object obj-spiegel" data-id="spiegel" aria-label="Spiegel slopen">
|
||||
<span class="art">
|
||||
<svg viewBox="0 0 100 160" aria-hidden="true" focusable="false">
|
||||
<defs>
|
||||
<linearGradient id="mirror-glass" x1="0" y1="0" x2="1" y2="1">
|
||||
<stop offset="0" stop-color="#eaf8fb"/>
|
||||
<stop offset=".3" stop-color="#a9d6e1"/>
|
||||
<stop offset=".55" stop-color="#d5eef4"/>
|
||||
<stop offset=".8" stop-color="#7fb3c2"/>
|
||||
<stop offset="1" stop-color="#598fa0"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="mirror-frame" x1="0" y1="0" x2="0" y2="1">
|
||||
<stop offset="0" stop-color="#f1d07f"/>
|
||||
<stop offset=".5" stop-color="#c99a3f"/>
|
||||
<stop offset="1" stop-color="#946821"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<path d="M8 30Q8 8 50 8t42 22v114q0 10-10 10H18q-10 0-10-10Z" fill="url(#mirror-frame)"/>
|
||||
<path d="M15 30q0-15 35-15t35 15v113q0 4-4 4H19q-4 0-4-4Z" fill="url(#mirror-glass)"/>
|
||||
<path d="m22 29 27-14-13 57Z" fill="#fff" opacity=".45"/>
|
||||
<path d="m58 92 20-50 6 14-18 56Z" fill="#fff" opacity=".22"/>
|
||||
<path d="m21 122 14-26 9 36Z" fill="#fff" opacity=".16"/>
|
||||
<rect x="8" y="30" width="84" height="124" rx="12" fill="none" stroke="#7a5518" stroke-opacity=".45"/>
|
||||
<g class="mirror-cracks" fill="none" stroke="#22404a" stroke-width="1.15" stroke-linecap="round">
|
||||
<path class="crack crack-1" d="M58 16 52 46 63 61 54 84 60 112 56 146"/>
|
||||
<path class="crack crack-1" d="m63 61 19-7M54 84 31 76M60 112l19 7"/>
|
||||
<path class="crack crack-2" d="M15 58 37 52 52 46M85 88 68 81 63 61M19 127 37 116 54 84"/>
|
||||
<path class="crack crack-3" d="M15 94 29 88 31 76M85 130 70 128 60 112M34 147 42 128 56 146"/>
|
||||
</g>
|
||||
</svg>
|
||||
</span>
|
||||
</button>
|
||||
|
||||
<button type="button" class="object obj-schilderij" data-id="schilderij" aria-label="Schilderij slopen">
|
||||
<span class="art">
|
||||
<svg viewBox="0 0 120 90" aria-hidden="true" focusable="false">
|
||||
<defs>
|
||||
<linearGradient id="paint-sky" x1="0" y1="0" x2="0" y2="1">
|
||||
<stop offset="0" stop-color="#f8d9a0"/>
|
||||
<stop offset=".65" stop-color="#eaa36d"/>
|
||||
<stop offset="1" stop-color="#c97854"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint-sea" x1="0" y1="0" x2="0" y2="1">
|
||||
<stop offset="0" stop-color="#4c8b9b"/>
|
||||
<stop offset="1" stop-color="#255565"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<rect x="2" y="2" width="116" height="86" rx="3" fill="#5d3a22"/>
|
||||
<rect x="8" y="8" width="104" height="74" rx="1" fill="#c99a3f"/>
|
||||
<rect x="12" y="12" width="96" height="62" fill="url(#paint-sky)"/>
|
||||
<circle cx="78" cy="31" r="11" fill="#fff0bf" opacity=".9"/>
|
||||
<rect x="12" y="50" width="96" height="24" fill="url(#paint-sea)"/>
|
||||
<path d="M12 51h96M18 58h18M54 58h30M31 65h22M66 66h25" stroke="#f3e4c4" stroke-width="1.5" opacity=".55"/>
|
||||
<path d="M47 49h18l-4 6H50Z" fill="#3c2718"/>
|
||||
<path d="m56 50 1-13 8 13" fill="#f6ead0"/>
|
||||
<path d="M64 37v13" stroke="#5d3a22" stroke-width="1.2"/>
|
||||
<rect x="8" y="8" width="104" height="74" fill="none" stroke="#8a5d21" stroke-width="2"/>
|
||||
<rect x="12" y="12" width="96" height="62" fill="none" stroke="#6b4425" stroke-opacity=".55"/>
|
||||
</svg>
|
||||
</span>
|
||||
<span class="damage" aria-hidden="true">
|
||||
<svg viewBox="0 0 100 100" preserveAspectRatio="none"><path class="c1" d="M50 0 46 27 54 44 45 68 51 100"/><path class="c2" d="M0 45 27 40 46 27M54 44 78 36 100 42"/><path class="c3" d="M18 100 33 74 45 68M78 36 71 59 86 78"/></svg>
|
||||
</span>
|
||||
</button>
|
||||
|
||||
<button type="button" class="object obj-klok" data-id="klok" aria-label="Muurklok slopen">
|
||||
<span class="art">
|
||||
<svg viewBox="0 0 100 100" aria-hidden="true" focusable="false">
|
||||
<circle cx="50" cy="50" r="47" fill="#3d2a1c"/>
|
||||
<circle cx="50" cy="50" r="42" fill="#f3e4c1"/>
|
||||
<circle cx="50" cy="50" r="42" fill="none" stroke="#c99a3f" stroke-width="2"/>
|
||||
<g stroke="#5b4227" stroke-width="2.2" stroke-linecap="round">
|
||||
<path d="M50 13v6M50 81v6M13 50h6M81 50h6"/>
|
||||
<path d="M26 26l4 4M70 70l4 4M74 26l-4 4M30 70l-4 4" stroke-width="1.4" opacity=".6"/>
|
||||
</g>
|
||||
<g stroke="#3d2a1c" stroke-linecap="round">
|
||||
<path d="M50 50 49 74" stroke-width="4"/>
|
||||
<path d="m50 50 17-11" stroke-width="3"/>
|
||||
</g>
|
||||
<circle cx="50" cy="50" r="4" fill="#c99a3f"/>
|
||||
<circle cx="50" cy="50" r="2" fill="#3d2a1c"/>
|
||||
</svg>
|
||||
</span>
|
||||
<span class="damage" aria-hidden="true">
|
||||
<svg viewBox="0 0 100 100" preserveAspectRatio="none"><path class="c1" d="M50 0 46 31 55 48 47 75 51 100"/><path class="c2" d="M0 48 29 42 46 31M55 48 79 41 100 47"/><path class="c3" d="M16 100 32 76 47 75M79 41 70 64 87 82"/></svg>
|
||||
</span>
|
||||
</button>
|
||||
|
||||
<button type="button" class="object obj-kast" data-id="kast" aria-label="Boekenkast slopen">
|
||||
<span class="art">
|
||||
<svg viewBox="0 0 120 200" aria-hidden="true" focusable="false">
|
||||
<rect x="3" y="3" width="114" height="194" rx="4" fill="#5f3f26"/>
|
||||
<rect x="11" y="11" width="98" height="178" fill="#352317"/>
|
||||
<rect x="11" y="68" width="98" height="5" fill="#7b5330"/>
|
||||
<rect x="11" y="126" width="98" height="5" fill="#7b5330"/>
|
||||
<rect x="11" y="184" width="98" height="5" fill="#7b5330"/>
|
||||
<g>
|
||||
<rect x="17" y="22" width="11" height="46" rx="1" fill="#b9553f"/>
|
||||
<rect x="30" y="18" width="9" height="50" rx="1" fill="#4f7d75"/>
|
||||
<rect x="41" y="25" width="13" height="43" rx="1" fill="#d09a45"/>
|
||||
<rect x="56" y="20" width="8" height="48" rx="1" fill="#6b5b95"/>
|
||||
<rect x="66" y="27" width="12" height="41" rx="1" fill="#a63c3c"/>
|
||||
<path d="m81 68 10-45 9 2-10 43Z" fill="#49728f"/>
|
||||
<rect x="93" y="24" width="10" height="44" rx="1" fill="#7d8f4b"/>
|
||||
</g>
|
||||
<g>
|
||||
<rect x="17" y="78" width="10" height="48" rx="1" fill="#4f7d75"/>
|
||||
<rect x="29" y="74" width="12" height="52" rx="1" fill="#c0703f"/>
|
||||
<rect x="43" y="80" width="8" height="46" rx="1" fill="#d4b156"/>
|
||||
<rect x="53" y="76" width="13" height="50" rx="1" fill="#7c4d6b"/>
|
||||
<rect x="68" y="82" width="9" height="44" rx="1" fill="#4b6f95"/>
|
||||
<rect x="79" y="77" width="12" height="49" rx="1" fill="#8b4a3c"/>
|
||||
<rect x="93" y="83" width="10" height="43" rx="1" fill="#5d7a4a"/>
|
||||
</g>
|
||||
<g>
|
||||
<rect x="17" y="136" width="12" height="48" rx="1" fill="#8b4a3c"/>
|
||||
<rect x="31" y="132" width="9" height="52" rx="1" fill="#d09a45"/>
|
||||
<rect x="42" y="138" width="11" height="46" rx="1" fill="#4f7d75"/>
|
||||
<rect x="55" y="134" width="8" height="50" rx="1" fill="#a63c3c"/>
|
||||
<rect x="65" y="139" width="12" height="45" rx="1" fill="#6b5b95"/>
|
||||
<rect x="79" y="135" width="9" height="49" rx="1" fill="#c0703f"/>
|
||||
<rect x="90" y="140" width="13" height="44" rx="1" fill="#49728f"/>
|
||||
</g>
|
||||
<path d="M11 11h98v178H11Z" fill="none" stroke="#8a6238" stroke-width="2"/>
|
||||
</svg>
|
||||
</span>
|
||||
<span class="damage" aria-hidden="true">
|
||||
<svg viewBox="0 0 100 100" preserveAspectRatio="none"><path class="c1" d="M52 0 48 24 56 40 47 66 53 100"/><path class="c2" d="M0 44 26 39 48 24M56 40 78 32 100 38"/><path class="c3" d="M18 100 34 73 47 66M78 32 70 57 86 78"/></svg>
|
||||
</span>
|
||||
</button>
|
||||
|
||||
<button type="button" class="object obj-plant" data-id="plant" aria-label="Plant slopen">
|
||||
<span class="art">
|
||||
<svg viewBox="0 0 100 160" aria-hidden="true" focusable="false">
|
||||
<path d="M50 116c-2-22 2-40 12-55" fill="none" stroke="#3f6b3a" stroke-width="4" stroke-linecap="round"/>
|
||||
<path d="M50 118c-6-18-16-30-28-38" fill="none" stroke="#3f6b3a" stroke-width="4" stroke-linecap="round"/>
|
||||
<path d="M50 120c5-15 15-25 26-31" fill="none" stroke="#3f6b3a" stroke-width="4" stroke-linecap="round"/>
|
||||
<path d="M62 61c-2-20 9-34 24-37-2 18-9 30-24 37Z" fill="#4f8747"/>
|
||||
<path d="M59 74c-12-14-12-29-6-41 13 10 18 24 6 41Z" fill="#67a05a"/>
|
||||
<path d="M22 80c4-17 16-27 31-26-6 16-16 24-31 26Z" fill="#477c42"/>
|
||||
<path d="M29 91c-12-8-18-20-16-32 14 5 23 15 16 32Z" fill="#5f9954"/>
|
||||
<path d="M76 89c11-7 17-18 16-30-13 4-22 14-16 30Z" fill="#397036"/>
|
||||
<path d="M50 116c-3-11-3-22 0-33 3 11 4 22 0 33Z" fill="#77ab68"/>
|
||||
<path d="M20 116h60l-7 40H27Z" fill="#b2603d"/>
|
||||
<path d="M20 116h60l-2 10H22Z" fill="#c97a52"/>
|
||||
<path d="M27 156h46l-1 4H28Z" fill="#8d4328"/>
|
||||
<path d="M30 124h40" stroke="#8d4328" stroke-width="2" opacity=".5"/>
|
||||
</svg>
|
||||
</span>
|
||||
<span class="damage" aria-hidden="true">
|
||||
<svg viewBox="0 0 100 100" preserveAspectRatio="none"><path class="c1" d="M50 8 46 34 55 50 46 72 52 100"/><path class="c2" d="M0 48 28 43 46 34M55 50 80 44 100 50"/><path class="c3" d="M18 100 33 77 46 72M80 44 72 66 88 84"/></svg>
|
||||
</span>
|
||||
</button>
|
||||
|
||||
<button type="button" class="object obj-zetel" data-id="zetel" aria-label="Zetel slopen">
|
||||
<span class="art">
|
||||
<svg viewBox="0 0 220 140" aria-hidden="true" focusable="false">
|
||||
<rect x="24" y="14" width="172" height="72" rx="22" fill="#3f6f6a"/>
|
||||
<rect x="38" y="28" width="66" height="46" rx="14" fill="#4e837d"/>
|
||||
<rect x="116" y="28" width="66" height="46" rx="14" fill="#4e837d"/>
|
||||
<rect x="12" y="52" width="196" height="58" rx="16" fill="#467a74"/>
|
||||
<rect x="12" y="52" width="32" height="64" rx="16" fill="#39716b"/>
|
||||
<rect x="176" y="52" width="32" height="64" rx="16" fill="#39716b"/>
|
||||
<rect x="35" y="72" width="150" height="30" rx="10" fill="#5b8f89"/>
|
||||
<rect x="43" y="76" width="60" height="22" rx="8" fill="#6b9d96"/>
|
||||
<rect x="117" y="76" width="60" height="22" rx="8" fill="#6b9d96"/>
|
||||
<rect x="150" y="54" width="32" height="28" rx="7" fill="#c47d4f" transform="rotate(8 166 68)"/>
|
||||
<rect x="42" y="108" width="10" height="22" rx="3" fill="#4a331f"/>
|
||||
<rect x="168" y="108" width="10" height="22" rx="3" fill="#4a331f"/>
|
||||
<path d="M39 63c20 10 60 12 82 2" fill="none" stroke="#7aa9a2" stroke-width="2" opacity=".6"/>
|
||||
</svg>
|
||||
</span>
|
||||
<span class="damage" aria-hidden="true">
|
||||
<svg viewBox="0 0 100 100" preserveAspectRatio="none"><path class="c1" d="M52 0 47 28 56 45 46 70 53 100"/><path class="c2" d="M0 44 27 39 47 28M56 45 79 37 100 44"/><path class="c3" d="M17 100 33 73 46 70M79 37 71 60 87 79"/></svg>
|
||||
</span>
|
||||
</button>
|
||||
|
||||
<button type="button" class="object obj-tafel" data-id="tafel" aria-label="Salontafel slopen">
|
||||
<span class="art">
|
||||
<svg viewBox="0 0 200 100" aria-hidden="true" focusable="false">
|
||||
<path d="M18 30h164l-9 18H27Z" fill="#8a5b34"/>
|
||||
<path d="M27 48h146v8H27Z" fill="#6d4527"/>
|
||||
<rect x="36" y="56" width="9" height="34" rx="2" fill="#5f3b20"/>
|
||||
<rect x="155" y="56" width="9" height="34" rx="2" fill="#5f3b20"/>
|
||||
<path d="M54 28h28l-2 18H56Z" fill="#d6b15b"/>
|
||||
<path d="M60 23h18l2 5H58Z" fill="#ead6a0"/>
|
||||
<path d="M108 18h24v12h-24Z" fill="#f1e4c8"/>
|
||||
<path d="M112 21h16M112 25h12" stroke="#9e8d70" stroke-width="1.4"/>
|
||||
<path d="M148 20h14v10h-14Z" fill="#c46c4b"/>
|
||||
<path d="M162 21h6v8h-6Z" fill="#c46c4b"/>
|
||||
<path d="M151 30h9v1.5h-9Z" fill="#8d4328"/>
|
||||
<path d="M18 30h164" stroke="#a56f42" stroke-width="2"/>
|
||||
</svg>
|
||||
</span>
|
||||
<span class="damage" aria-hidden="true">
|
||||
<svg viewBox="0 0 100 100" preserveAspectRatio="none"><path class="c1" d="M50 0 46 30 55 47 47 73 52 100"/><path class="c2" d="M0 47 28 42 46 30M55 47 79 40 100 47"/><path class="c3" d="M18 100 33 76 47 73M79 40 71 63 87 82"/></svg>
|
||||
</span>
|
||||
</button>
|
||||
|
||||
<div class="room-tag" aria-hidden="true">SLOOPZONE 18/10</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div class="underbar">
|
||||
<p class="log" id="log" role="status" aria-live="polite">Kamer wordt klaargezet...</p>
|
||||
<div class="chips" id="chips" aria-label="Slooplijst"></div>
|
||||
</div>
|
||||
|
||||
<p class="controls-hint">Klik op een stuk om te slaan. Wissel van werktuig met <kbd>1</kbd> en <kbd>2</kbd>. Glas vraagt een hamer, vastgeschroefd werk een koevoet.</p>
|
||||
</main>
|
||||
|
||||
<footer class="footer">
|
||||
<span>Met liefde gesloopt voor <span id="footer-name">Jos</span></span>
|
||||
<span class="footer-date" id="footer-date">18 oktober</span>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
<canvas id="confetti" aria-hidden="true"></canvas>
|
||||
|
||||
<div class="modal" id="modal" hidden>
|
||||
<div class="modal-backdrop"></div>
|
||||
<section class="voucher" role="dialog" aria-modal="true" aria-labelledby="voucher-title" aria-describedby="voucher-lead">
|
||||
<p class="voucher-kicker">Sloopbewijs nr. 18/10</p>
|
||||
<h2 id="voucher-title">Kamer met succes gesloopt</h2>
|
||||
<p class="voucher-lead" id="voucher-lead">Jos, het stofmasker mag af. Onder het behang zat een envelop met je cadeau.</p>
|
||||
|
||||
<div class="voucher-card">
|
||||
<span class="voucher-label">Cadeaubon</span>
|
||||
<span class="voucher-recipient" id="voucher-recipient">Voor Jos</span>
|
||||
<div class="voucher-code-row">
|
||||
<code id="voucher-code">...</code>
|
||||
<button type="button" class="copy-btn" id="copy-code">Kopieer</button>
|
||||
</div>
|
||||
<span class="voucher-foot"><span id="voucher-date">18 oktober</span> · Geldig op vertoon van een brede glimlach</span>
|
||||
</div>
|
||||
|
||||
<p class="voucher-note" id="voucher-note" role="status"></p>
|
||||
|
||||
<div class="modal-actions">
|
||||
<button type="button" class="primary-btn" id="play-again">Nog eens slopen</button>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<script src="game.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user