{"id":412,"date":"2026-11-19T08:19:59","date_gmt":"2026-11-19T08:19:59","guid":{"rendered":"https:\/\/www.jochberg.nl\/index.php\/ski-game\/"},"modified":"2026-11-19T09:05:29","modified_gmt":"2026-11-19T09:05:29","slug":"ski-game","status":"publish","type":"page","link":"https:\/\/www.jochberg.nl\/index.php\/en\/ski-game\/","title":{"rendered":"Ski game: dodge the trees"},"content":{"rendered":"\n<div class=\"wp-block-group hf-section hf-pagehead hf-skigame-head\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\">\n<p class=\"hf-kicker wp-block-paragraph\">Game<\/p>\n\n\n\n<h1 class=\"wp-block-heading hf-page-title\">Ski game: dodge the trees<\/h1>\n\n\n\n<p class=\"hf-lead wp-block-paragraph\">Waiting for real snow? Start skiing down the slope above Jochberg right here. Steer with your mouse or finger, dodge the fir trees and see how far you get.<\/p>\n\n\n\n<div class=\"hf-skigame\" data-score=\"Points\" data-best=\"Best\"><canvas class=\"hf-skigame-canvas\" role=\"img\" aria-label=\"Ski game: a skier racing down a snowy slope between fir trees\"><\/canvas><div class=\"hf-skigame-screen hf-skigame-start\"><p class=\"hf-skigame-title\">Skiing in Jochberg<\/p><p class=\"hf-skigame-text\">Move your mouse or finger left and right to dodge the trees. Ski through the red gates for 50 bonus points.<\/p><button type=\"button\" class=\"hf-skigame-btn\" data-ski=\"start\">Start<\/button><p class=\"hf-skigame-keys\">On a computer you can also use the arrow keys.<\/p><\/div><div class=\"hf-skigame-screen hf-skigame-over\" hidden><p class=\"hf-skigame-title\">Ouch, a tree!<\/p><p class=\"hf-skigame-text\">You scored <strong class=\"hf-skigame-final\">0<\/strong> points.<\/p><p class=\"hf-skigame-newbest\" hidden>New record!<\/p><form class=\"hf-skigame-form\" hidden novalidate data-m-saving=\"Saving\u2026\" data-m-ok=\"Saved! You are number {r} on the leaderboard.\" data-m-name=\"Please enter a name of 2 to 20 letters or numbers (and no swear words).\" data-m-captcha=\"Please tick the \u2018I\u2019m not a robot\u2019 box first.\" data-m-bot=\"The security check was not quite convinced. Please try again.\" data-m-rate=\"Please wait a moment before saving another score.\" data-m-error=\"Saving did not work. Please try again later.\"><label class=\"hf-skigame-label\" for=\"hf-skigame-name\">Put your score on the leaderboard<\/label><div class=\"hf-skigame-row\"><input id=\"hf-skigame-name\" class=\"hf-skigame-input\" type=\"text\" name=\"name\" maxlength=\"20\" autocomplete=\"nickname\" placeholder=\"Your name\" required><button type=\"submit\" class=\"hf-skigame-btn hf-skigame-save\">Save<\/button><\/div><div class=\"hf-skigame-captcha\"><\/div><\/form><p class=\"hf-skigame-msg\" role=\"status\" hidden><\/p><button type=\"button\" class=\"hf-skigame-btn\" data-ski=\"start\">Play again<\/button><\/div><div class=\"hf-skigame-screen hf-skigame-pause\" hidden><p class=\"hf-skigame-title\">Paused<\/p><button type=\"button\" class=\"hf-skigame-btn\" data-ski=\"resume\">Keep skiing<\/button><\/div><button type=\"button\" class=\"hf-skigame-sound\" aria-pressed=\"true\" aria-label=\"Sound\"><svg class=\"hf-ico-on\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M4 9v6h4l5 4V5L8 9H4z\" fill=\"currentColor\"\/><path d=\"M16 8.5a5 5 0 0 1 0 7M18.5 6a8.5 8.5 0 0 1 0 12\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\"\/><\/svg><svg class=\"hf-ico-off\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M4 9v6h4l5 4V5L8 9H4z\" fill=\"currentColor\"\/><path d=\"M16 9l6 6M22 9l-6 6\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\"\/><\/svg><\/button><\/div>\n\n\n\n<script id=\"hf-skigame-js\">(function () { 'use strict'; function clamp(v, a, b) { if (v > b) { return b; } if (a > v) { return a; } return v; } function rand(a, b) { return a + Math.random() * (b - a); } function lcg(seed) { var s = seed; return function () { s = (s * 9301 + 49297) % 233280; return s \/ 233280; }; } function HfSki(root) { var cv = root.querySelector('canvas'); if (!cv) { return; } var ctx = cv.getContext('2d'); if (!ctx) { return; } root.setAttribute('data-ready', '1'); if (!root.hasAttribute('tabindex')) { root.setAttribute('tabindex', '-1'); } var T_SCORE = root.getAttribute('data-score') || 'Score'; var T_BEST = root.getAttribute('data-best') || 'Best'; var scrStart = root.querySelector('.hf-skigame-start'); var scrOver = root.querySelector('.hf-skigame-over'); var scrPause = root.querySelector('.hf-skigame-pause'); var elFinal = root.querySelector('.hf-skigame-final'); var elNew = root.querySelector('.hf-skigame-newbest'); var lang = document.documentElement.getAttribute('lang') || 'nl'; var font = 'system-ui, sans-serif'; try { font = window.getComputedStyle(root).fontFamily || font; } catch (e0) { font = 'system-ui, sans-serif'; } var reduce = false; if (window.matchMedia) { reduce = window.matchMedia('(prefers-reduced-motion: reduce)').matches; } var ZP = 9, ZFAR = 150, PW = 0.28; var W = 0, H = 0, DPR = 1, HOR = 0, PY = 0, KP = 50, F = 450, CAMH = 5, LP = 4; var skyC = document.createElement('canvas'); var mtnC = document.createElement('canvas'); var state = 'idle'; var best = 0; try { best = parseInt(window.localStorage.getItem('hfSkiBest') || '0', 10) || 0; } catch (e1) { best = 0; } var objs = [], lanes = [], parts = [], pops = [], trail = [], clouds = []; var px = 0, pvx = 0, ptx = 0, lean = 0; var dist = 0, dist0 = 0, bonus = 0, score = 0, speed = 10; var nextRow = 14, nextGate = 0, lane = 0; var crashT = 0, crashDir = 1, shake = 0, flash = 0, idleT = 0; var keyL = false, keyR = false, isNew = false; var onScreen = true, raf = 0, last = 0; var sndBtn = root.querySelector('.hf-skigame-sound'); var AC = null, master = null, musicBus = null, fxBus = null; var muted = false, musicOn = false, musicTimer = 0, beat = 0, beatTime = 0; var SPB = 0.4; var MEL = [71, 1, 74, 1, 79, 1, 83, 1.5, 81, 0.5, 79, 1, 78, 1, 81, 1, 74, 1, 72, 1, 69, 1, 66, 1, 69, 1, 72, 1, 78, 1, 81, 1.5, 79, 0.5, 78, 1, 79, 1, 74, 1, 71, 1, 67, 2, 0, 1, 76, 1, 79, 1, 84, 1, 83, 1, 79, 1, 74, 1, 72, 0.5, 74, 0.5, 78, 1, 81, 1, 79, 1, 71, 1, 74, 1, 76, 0.5, 78, 0.5, 79, 1, 76, 1, 74, 1, 71, 1, 67, 1, 66, 1, 69, 1, 72, 1, 71, 1, 67, 2]; var CH = 'GGDDDDGGCGDGCGDG'; var melBeat = []; var form = root.querySelector('.hf-skigame-form'); var nameIn = form ? form.querySelector('input') : null; var msgEl = root.querySelector('.hf-skigame-msg'); var capBox = root.querySelector('.hf-skigame-captcha'); var board = document.querySelector('.hf-skigame-board'); var API = '\/?rest_route=\/hf-ski\/v1\/'; var gameTok = '', capKey = '', capVer = '', capState = 0, capWidget = -1, capQueue = [], saving = false, lastScore = 0; var lang2 = lang.slice(0, 2).toLowerCase(); try { muted = window.localStorage.getItem('hfSkiMute') === '1'; } catch (e20) { muted = false; } (function () { var i, pos = 0, b; for (i = 0; 48 > i; i += 1) { melBeat.push([]); } for (i = 0; MEL.length > i; i += 2) { if (MEL[i] > 0) { b = Math.floor(pos); melBeat[b].push([pos - b, MEL[i], MEL[i + 1]]); } pos += MEL[i + 1]; } })(); function mf(m) { return 440 * Math.pow(2, (m - 69) \/ 12); } function audioInit() { var Ctor; if (AC) { return true; } Ctor = window.AudioContext || window.webkitAudioContext; if (!Ctor) { return false; } try { AC = new Ctor(); } catch (e21) { AC = null; return false; } master = AC.createGain(); master.gain.value = muted ? 0 : 0.8; master.connect(AC.destination); musicBus = AC.createGain(); musicBus.gain.value = 0.22; musicBus.connect(master); fxBus = AC.createGain(); fxBus.gain.value = 0.55; fxBus.connect(master); return true; } function audioWake() { if (!AC) { return; } if (AC.state === 'suspended') { try { AC.resume(); } catch (e22) { return; } } } function squeeze(m, t, dur, vol, bus) { var f = mf(m), o1 = AC.createOscillator(), o2 = AC.createOscillator(), lp = AC.createBiquadFilter(), g = AC.createGain(); o1.type = 'sawtooth'; o2.type = 'square'; o1.frequency.value = f; o2.frequency.value = f * 1.006; lp.type = 'lowpass'; lp.frequency.value = Math.min(4200, f * 5); lp.Q.value = 0.8; g.gain.setValueAtTime(0.0001, t); g.gain.linearRampToValueAtTime(vol, t + 0.025); g.gain.linearRampToValueAtTime(vol * 0.7, t + Math.max(0.05, dur * 0.75)); g.gain.linearRampToValueAtTime(0.0001, t + dur); o1.connect(lp); o2.connect(lp); lp.connect(g); g.connect(bus); o1.start(t); o2.start(t); o1.stop(t + dur + 0.05); o2.stop(t + dur + 0.05); } function oom(m, t) { var o = AC.createOscillator(), g = AC.createGain(); o.type = 'triangle'; o.frequency.value = mf(m); g.gain.setValueAtTime(0.0001, t); g.gain.linearRampToValueAtTime(0.7, t + 0.012); g.gain.exponentialRampToValueAtTime(0.001, t + 0.34); o.connect(g); g.connect(musicBus); o.start(t); o.stop(t + 0.38); } function bell(t, k) { var fr = [587, 845, 1176, 1650], i, o, g; for (i = 0; fr.length > i; i += 1) { o = AC.createOscillator(); g = AC.createGain(); o.type = 'sine'; o.frequency.value = fr[i] * k; g.gain.setValueAtTime(0.0001, t); g.gain.linearRampToValueAtTime(0.45 \/ (i + 1), t + 0.004); g.gain.exponentialRampToValueAtTime(0.0001, t + 0.9 - i * 0.15); o.connect(g); g.connect(fxBus); o.start(t); o.stop(t + 0.95); } } function playBeat(b, t) { var bar = Math.floor(b \/ 3), ch = CH.charAt(bar), ev = melBeat[b], i, tones; if (0 === b % 3) { oom(ch === 'G' ? (bar % 2 ? 50 : 43) : (ch === 'D' ? (bar % 2 ? 45 : 50) : (bar % 2 ? 43 : 48)), t); } else { tones = ch === 'G' ? [59, 62, 67] : (ch === 'D' ? [57, 60, 66] : [60, 64, 67]); for (i = 0; tones.length > i; i += 1) { squeeze(tones[i], t, 0.16, 0.06, musicBus); } } for (i = 0; ev.length > i; i += 1) { squeeze(ev[i][1], t + ev[i][0] * SPB, ev[i][2] * SPB * 0.92, 0.16, musicBus); } } function musicTick() { if (!musicOn) { return; } if (!AC) { return; } while (AC.currentTime + 0.3 > beatTime) { playBeat(beat, beatTime); beat = (beat + 1) % 48; beatTime += SPB; } } function musicStart() { if (!AC) { return; } if (musicOn) { return; } if (muted) { return; } musicOn = true; beat = 0; beatTime = AC.currentTime + 0.1; musicTick(); musicTimer = window.setInterval(musicTick, 100); } function musicStop() { musicOn = false; if (musicTimer) { window.clearInterval(musicTimer); musicTimer = 0; } } function sfx(kind) { var t, i, len, buf, data, src, lp, g, o, og; if (!AC) { return; } if (muted) { return; } t = AC.currentTime + 0.01; if (kind === 'gate') { bell(t, 1); bell(t + 0.13, 1.19); } else if (kind === 'start') { bell(t, 0.84); } else if (kind === 'record') { squeeze(67, t, 0.14, 0.2, fxBus); squeeze(71, t + 0.14, 0.14, 0.2, fxBus); squeeze(74, t + 0.28, 0.14, 0.2, fxBus); squeeze(79, t + 0.42, 0.6, 0.22, fxBus); bell(t + 0.42, 1.3); } else { len = Math.floor(AC.sampleRate * 0.45); buf = AC.createBuffer(1, len, AC.sampleRate); data = buf.getChannelData(0); for (i = 0; len > i; i += 1) { data[i] = (Math.random() * 2 - 1) * Math.pow(1 - i \/ len, 2); } src = AC.createBufferSource(); lp = AC.createBiquadFilter(); g = AC.createGain(); src.buffer = buf; lp.type = 'lowpass'; lp.frequency.value = 1100; g.gain.value = 0.8; src.connect(lp); lp.connect(g); g.connect(fxBus); src.start(t); o = AC.createOscillator(); og = AC.createGain(); o.type = 'sine'; o.frequency.setValueAtTime(120, t); o.frequency.exponentialRampToValueAtTime(42, t + 0.3); og.gain.setValueAtTime(0.9, t); og.gain.exponentialRampToValueAtTime(0.001, t + 0.35); o.connect(og); og.connect(fxBus); o.start(t); o.stop(t + 0.4); if (kind === 'crash') { squeeze(67, t + 0.5, 0.26, 0.2, fxBus); squeeze(66, t + 0.78, 0.26, 0.2, fxBus); squeeze(65, t + 1.06, 0.26, 0.2, fxBus); squeeze(64, t + 1.34, 0.8, 0.2, fxBus); } } } function applyMute() { if (muted) { root.classList.add('is-muted'); } else { root.classList.remove('is-muted'); } if (sndBtn) { sndBtn.setAttribute('aria-pressed', muted ? 'false' : 'true'); } if (master) { master.gain.setTargetAtTime(muted ? 0 : 0.8, AC.currentTime, 0.02); } } function toggleMute() { muted = !muted; try { window.localStorage.setItem('hfSkiMute', muted ? '1' : '0'); } catch (e23) { muted = !!muted; } if (!muted) { if (audioInit()) { audioWake(); } } applyMute(); if (muted) { musicStop(); } else if (state === 'play') { musicStart(); } } function api(path, data, cb) { var opt = { method: data ? 'POST' : 'GET', headers: { Accept: 'application\/json' }, credentials: 'omit', cache: 'no-store' }; if (!window.fetch) { cb(null, 0); return; } if (data) { opt.headers['Content-Type'] = 'application\/json'; opt.body = JSON.stringify(data); } window.fetch(API + path, opt).then(function (res) { return res.json().then(function (j) { cb(j, res.status); }, function () { cb(null, res.status); }); }, function () { cb(null, 0); }); } function say(key, rank) { var t; if (!msgEl) { return; } t = form ? (form.getAttribute('data-' + key) || '') : ''; msgEl.textContent = t.split('{r}').join(String(rank || '')); msgEl.hidden = !t; } function capFail() { var q = capQueue, i; capState = 0; capQueue = []; for (i = 0; q.length > i; i += 1) { q[i](false); } } function capReady(cb) { var sc, amp = String.fromCharCode(38); if (!capKey) { cb(false); return; } if (capState === 2) { cb(true); return; } capQueue.push(cb); if (capState === 1) { return; } capState = 1; sc = document.createElement('script'); sc.async = true; sc.src = 'https:\/\/www.google.com\/recaptcha\/api.js?render=' + (capVer === 'v3' ? encodeURIComponent(capKey) : 'explicit') + amp + 'hl=' + lang2; sc.onload = function () { if (!window.grecaptcha) { capFail(); return; } window.grecaptcha.ready(function () { var q, i; if (capVer !== 'v3') { if (capBox) { try { capWidget = window.grecaptcha.render(capBox, { sitekey: capKey, size: W > 330 ? 'normal' : 'compact' }); } catch (e24) { capWidget = -1; } } } capState = 2; q = capQueue; capQueue = []; for (i = 0; q.length > i; i += 1) { q[i](true); } }); }; sc.onerror = capFail; document.head.appendChild(sc); } function capToken(cb) { capReady(function (ok) { if (!ok) { cb(''); return; } if (capVer === 'v3') { window.grecaptcha.execute(capKey, { action: 'skiscore' }).then(function (tk) { cb(tk || ''); }, function () { cb(''); }); } else { cb(capWidget >= 0 ? (window.grecaptcha.getResponse(capWidget) || '') : ''); } }); } function capReset() { if (capVer === 'v3') { return; } if (capWidget >= 0) { try { window.grecaptcha.reset(capWidget); } catch (e25) { capWidget = capWidget + 0; } } } function renderBoard(list, meName) { var ol, empty, i, li, a, b, pts, mine = false, me = String(meName || '').toLowerCase(); if (!board) { return; } ol = board.querySelector('ol'); empty = board.querySelector('.hf-skigame-board-empty'); if (!ol) { return; } while (ol.firstChild) { ol.removeChild(ol.firstChild); } for (i = 0; list.length > i; i += 1) { li = document.createElement('li'); a = document.createElement('span'); a.className = 'hf-skigame-rank'; a.textContent = String(i + 1); b = document.createElement('span'); b.className = 'hf-skigame-who'; b.textContent = String(list[i].n); pts = document.createElement('span'); pts.className = 'hf-skigame-pts'; pts.textContent = fmt(list[i].s); li.appendChild(a); li.appendChild(b); li.appendChild(pts); if (!mine) { if (me) { if (String(list[i].n).toLowerCase() === me) { li.className = 'is-you'; mine = true; } } } ol.appendChild(li); } if (empty) { empty.hidden = list.length > 0; } board.hidden = false; } function loadBoard() { if (!board) { return; } api('board', null, function (j) { if (j) { if (j.board) { renderBoard(j.board, ''); } } }); } function prepForm() { var showIt = false; if (msgEl) { msgEl.hidden = true; msgEl.textContent = ''; } if (!form) { return; } if (gameTok) { if (capKey) { showIt = score > 0; } } form.hidden = !showIt; if (showIt) { if (nameIn) { try { nameIn.value = window.localStorage.getItem('hfSkiName') || nameIn.value; } catch (e26) { nameIn.value = nameIn.value || ''; } } capReset(); } } function fmt(v) { var n = Math.round(v); try { return n.toLocaleString(lang); } catch (e2) { return String(n); } } function vLat() { return Math.max(6, LP * 1.9); } function diffAt(s) { if (state === 'idle') { return 0.12; } return clamp((s - dist0) \/ 3200, 0, 1); } function rowGap(d) { return 9 - 4 * d; } function speedFor(d) { return 12 + 15 * d; } function rr(x, y, w, h, rad) { ctx.beginPath(); ctx.moveTo(x + rad, y); ctx.arcTo(x + w, y, x + w, y + h, rad); ctx.arcTo(x + w, y + h, x, y + h, rad); ctx.arcTo(x, y + h, x, y, rad); ctx.arcTo(x, y, x + w, y, rad); ctx.closePath(); } function resize() { var r = root.getBoundingClientRect(); var w = Math.max(220, Math.round(r.width)); var h = Math.max(220, Math.round(r.height)); var d = Math.min(2, window.devicePixelRatio || 1); if (w === W) { if (h === H) { if (d === DPR) { return false; } } } W = w; H = h; DPR = d; cv.width = Math.round(W * DPR); cv.height = Math.round(H * DPR); HOR = Math.round(H * (H > W ? 0.3 : 0.34)); PY = Math.round(H * 0.86); KP = H * 0.105; F = KP * ZP; CAMH = (PY - HOR) \/ KP; LP = W \/ 2 \/ KP; px = clamp(px, -LP * 0.92, LP * 0.92); ptx = clamp(ptx, -LP * 0.92, LP * 0.92); buildBg(); return true; } function range(c, rnd, count, hMin, hMax, col, shade, snow, snowShade) { var step = W * 1.3 \/ (count - 1); var ref = Math.min(H, W * 0.85); var base = HOR + 3; var i, x, h, w, ax, ay; for (i = 0; count > i; i += 1) { x = -W * 0.15 + i * step + (rnd() - 0.5) * step * 0.6; h = ref * (hMin + rnd() * (hMax - hMin)); w = h * (1.25 + rnd() * 0.9); ax = x + (rnd() - 0.5) * w * 0.35; ay = base - h; c.fillStyle = col; c.beginPath(); c.moveTo(x - w, base); c.lineTo(ax, ay); c.lineTo(x + w, base); c.closePath(); c.fill(); c.fillStyle = shade; c.beginPath(); c.moveTo(x - w, base); c.lineTo(ax, ay); c.lineTo(ax + w * 0.15, base); c.closePath(); c.fill(); snowCap(c, rnd, x - w, ax, ay, x + w, base, snow, snowShade); } } function snowCap(c, rnd, lx, ax, ay, rx, base, snow, snowShade) { var t = 0.3 + rnd() * 0.12; var ly = ay + (base - ay) * t; var x1 = ax + (lx - ax) * t; var x2 = ax + (rx - ax) * t; var dh = (base - ay) * 0.07; var pts = []; var j; for (j = 1; 5 > j; j += 1) { pts.push([x1 + (x2 - x1) * j \/ 5, ly + (j % 2 === 1 ? -dh : dh * 0.4) * (0.6 + rnd() * 0.8)]); } c.fillStyle = snow; c.beginPath(); c.moveTo(ax, ay); c.lineTo(x1, ly); for (j = 0; pts.length > j; j += 1) { c.lineTo(pts[j][0], pts[j][1]); } c.lineTo(x2, ly); c.closePath(); c.fill(); c.fillStyle = snowShade; c.beginPath(); c.moveTo(ax, ay); c.lineTo(x1, ly); c.lineTo(pts[0][0], pts[0][1]); c.lineTo(pts[1][0], pts[1][1]); c.closePath(); c.fill(); } function forestLine(c, rnd) { var x = -6, h, w; var sc = Math.max(0.7, H \/ 520); c.fillStyle = '#4b6f63'; c.beginPath(); while (W + 6 > x) { if (rnd() > 0.86) { x += (14 + rnd() * 40) * sc; } else { h = (3 + rnd() * 6) * sc; w = (1.6 + rnd() * 2.2) * sc; c.moveTo(x - w, HOR + 1); c.lineTo(x, HOR + 1 - h); c.lineTo(x + w, HOR + 1); x += w * (0.8 + rnd() * 1.4); } } c.fill(); } function buildBg() { var c, g, sunX, sunY, sunR; skyC.width = cv.width; skyC.height = cv.height; mtnC.width = cv.width; mtnC.height = cv.height; c = skyC.getContext('2d'); c.setTransform(DPR, 0, 0, DPR, 0, 0); g = c.createLinearGradient(0, 0, 0, HOR + 10); g.addColorStop(0, '#1d6fd6'); g.addColorStop(0.6, '#56a3ef'); g.addColorStop(1, '#c4e4ff'); c.fillStyle = g; c.fillRect(0, 0, W, H); sunX = W * 0.8; sunY = H * 0.11; sunR = Math.max(14, Math.min(W, H) * 0.045); g = c.createRadialGradient(sunX, sunY, sunR * 0.6, sunX, sunY, sunR * 5); g.addColorStop(0, 'rgba(255,248,214,0.9)'); g.addColorStop(1, 'rgba(255,248,214,0)'); c.fillStyle = g; c.fillRect(0, 0, W, HOR + 10); c.fillStyle = '#fffbea'; c.beginPath(); c.arc(sunX, sunY, sunR, 0, Math.PI * 2); c.fill(); c = mtnC.getContext('2d'); c.setTransform(DPR, 0, 0, DPR, 0, 0); c.clearRect(0, 0, W, H); range(c, lcg(7), 10, 0.1, 0.2, '#a9c1df', 'rgba(60,92,145,0.18)', '#f6f9fd', '#d9e5f3'); range(c, lcg(31), 8, 0.05, 0.11, '#86a3c9', 'rgba(44,74,124,0.22)', '#ffffff', '#d3e0f0'); forestLine(c, lcg(13)); g = c.createLinearGradient(0, HOR, 0, H); g.addColorStop(0, '#d3e2f3'); g.addColorStop(0.3, '#eaf2fb'); g.addColorStop(1, '#ffffff'); c.fillStyle = g; c.fillRect(0, HOR, W, H - HOR); g = c.createLinearGradient(0, HOR - 26, 0, HOR + 30); g.addColorStop(0, 'rgba(255,255,255,0)'); g.addColorStop(0.5, 'rgba(255,255,255,0.5)'); g.addColorStop(1, 'rgba(255,255,255,0)'); c.fillStyle = g; c.fillRect(0, HOR - 26, W, 56); } function initClouds() { var i; clouds = []; for (i = 0; 5 > i; i += 1) { clouds.push({ fx: Math.random() * 1.2 - 0.1, fy: 0.04 + Math.random() * 0.15, s: 0.6 + Math.random() * 0.7, v: 0.004 + Math.random() * 0.008 }); } } function blob(x, y, rad) { ctx.moveTo(x + rad, y); ctx.arc(x, y, rad, 0, Math.PI * 2); } function drawClouds(dt) { var i, cl, x, y, s; var base = Math.min(W, H) \/ 420; ctx.fillStyle = 'rgba(255,255,255,0.9)'; for (i = 0; clouds.length > i; i += 1) { cl = clouds[i]; cl.fx += cl.v * dt; if (cl.fx > 1.3) { cl.fx = -0.3; cl.fy = 0.04 + Math.random() * 0.15; } x = cl.fx * W; y = cl.fy * H; s = cl.s * base; if (HOR - 12 > y + 26 * s) { ctx.beginPath(); blob(x, y, 20 * s); blob(x + 22 * s, y - 12 * s, 24 * s); blob(x + 48 * s, y - 2 * s, 20 * s); blob(x + 26 * s, y + 7 * s, 18 * s); blob(x - 18 * s, y + 6 * s, 14 * s); ctx.fill(); } } } function spawnRow(S) { var d = diffAt(S); var playing = state !== 'idle'; var gap = rowGap(d); var sp = playing ? speedFor(d) : 10; var drift = 0.42 * vLat() * gap \/ sp; var span = LP * 1.08; var i, j, x, h, bw, r, cnt, side, st, xp, clr; var pl = lane, pS = S - gap; if (lanes.length) { pl = lanes[lanes.length - 1].x; pS = lanes[lanes.length - 1].S; } lane = clamp(lane + rand(-1, 1) * drift, -LP * 0.78, LP * 0.78); lanes.push({ S: S, x: lane }); cnt = Math.floor((0.09 + 0.16 * d) * 2 * span + Math.random()); if (playing) { if (45 > S - dist0) { cnt = 0; } else if (S >= nextGate) { nextGate = S + rand(150, 260); objs.push({ t: 2, S: S, x: lane, w: 1.45, done: false, ok: false }); cnt = 0; } } for (i = 0; cnt > i; i += 1) { for (j = 0; 6 > j; j += 1) { x = rand(-span, span); h = rand(4, 7.2); bw = h * rand(0.26, 0.32); r = bw * 0.38; clr = r + PW + 0.4; st = S - rand(0, 0.45) * gap; xp = pl + (lane - pl) * clamp((st - pS) \/ Math.max(0.5, S - pS), 0, 1); if (Math.abs(x - lane) > clr) { if (Math.abs(x - xp) > clr) { objs.push({ t: 1, S: st, x: x, h: h, bw: bw, r: r, done: false, hit: false }); break; } } } } for (side = -1; 1 >= side; side += 2) { if (Math.random() > 0.22) { h = rand(4.5, 8.2); bw = h * rand(0.26, 0.32); objs.push({ t: 1, S: S + rand(-2, 2), x: side * (LP * 1.18 + Math.random() * LP * 2.6), h: h, bw: bw, r: bw * 0.38, done: false, hit: false }); } } for (i = 0; 3 > i; i += 1) { objs.push({ t: 3, S: S + rand(-4, 4), x: rand(-LP * 2.6, LP * 2.6), w: rand(0.7, 1.7), done: true }); } } function laneAhead() { var i; for (i = 0; lanes.length > i; i += 1) { if (lanes[i].S > dist + 3) { return lanes[i].x; } } return px; } function spray() { var dir = pvx > 0 ? -1 : 1; var u = KP \/ 60; parts.push({ x: W \/ 2 + (px + rand(-0.15, 0.15)) * KP, y: PY + 0.05 * KP, vx: dir * rand(40, 120) * u, vy: -rand(30, 110) * u, life: 0, max: rand(0.35, 0.6), rad: rand(1.2, 3.2) * u }); } function crash(o) { var i, u = KP \/ 60; state = 'crash'; crashT = 0; speed = 0; o.hit = true; objs = objs.filter(function (q) { return q.hit || q.t === 3 || q.S > dist; }); crashDir = o.x > px ? -1 : 1; shake = 1; keyL = false; keyR = false; root.classList.remove('is-playing'); musicStop(); sfx(score > best ? 'thud' : 'crash'); for (i = 0; 28 > i; i += 1) { parts.push({ x: W \/ 2 + px * KP, y: PY - KP * rand(0.2, 1.4), vx: rand(-160, 160) * u, vy: rand(-230, -40) * u, life: 0, max: rand(0.6, 1.1), rad: rand(2, 5) * u }); } } function hitTest(o) { var dx = Math.abs(o.x - px); if (o.t === 1) { if (o.r + PW > dx) { crash(o); } } else if (o.t === 2) { if (o.w - 0.1 > dx) { o.ok = true; bonus += 50; sfx('gate'); pops.push({ x: W \/ 2 + px * KP, y: PY - KP * 2.1, life: 0, txt: '+50' }); } } } function show(el, focus) { var all = [scrStart, scrOver, scrPause]; var i, b; for (i = 0; all.length > i; i += 1) { if (all[i]) { all[i].hidden = all[i] !== el; } } if (el) { if (focus) { b = el.querySelector('[data-ski]'); if (b) { try { b.focus({ preventScroll: true }); } catch (e3) { b.focus(); } } } } } function gameOver() { state = 'over'; isNew = false; if (score > best) { best = score; isNew = true; try { window.localStorage.setItem('hfSkiBest', String(best)); } catch (e4) { isNew = true; } } if (elFinal) { elFinal.textContent = fmt(score); } if (elNew) { elNew.hidden = !isNew; } lastScore = score; if (isNew) { sfx('record'); } prepForm(); show(scrOver, true); } function ensureVisible() { var r = root.getBoundingClientRect(); var vh = window.innerHeight || document.documentElement.clientHeight; if (0 > r.top || r.bottom > vh) { try { root.scrollIntoView({ block: 'center', behavior: 'smooth' }); } catch (e5) { root.scrollIntoView(); } } } function startGame() { objs = []; lanes = []; parts = []; pops = []; trail = []; dist0 = dist; bonus = 0; score = 0; lane = 0; px = 0; pvx = 0; ptx = 0; lean = 0; crashT = 0; shake = 0; nextRow = dist + 6; nextGate = dist + 140; speed = 12; state = 'play'; flash = 1; if (audioInit()) { audioWake(); } musicStop(); musicStart(); sfx('start'); gameTok = ''; api('start', {}, function (j) { if (j) { if (j.t) { gameTok = String(j.t); capKey = String(j.k || ''); capVer = String(j.v || ''); } } }); show(null, false); root.classList.add('is-playing'); try { root.focus({ preventScroll: true }); } catch (e6) { root.focus(); } ensureVisible(); kick(); } function pause() { if (state !== 'play') { return; } state = 'pause'; keyL = false; keyR = false; root.classList.remove('is-playing'); musicStop(); show(scrPause, true); } function resume() { if (state !== 'pause') { return; } state = 'play'; show(null, false); root.classList.add('is-playing'); audioWake(); musicStart(); try { root.focus({ preventScroll: true }); } catch (e7) { root.focus(); } ensureVisible(); kick(); } function update(dt) { var i, o, d, desired, turn, u; if (state === 'play') { d = clamp((dist - dist0) \/ 3200, 0, 1); speed += (speedFor(d) - speed) * Math.min(1, dt * 2); } else if (state === 'idle') { speed += (10 - speed) * Math.min(1, dt * 2); idleT += dt; } else { speed = 0; } dist += speed * dt; while (dist + ZFAR - ZP >= nextRow) { spawnRow(nextRow); nextRow += rowGap(diffAt(nextRow)); } while (lanes.length > 1) { if (dist - 2 > lanes[0].S) { lanes.shift(); } else { break; } } if (state === 'play') { if (keyL) { ptx -= vLat() * 1.15 * dt; } if (keyR) { ptx += vLat() * 1.15 * dt; } ptx = clamp(ptx, -LP * 0.92, LP * 0.92); } else if (state === 'idle') { ptx = laneAhead(); } if (state === 'play' || state === 'idle') { desired = clamp((ptx - px) * 10, -vLat(), vLat()); pvx += (desired - pvx) * Math.min(1, dt * 16); px = clamp(px + pvx * dt, -LP * 0.92, LP * 0.92); turn = Math.abs(pvx) \/ vLat(); if (turn > 0.3) { if (Math.random() * 1.6 > 1 - turn) { spray(); } } trail.push({ x: px, S: dist }); } else { pvx += (0 - pvx) * Math.min(1, dt * 6); } while (trail.length > 0) { if (dist - trail[0].S > ZP - 1.5) { trail.shift(); } else { break; } } if (trail.length > 400) { trail.splice(0, trail.length - 400); } lean += (clamp(pvx \/ vLat(), -1, 1) * 0.42 - lean) * Math.min(1, dt * 10); for (i = objs.length - 1; i >= 0; i -= 1) { o = objs[i]; if (1.6 > o.S - dist + ZP) { objs.splice(i, 1); continue; } if (o.t !== 3) { if (dist - o.S > 1.4) { if (!o.hit) { objs.splice(i, 1); continue; } } } if (!o.done) { if (dist >= o.S) { o.done = true; if (state === 'play') { hitTest(o); } } } } u = KP \/ 60; for (i = parts.length - 1; i >= 0; i -= 1) { o = parts[i]; o.life += dt; if (o.life > o.max) { parts.splice(i, 1); continue; } o.vy += 600 * u * dt; o.x += o.vx * dt; o.y += o.vy * dt; } for (i = pops.length - 1; i >= 0; i -= 1) { pops[i].life += dt \/ 0.9; if (pops[i].life >= 1) { pops.splice(i, 1); } } if (state === 'play') { score = Math.floor(dist - dist0) + bonus; } if (state === 'crash') { crashT += dt; if (crashT > 1.1) { gameOver(); } } shake = Math.max(0, shake - dt * 2.5); flash = Math.max(0, flash - dt * 2.5); } function drawBumps() { var i, o, z, kz, x, y; ctx.fillStyle = 'rgba(118,156,206,0.11)'; for (i = 0; objs.length > i; i += 1) { o = objs[i]; if (o.t !== 3) { continue; } z = o.S - dist + ZP; if (z > ZFAR) { continue; } if (1.6 > z) { continue; } kz = F \/ z; x = W \/ 2 + o.x * kz; if (0 > x + o.w * kz) { continue; } if (x - o.w * kz > W) { continue; } y = HOR + CAMH * kz; ctx.globalAlpha = clamp((ZFAR - z) \/ 30, 0, 1); ctx.beginPath(); ctx.ellipse(x, y, o.w * kz, Math.max(0.6, o.w * kz * 0.14), 0, 0, Math.PI); ctx.fill(); } ctx.globalAlpha = 1; } function drawTrail() { var side, i, p, z, kz; if (2 > trail.length) { return; } ctx.strokeStyle = 'rgba(128,163,209,0.5)'; ctx.lineWidth = Math.max(1, KP * 0.05); ctx.lineCap = 'round'; ctx.lineJoin = 'round'; for (side = -1; 1 >= side; side += 2) { ctx.beginPath(); for (i = 0; trail.length > i; i += 1) { p = trail[i]; z = ZP - (dist - p.S); kz = F \/ z; if (i === 0) { ctx.moveTo(W \/ 2 + (p.x + side * 0.13) * kz, HOR + CAMH * kz); } else { ctx.lineTo(W \/ 2 + (p.x + side * 0.13) * kz, HOR + CAMH * kz); } } ctx.stroke(); } } function tree(x, y, s, o) { var h = o.h * s, bw = o.bw * s; var th, tw, i, by, ty, hw, tierH; ctx.fillStyle = 'rgba(70,100,150,0.16)'; ctx.beginPath(); ctx.ellipse(x + bw * 0.3, y, bw * 1.05, Math.max(0.8, bw * 0.22), 0, 0, Math.PI * 2); ctx.fill(); if (14 > h) { ctx.fillStyle = '#2e4636'; ctx.beginPath(); ctx.moveTo(x - bw, y); ctx.lineTo(x, y - h); ctx.lineTo(x + bw, y); ctx.closePath(); ctx.fill(); return; } th = h * 0.1; tw = Math.max(1, bw * 0.17); ctx.fillStyle = '#5e4331'; ctx.fillRect(x - tw \/ 2, y - th - 1, tw, th + 1); tierH = h * 0.4; ty = y; for (i = 0; 3 > i; i += 1) { by = y - th - i * h * 0.26; ty = by - tierH; hw = bw * (1 - i * 0.27); ctx.fillStyle = '#284034'; ctx.beginPath(); ctx.moveTo(x - hw, by); ctx.lineTo(x, ty); ctx.lineTo(x + hw, by); ctx.closePath(); ctx.fill(); ctx.fillStyle = '#3b5e4a'; ctx.beginPath(); ctx.moveTo(x, ty); ctx.lineTo(x + hw, by); ctx.lineTo(x + hw * 0.08, by); ctx.closePath(); ctx.fill(); ctx.fillStyle = '#f7fbff'; ctx.beginPath(); ctx.moveTo(x - hw, by); ctx.lineTo(x - hw * 0.62, by - tierH * 0.15); ctx.lineTo(x - hw * 0.3, by - tierH * 0.06); ctx.lineTo(x, by - tierH * 0.17); ctx.lineTo(x + hw * 0.32, by - tierH * 0.06); ctx.lineTo(x + hw * 0.64, by - tierH * 0.14); ctx.lineTo(x + hw, by); ctx.lineTo(x + hw * 0.45, by + tierH * 0.045); ctx.lineTo(x - hw * 0.45, by + tierH * 0.045); ctx.closePath(); ctx.fill(); } hw = bw * 0.46; ctx.beginPath(); ctx.moveTo(x, ty); ctx.lineTo(x + hw * 0.32, ty + tierH * 0.24); ctx.lineTo(x, ty + tierH * 0.19); ctx.lineTo(x - hw * 0.32, ty + tierH * 0.24); ctx.closePath(); ctx.fill(); } function gate(x, y, s, o) { var w = o.w * s, h = 1.75 * s, pw = Math.max(1, 0.05 * s); var col = o.ok ? '#f0b429' : '#c8102e'; var side, gx; for (side = -1; 1 >= side; side += 2) { gx = x + side * w; ctx.fillStyle = 'rgba(70,100,150,0.2)'; ctx.beginPath(); ctx.ellipse(gx + 0.1 * s, y, 0.2 * s, Math.max(0.6, 0.05 * s), 0, 0, Math.PI * 2); ctx.fill(); ctx.fillStyle = '#39404d'; ctx.fillRect(gx - pw \/ 2, y - h, pw, h); ctx.fillStyle = col; ctx.beginPath(); ctx.moveTo(gx, y - h); ctx.lineTo(gx - side * 0.62 * s, y - h + 0.2 * s); ctx.lineTo(gx, y - h + 0.44 * s); ctx.closePath(); ctx.fill(); } } function drawObj(o, z) { var kz, x, y, a, half; if (z > ZFAR + 4) { return; } kz = F \/ z; x = W \/ 2 + o.x * kz; half = (o.t === 1 ? o.bw : o.w + 0.7) * kz; if (0 > x + half) { return; } if (x - half > W) { return; } y = HOR + CAMH * kz; a = 1; if (z > ZFAR - 25) { a = clamp((ZFAR - z) \/ 25, 0, 1); } if (ZP > z) { if (!o.hit) { a = clamp((z - ZP + 1.2) \/ 1.2, 0, 1); } } if (0.02 > a) { return; } ctx.globalAlpha = a; if (o.t === 1) { tree(x, y, kz, o); } else { gate(x, y, kz, o); } ctx.globalAlpha = 1; } function drawSkier() { var x = W \/ 2 + px * KP; var y = PY; var s = KP; var off = clamp(pvx \/ vLat(), -1, 1) * 0.16; var ang = lean; var drop = 0; var t, j, fx; if (state === 'crash' || state === 'over') { t = clamp(crashT \/ 0.45, 0, 1); ang = lean + crashDir * 1.4 * t; drop = 0.22 * t; off = 0; } ctx.fillStyle = 'rgba(60,90,140,0.22)'; ctx.beginPath(); ctx.ellipse(x + 0.1 * s, y + 0.03 * s, 0.52 * s, 0.11 * s, 0, 0, Math.PI * 2); ctx.fill(); ctx.save(); ctx.translate(x, y + drop * s); ctx.rotate(ang); ctx.scale(s, s); ctx.lineCap = 'round'; ctx.lineJoin = 'round'; ctx.strokeStyle = '#7c8696'; ctx.lineWidth = 0.03; for (j = -1; 1 >= j; j += 2) { ctx.beginPath(); ctx.moveTo(j * 0.42, -0.86); ctx.lineTo(j * 0.6, -0.05); ctx.stroke(); ctx.beginPath(); ctx.ellipse(j * 0.585, -0.12, 0.06, 0.02, 0, 0, Math.PI * 2); ctx.stroke(); } ctx.fillStyle = '#f0b429'; for (j = -1; 1 >= j; j += 2) { fx = j * 0.13; ctx.beginPath(); ctx.moveTo(fx - 0.05, 0.15); ctx.lineTo(fx + 0.05, 0.15); ctx.lineTo(fx + 0.045 + off, -0.36); ctx.quadraticCurveTo(fx + off, -0.48, fx - 0.045 + off, -0.36); ctx.closePath(); ctx.fill(); } ctx.fillStyle = '#1f2633'; for (j = -1; 1 >= j; j += 2) { rr(j * 0.13 - 0.07, -0.22, 0.14, 0.24, 0.035); ctx.fill(); } ctx.strokeStyle = '#2e3a4f'; ctx.lineWidth = 0.16; for (j = -1; 1 >= j; j += 2) { ctx.beginPath(); ctx.moveTo(j * 0.13, -0.18); ctx.lineTo(j * 0.17 + off * 0.35, -0.49); ctx.lineTo(j * 0.11, -0.8); ctx.stroke(); } ctx.fillStyle = '#b5432b'; ctx.beginPath(); ctx.moveTo(-0.21, -0.74); ctx.lineTo(0.21, -0.74); ctx.lineTo(0.26, -1.27); ctx.quadraticCurveTo(0, -1.38, -0.26, -1.27); ctx.closePath(); ctx.fill(); ctx.fillStyle = 'rgba(255,255,255,0.92)'; ctx.fillRect(-0.235, -1.07, 0.47, 0.055); ctx.strokeStyle = '#b5432b'; ctx.lineWidth = 0.12; for (j = -1; 1 >= j; j += 2) { ctx.beginPath(); ctx.moveTo(j * 0.22, -1.22); ctx.lineTo(j * 0.36, -1.02); ctx.lineTo(j * 0.42, -0.87); ctx.stroke(); } ctx.fillStyle = '#1f2633'; for (j = -1; 1 >= j; j += 2) { ctx.beginPath(); ctx.arc(j * 0.42, -0.86, 0.055, 0, Math.PI * 2); ctx.fill(); } rr(-0.085, -1.42, 0.17, 0.09, 0.03); ctx.fill(); ctx.save(); ctx.beginPath(); ctx.arc(0, -1.5, 0.145, 0, Math.PI * 2); ctx.clip(); ctx.fillStyle = '#6b4a2f'; ctx.fillRect(-0.16, -1.66, 0.32, 0.32); ctx.fillStyle = '#c8102e'; ctx.fillRect(-0.16, -1.66, 0.32, 0.105); ctx.fillStyle = '#ffffff'; ctx.fillRect(-0.16, -1.555, 0.32, 0.06); ctx.fillStyle = '#c8102e'; ctx.fillRect(-0.16, -1.495, 0.32, 0.065); ctx.restore(); ctx.fillStyle = '#ffffff'; ctx.beginPath(); ctx.arc(0, -1.665, 0.055, 0, Math.PI * 2); ctx.fill(); ctx.restore(); } function drawWorld() { var list = [], i, o, z; for (i = 0; objs.length > i; i += 1) { if (objs[i].t !== 3) { list.push(objs[i]); } } list.sort(function (a, b) { return b.S - a.S; }); i = 0; while (list.length > i) { o = list[i]; z = o.S - dist + ZP; if (ZP >= z) { if (!o.hit) { break; } } drawObj(o, z); i += 1; } drawSkier(); while (list.length > i) { o = list[i]; drawObj(o, o.S - dist + ZP); i += 1; } } function drawParts() { var i, p; ctx.fillStyle = '#b3cdee'; for (i = 0; parts.length > i; i += 1) { p = parts[i]; ctx.globalAlpha = clamp(1 - p.life \/ p.max, 0, 1); ctx.beginPath(); ctx.arc(p.x, p.y, p.rad, 0, Math.PI * 2); ctx.fill(); } ctx.globalAlpha = 1; } function drawPops() { var i, p, fs; if (0 === pops.length) { return; } fs = Math.round(Math.max(18, KP * 0.42)); ctx.textAlign = 'center'; ctx.textBaseline = 'middle'; ctx.font = '800 ' + fs + 'px ' + font; ctx.lineWidth = 4; ctx.lineJoin = 'round'; ctx.strokeStyle = 'rgba(255,255,255,0.95)'; ctx.fillStyle = '#c8102e'; for (i = 0; pops.length > i; i += 1) { p = pops[i]; ctx.globalAlpha = clamp(1.2 - p.life * 1.2, 0, 1); ctx.strokeText(p.txt, p.x, p.y - p.life * 50); ctx.fillText(p.txt, p.x, p.y - p.life * 50); } ctx.globalAlpha = 1; } function pill(x, y, w, label, val) { ctx.fillStyle = 'rgba(255,255,255,0.86)'; rr(x, y, w, 50, 12); ctx.fill(); ctx.textAlign = 'left'; ctx.textBaseline = 'alphabetic'; ctx.fillStyle = '#6a5a4c'; ctx.font = '700 10px ' + font; ctx.fillText(label.toUpperCase(), x + 12, y + 17); ctx.fillStyle = '#2b211b'; ctx.font = '800 21px ' + font; ctx.fillText(val, x + 12, y + 40); } function drawHud() { var w = clamp(W * 0.22, 96, 150); pill(12, 12, w, T_SCORE, fmt(score)); pill(W - 12 - w, 12, w, T_BEST, fmt(best)); } function draw(dt) { var ox = 0, oy = 0; if (shake > 0) { ox = rand(-1, 1) * shake * 7; oy = rand(-1, 1) * shake * 5; } ctx.setTransform(DPR, 0, 0, DPR, 0, 0); ctx.fillStyle = '#cfe5fb'; ctx.fillRect(0, 0, W, H); ctx.setTransform(DPR, 0, 0, DPR, ox * DPR, oy * DPR); ctx.drawImage(skyC, 0, 0, W, H); drawClouds(dt); ctx.drawImage(mtnC, 0, 0, W, H); drawBumps(); drawTrail(); drawWorld(); drawParts(); drawPops(); ctx.setTransform(DPR, 0, 0, DPR, 0, 0); drawHud(); if (flash > 0) { ctx.fillStyle = 'rgba(255,255,255,' + flash.toFixed(3) + ')'; ctx.fillRect(0, 0, W, H); } } function shouldRun() { if (!onScreen) { return false; } if (document.hidden) { return false; } if (state === 'play' || state === 'crash') { return true; } if (state === 'idle') { if (reduce) { return false; } return 40 > idleT; } return false; } function frame(ts) { var dt; raf = 0; dt = last ? (ts - last) \/ 1000 : 1 \/ 60; last = ts; if (dt > 0.05) { dt = 0.05; } if (0 >= dt) { dt = 1 \/ 60; } update(dt); draw(dt); if (shouldRun()) { raf = window.requestAnimationFrame(frame); } else { last = 0; } } function kick() { if (raf) { return; } if (!shouldRun()) { return; } last = 0; raf = window.requestAnimationFrame(frame); } function toX(ev) { var r = cv.getBoundingClientRect(); return clamp((ev.clientX - r.left - r.width \/ 2) \/ KP, -LP * 0.92, LP * 0.92); } cv.addEventListener('pointermove', function (ev) { if (state === 'play') { ptx = toX(ev); } }); cv.addEventListener('pointerdown', function (ev) { if (state !== 'play') { return; } ptx = toX(ev); if (ev.pointerType !== 'mouse') { try { cv.setPointerCapture(ev.pointerId); } catch (e8) { ptx = toX(ev); } } }); cv.addEventListener('touchstart', function (ev) { if (state === 'play') { ev.preventDefault(); } }, { passive: false }); cv.addEventListener('touchmove', function (ev) { if (state === 'play') { ev.preventDefault(); } }, { passive: false }); window.addEventListener('keydown', function (ev) { var k = ev.key, tg = ev.target; if (tg) { if (tg.tagName === 'INPUT' || tg.tagName === 'TEXTAREA' || tg.isContentEditable) { return; } } if (k === 'm' || k === 'M') { if (onScreen) { if (state !== 'idle') { toggleMute(); } } return; } if (state !== 'play') { return; } if (k === 'ArrowLeft' || k === 'a' || k === 'A') { keyL = true; ev.preventDefault(); } else if (k === 'ArrowRight' || k === 'd' || k === 'D') { keyR = true; ev.preventDefault(); } else if (k === 'Escape' || k === 'p' || k === 'P') { ev.preventDefault(); pause(); } }); window.addEventListener('keyup', function (ev) { var k = ev.key; if (k === 'ArrowLeft' || k === 'a' || k === 'A') { keyL = false; } if (k === 'ArrowRight' || k === 'd' || k === 'D') { keyR = false; } }); window.addEventListener('blur', function () { keyL = false; keyR = false; }); root.addEventListener('click', function (ev) { var b = ev.target.closest ? ev.target.closest('button') : null; var act; if (!b) { return; } act = b.getAttribute('data-ski'); if (act === 'start') { startGame(); } if (act === 'resume') { resume(); } }); document.addEventListener('visibilitychange', function () { if (document.hidden) { pause(); } else { kick(); } }); if ('IntersectionObserver' in window) { new window.IntersectionObserver(function (entries) { var e = entries[entries.length - 1]; onScreen = e.isIntersecting ? e.intersectionRatio > 0.2 : false; if (onScreen) { kick(); } else { pause(); } }, { threshold: [0, 0.2, 0.5, 1] }).observe(root); } function onResize() { if (resize()) { if (!raf) { draw(0); } } } if ('ResizeObserver' in window) { new window.ResizeObserver(onResize).observe(root); } else { window.addEventListener('resize', onResize); } if (sndBtn) { if (!(window.AudioContext || window.webkitAudioContext)) { sndBtn.hidden = true; } sndBtn.addEventListener('click', function (ev) { ev.stopPropagation(); toggleMute(); }); } applyMute(); if (form) { form.addEventListener('submit', function (ev) { var nm; ev.preventDefault(); if (saving) { return; } nm = (nameIn ? nameIn.value : '').trim().split(' ').filter(function (x) { return x.length > 0; }).join(' '); if (2 > nm.length || nm.length > 20) { say('m-name'); return; } saving = true; say('m-saving'); capToken(function (tk) { if (!tk) { saving = false; say(capVer === 'v3' ? 'm-error' : 'm-captcha'); return; } api('score', { name: nm, score: lastScore, token: gameTok, captcha: tk, lang: lang2 }, function (j) { var code = j ? String(j.error || '') : ''; saving = false; if (j) { if (j.ok) { gameTok = ''; form.hidden = true; say('m-ok', j.rank); try { window.localStorage.setItem('hfSkiName', nm); } catch (e27) { nm = String(nm); } if (j.board) { renderBoard(j.board, nm); } return; } } if (code === 'captcha') { say(capVer === 'v3' ? 'm-bot' : 'm-captcha'); } else if (code === 'name') { say('m-name'); } else if (code === 'rate') { say('m-rate'); } else { say('m-error'); } capReset(); }); }); }); if (nameIn) { nameIn.addEventListener('focus', function () { capReady(function () { return; }); }); } } resize(); initClouds(); update(0); draw(0); kick(); loadBoard(); } var list = document.querySelectorAll('.hf-skigame'); var n; for (n = 0; list.length > n; n += 1) { if (!list[n].getAttribute('data-ready')) { HfSki(list[n]); } } })();<\/script>\n<\/div><\/div>\n\n\n\n<div class=\"wp-block-group hf-section hf-section-tight hf-skigame-help\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\">\n<div class=\"hf-skigame-board\" hidden><h2 class=\"hf-h3\">Leaderboard<\/h2><ol class=\"hf-skigame-list\"><\/ol><p class=\"hf-skigame-board-empty\" hidden>No scores yet. Will you be the first?<\/p><\/div>\n\n\n\n<h2 class=\"wp-block-heading hf-h3\">How to play<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>Move your mouse or finger left and right: your skier follows.<\/li><li>On a computer you can also use the arrow keys. Press P or Esc to pause.<\/li><li>Every metre is worth one point. Ski through the red gates for 50 extra points.<\/li><li>The further you get, the faster you go and the more trees there are.<\/li><li>After a run you can put your score on the leaderboard with your name. The form is protected by reCAPTCHA.<\/li><li>Use the speaker button at the top of the game or the M key to turn the music and sounds on or off.<\/li><li>Your personal best is stored in your own browser. Your name and score only go on the leaderboard if you save them yourself.<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Fancy the real thing? From the village, the Wagst\u00e4ttbahn gondola takes you straight into the KitzSki ski area. Check <a href=\"\/index.php\/en\/snow-and-weather\/\">snow and weather<\/a> to see how much snow there is right now.<\/p>\n<\/div><\/div>\n\n\n\n<div class=\"wp-block-group hf-section hf-section-tight\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\">\n<p class=\"has-text-align-center hf-kicker wp-block-paragraph\">Also useful<\/p>\n\n\n\n<nav class=\"hf-related\"><a href=\"\/index.php\/en\/jochberg-ski-area\/\">Ski area and lift status<\/a><a href=\"\/index.php\/en\/skiing-with-kids\/\">Skiing with kids<\/a><a href=\"\/index.php\/en\/snow-and-weather\/\">Snow and weather<\/a><a href=\"\/index.php\/en\/hahnenkamm-race\/\">Hahnenkamm race<\/a><a href=\"\/index.php\/en\/apartments\/\">Our apartments<\/a><\/nav>\n<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Game Ski game: dodge the trees Waiting for real snow? Start skiing down the slope above Jochberg right here. Steer with your mouse or finger, dodge the fir trees and see how far you get. Skiing in Jochberg Move your mouse or finger left and right to dodge the trees. Ski through the red gates &#8230; <a title=\"Ski game: dodge the trees\" class=\"read-more\" href=\"https:\/\/www.jochberg.nl\/index.php\/en\/ski-game\/\" aria-label=\"Lees meer over Ski game: dodge the trees\">Lees verder<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-412","page","type-page","status-publish"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\r\n<title>Ski game: dodge the trees - Haus Florie<\/title>\r\n<meta name=\"description\" content=\"Play the free ski game by Haus Florie: race down the slope above Jochberg, dodge the trees and ski through the gates. With mouse, finger or arrow keys.\" \/>\r\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\r\n<link rel=\"canonical\" href=\"https:\/\/www.jochberg.nl\/index.php\/en\/ski-game\/\" \/>\r\n<meta property=\"og:locale\" content=\"nl_NL\" \/>\r\n<meta property=\"og:type\" content=\"article\" \/>\r\n<meta property=\"og:title\" content=\"Ski game: dodge the trees - Haus Florie\" \/>\r\n<meta property=\"og:description\" content=\"Play the free ski game by Haus Florie: race down the slope above Jochberg, dodge the trees and ski through the gates. With mouse, finger or arrow keys.\" \/>\r\n<meta property=\"og:url\" content=\"https:\/\/www.jochberg.nl\/index.php\/en\/ski-game\/\" \/>\r\n<meta property=\"og:site_name\" content=\"Haus Florie\" \/>\r\n<meta property=\"article:modified_time\" content=\"2026-11-19T09:05:29+00:00\" \/>\r\n<meta property=\"og:image\" content=\"https:\/\/www.jochberg.nl\/wp-content\/uploads\/2026\/10\/Jochberg-in-de-winter-\u2013-kerk-en-dorp.jpg\" \/>\r\n\t<meta property=\"og:image:width\" content=\"960\" \/>\r\n\t<meta property=\"og:image:height\" content=\"720\" \/>\r\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\r\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\r\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 minuut\" \/>\r\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.jochberg.nl\\\/index.php\\\/en\\\/ski-game\\\/\",\"url\":\"https:\\\/\\\/www.jochberg.nl\\\/index.php\\\/en\\\/ski-game\\\/\",\"name\":\"Ski game: dodge the trees - Haus Florie\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.jochberg.nl\\\/#website\"},\"datePublished\":\"2026-11-19T08:19:59+00:00\",\"dateModified\":\"2026-11-19T09:05:29+00:00\",\"description\":\"Play the free ski game by Haus Florie: race down the slope above Jochberg, dodge the trees and ski through the gates. With mouse, finger or arrow keys.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.jochberg.nl\\\/index.php\\\/en\\\/ski-game\\\/#breadcrumb\"},\"inLanguage\":\"nl-NL\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.jochberg.nl\\\/index.php\\\/en\\\/ski-game\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.jochberg.nl\\\/index.php\\\/en\\\/ski-game\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.jochberg.nl\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Ski game: dodge the trees\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.jochberg.nl\\\/#website\",\"url\":\"https:\\\/\\\/www.jochberg.nl\\\/\",\"name\":\"Haus Florie\",\"description\":\"Alles over Jochberg in Tirol\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.jochberg.nl\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"nl-NL\"}]}<\/script>\r\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Ski game: dodge the trees - Haus Florie","description":"Play the free ski game by Haus Florie: race down the slope above Jochberg, dodge the trees and ski through the gates. With mouse, finger or arrow keys.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.jochberg.nl\/index.php\/en\/ski-game\/","og_locale":"nl_NL","og_type":"article","og_title":"Ski game: dodge the trees - Haus Florie","og_description":"Play the free ski game by Haus Florie: race down the slope above Jochberg, dodge the trees and ski through the gates. With mouse, finger or arrow keys.","og_url":"https:\/\/www.jochberg.nl\/index.php\/en\/ski-game\/","og_site_name":"Haus Florie","article_modified_time":"2026-11-19T09:05:29+00:00","og_image":[{"width":960,"height":720,"url":"https:\/\/www.jochberg.nl\/wp-content\/uploads\/2026\/10\/Jochberg-in-de-winter-\u2013-kerk-en-dorp.jpg","type":"image\/jpeg"}],"twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"1 minuut"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.jochberg.nl\/index.php\/en\/ski-game\/","url":"https:\/\/www.jochberg.nl\/index.php\/en\/ski-game\/","name":"Ski game: dodge the trees - Haus Florie","isPartOf":{"@id":"https:\/\/www.jochberg.nl\/#website"},"datePublished":"2026-11-19T08:19:59+00:00","dateModified":"2026-11-19T09:05:29+00:00","description":"Play the free ski game by Haus Florie: race down the slope above Jochberg, dodge the trees and ski through the gates. With mouse, finger or arrow keys.","breadcrumb":{"@id":"https:\/\/www.jochberg.nl\/index.php\/en\/ski-game\/#breadcrumb"},"inLanguage":"nl-NL","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.jochberg.nl\/index.php\/en\/ski-game\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.jochberg.nl\/index.php\/en\/ski-game\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.jochberg.nl\/"},{"@type":"ListItem","position":2,"name":"Ski game: dodge the trees"}]},{"@type":"WebSite","@id":"https:\/\/www.jochberg.nl\/#website","url":"https:\/\/www.jochberg.nl\/","name":"Haus Florie","description":"Alles over Jochberg in Tirol","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.jochberg.nl\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"nl-NL"}]}},"_links":{"self":[{"href":"https:\/\/www.jochberg.nl\/index.php\/wp-json\/wp\/v2\/pages\/412","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jochberg.nl\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.jochberg.nl\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.jochberg.nl\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jochberg.nl\/index.php\/wp-json\/wp\/v2\/comments?post=412"}],"version-history":[{"count":2,"href":"https:\/\/www.jochberg.nl\/index.php\/wp-json\/wp\/v2\/pages\/412\/revisions"}],"predecessor-version":[{"id":454,"href":"https:\/\/www.jochberg.nl\/index.php\/wp-json\/wp\/v2\/pages\/412\/revisions\/454"}],"wp:attachment":[{"href":"https:\/\/www.jochberg.nl\/index.php\/wp-json\/wp\/v2\/media?parent=412"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}