What Is Your Current View of Trump?

🤖 AI Summary
AI
0% picked Option
Option A 0%
Option B 0%
0 votes
📌 What do you want to do next?

(function(){ const root = document.getElementById('factme-trump-runner'); if (!root) return; const cvs = root.querySelector('#ftr-canvas'); const ctx = cvs.getContext('2d'); const overlay = root.querySelector('#ftr-overlay'); const overlayTitle = root.querySelector('#ftr-overlay-title'); const overlayText = root.querySelector('#ftr-overlay-text'); const startBtn = root.querySelector('#ftr-start'); const startWrap = root.querySelector('#ftr-start-wrap'); const capture = root.querySelector('#ftr-capture'); const emailInput = root.querySelector('#ftr-email'); const nickInput = root.querySelector('#ftr-nick'); const retryBtn = root.querySelector('#ftr-retry'); const scoreEl = root.querySelector('#ftr-score'); const bestEl = root.querySelector('#ftr-best'); const statusEl = root.querySelector('#ftr-status'); const boardList = root.querySelector('#ftr-board-list'); const showMoreBtn = root.querySelector('#ftr-show-more'); const ajaxUrl = '/wp-admin/admin-ajax.php'; const LS_BEST = 'ftr3_best'; const LS_UNLOCKED = 'ftr3_unlocked'; const LS_FREE_USED = 'ftr3_free_used'; const LS_EMAIL = 'ftr3_email'; const LS_NICK = 'ftr3_nick'; let best = parseInt(localStorage.getItem(LS_BEST) || '0', 10); let unlocked = localStorage.getItem(LS_UNLOCKED) === '1'; let freeUsed = localStorage.getItem(LS_FREE_USED) === '1'; let running = false; let gameOver = false; let raf = null; let score = 0; let speed = 6.8; let tick = 0; let obstacleCooldown = 35; let firstObstacleSpawned = false; let boardExpanded = false; const dpr = Math.max(1, Math.min(2, window.devicePixelRatio || 1)); const world = { obstacles: [], clouds: [{x:120,y:36},{x:320,y:55},{x:610,y:28}], trump: {x:54, y:0, w:24, h:34, vy:0, jumping:false} }; function resizeCanvas(){ const rect = cvs.getBoundingClientRect(); const cssW = rect.width || 720; const cssH = Math.max(cssW * 0.305, window.innerWidth <= 640 ? 240 : 220); cvs.width = Math.round(cssW * dpr); cvs.height = Math.round(cssH * dpr); ctx.setTransform(dpr,0,0,dpr,0,0); } function getWidth(){ return cvs.getBoundingClientRect().width || 720; } function getHeight(){ return cvs.getBoundingClientRect().height || 240; } function getGroundY(){ return getHeight() - 34; } function resetWorld(){ score = 0; speed = 6.8; tick = 0; obstacleCooldown = 35; firstObstacleSpawned = false; world.obstacles = []; world.trump.y = getGroundY() - world.trump.h; world.trump.vy = 0; world.trump.jumping = false; scoreEl.textContent = '0'; } function updateMeta(){ bestEl.textContent = String(best); if (unlocked) { statusEl.textContent = 'Unlimited runs unlocked'; retryBtn.disabled = running; } else if (freeUsed) { statusEl.textContent = 'Free run used'; retryBtn.disabled = true; } else { statusEl.textContent = '1 free run left'; retryBtn.disabled = running; } localStorage.setItem(LS_BEST, String(best)); } function renderBoard(items){ boardList.innerHTML = ''; if (!items.length){ boardList.innerHTML = '
  • No scores yet
  • '; showMoreBtn.classList.add('hidden'); return; } const visible = boardExpanded ? items : items.slice(0, 3); visible.forEach(item => { const li = document.createElement('li'); li.textContent = item.nickname + ' — ' + item.score; boardList.appendChild(li); }); if (items.length > 3) { showMoreBtn.classList.remove('hidden'); showMoreBtn.textContent = boardExpanded ? 'Show less' : 'Show more'; } else { showMoreBtn.classList.add('hidden'); } } function loadLeaderboard(){ const fd = new FormData(); fd.append('action', 'factme_runner_get_leaderboard'); fetch(ajaxUrl, { method: 'POST', body: fd }) .then(r => r.json()) .then(data => { if (data.success && Array.isArray(data.data)) { renderBoard(data.data); } else { renderBoard([]); } }) .catch(() => renderBoard([])); } showMoreBtn.addEventListener('click', function(){ boardExpanded = !boardExpanded; loadLeaderboard(); }); function drawCloud(x, y){ ctx.fillStyle = '#dbeafe'; ctx.beginPath(); ctx.arc(x, y, 10, 0, Math.PI * 2); ctx.arc(x + 12, y - 6, 12, 0, Math.PI * 2); ctx.arc(x + 28, y, 10, 0, Math.PI * 2); ctx.fill(); } function drawTrump(x, y){ ctx.fillStyle = '#1f2937'; ctx.fillRect(x + 6, y + 12, 12, 20); ctx.fillStyle = '#f5cfa0'; ctx.fillRect(x + 6, y + 2, 12, 12); ctx.fillStyle = '#f59e0b'; ctx.beginPath(); ctx.moveTo(x + 5, y + 7); ctx.lineTo(x + 18, y + 4); ctx.lineTo(x + 17, y + 1); ctx.lineTo(x + 7, y + 1); ctx.closePath(); ctx.fill(); ctx.fillStyle = '#ef4444'; ctx.fillRect(x + 11, y + 16, 3, 10); ctx.fillStyle = '#111827'; ctx.fillRect(x + 7, y + 31, 3, 3); ctx.fillRect(x + 14, y + 31, 3, 3); } function drawObstacle(o){ if (o.kind === 'mic'){ ctx.fillStyle = '#111827'; ctx.fillRect(o.x + 7, o.y + 6, 2, 22); ctx.beginPath(); ctx.arc(o.x + 8, o.y + 5, 5, 0, Math.PI * 2); ctx.fill(); } else { ctx.fillStyle = '#fee2e2'; ctx.fillRect(o.x, o.y, o.w, o.h); ctx.strokeStyle = '#ef4444'; ctx.strokeRect(o.x, o.y, o.w, o.h); ctx.fillStyle = '#991b1b'; ctx.fillRect(o.x + 4, o.y + 5, o.w - 8, 3); ctx.fillRect(o.x + 4, o.y + 11, o.w - 12, 2); ctx.fillRect(o.x + 4, o.y + 16, o.w - 10, 2); } } function intersects(a, b){ return a.x < b.x + b.w && a.x + a.w > b.x && a.y < b.y + b.h && a.y + a.h > b.y; } function spawnObstacle(){ if (Math.random() < 0.55) { world.obstacles.push({ x: getWidth() + 10, y: getGroundY() - 28, w: 16, h: 28, kind: 'mic' }); } else { world.obstacles.push({ x: getWidth() + 10, y: getGroundY() - 22, w: 28, h: 22, kind: 'news' }); } } function jump(){ if (!running || gameOver) return; if (!world.trump.jumping){ world.trump.vy = -7.2; world.trump.jumping = true; } } function showCapture(){ overlay.classList.remove('hidden'); overlayTitle.textContent = 'Game over'; overlayText.textContent = 'Score: ' + score + '. Enter email + nickname to unlock unlimited runs.'; startWrap.classList.add('hidden'); capture.classList.remove('hidden'); } function saveScoreRemote(scoreValue){ const nickname = localStorage.getItem(LS_NICK) || ''; if (!nickname) return; const fd = new FormData(); fd.append('action', 'factme_runner_save_score'); fd.append('nickname', nickname); fd.append('score', String(scoreValue)); fetch(ajaxUrl, { method: 'POST', body: fd }) .then(r => r.json()) .then(() => { loadLeaderboard(); }) .catch(() => {}); } function endGame(){ running = false; gameOver = true; cancelAnimationFrame(raf); if (score > best) best = score; if (unlocked) { saveScoreRemote(score); overlay.classList.remove('hidden'); overlayTitle.textContent = 'Game over'; overlayText.textContent = 'Score: ' + score + '. Tap play again.'; startWrap.classList.remove('hidden'); capture.classList.add('hidden'); startBtn.textContent = 'Play again'; } else if (!freeUsed) { freeUsed = true; localStorage.setItem(LS_FREE_USED, '1'); showCapture(); } updateMeta(); } function loop(){ const w = getWidth(); const groundY = getGroundY(); tick += 1; speed += 0.0035; score += 1; scoreEl.textContent = String(score); if (score > best) { best = score; bestEl.textContent = String(best); } obstacleCooldown--; if (!firstObstacleSpawned && obstacleCooldown <= 0) { spawnObstacle(); firstObstacleSpawned = true; obstacleCooldown = 55; } else if (firstObstacleSpawned && obstacleCooldown <= 0) { spawnObstacle(); obstacleCooldown = Math.floor(42 + Math.random() * 38); } world.trump.vy += 0.68; world.trump.y += world.trump.vy; if (world.trump.y >= groundY - world.trump.h){ world.trump.y = groundY - world.trump.h; world.trump.vy = 0; world.trump.jumping = false; } for (let i = world.obstacles.length - 1; i >= 0; i--){ const o = world.obstacles[i]; o.x -= speed; if (o.x + o.w < -10) { world.obstacles.splice(i, 1); } else if (intersects({ x: world.trump.x, y: world.trump.y, w: world.trump.w, h: world.trump.h }, o)) { endGame(); return; } } ctx.clearRect(0, 0, w, getHeight()); world.clouds.forEach(c => { c.x -= speed * 0.15; if (c.x < -60) c.x = w + Math.random() * 80; drawCloud(c.x, c.y); }); ctx.fillStyle = 'rgba(15,23,42,.06)'; ctx.font = '700 16px Inter, sans-serif'; ctx.fillText('FACTME RUNNER', w - 170, 22); ctx.strokeStyle = '#cbd5e1'; ctx.lineWidth = 2; ctx.beginPath(); ctx.moveTo(0, groundY + 1); ctx.lineTo(w, groundY + 1); ctx.stroke(); ctx.strokeStyle = '#94a3b8'; for (let i = 0; i < 20; i++){ const gx = (i * 50) - ((tick * speed * 1.6) % 50); ctx.beginPath(); ctx.moveTo(gx, groundY + 8); ctx.lineTo(gx + 18, groundY + 8); ctx.stroke(); } drawTrump(world.trump.x, world.trump.y); world.obstacles.forEach(drawObstacle); raf = requestAnimationFrame(loop); } function canPlay(){ return unlocked || !freeUsed; } function startRun(){ if (running) return; if (!canPlay()) { showCapture(); return; } running = true; gameOver = false; overlay.classList.add('hidden'); resetWorld(); loop(); updateMeta(); } startBtn.addEventListener('click', startRun); retryBtn.addEventListener('click', startRun); capture.addEventListener('submit', function(e){ e.preventDefault(); const email = emailInput.value.trim(); const nick = nickInput.value.trim(); if (!email || !email.includes('@')) { emailInput.focus(); emailInput.style.borderColor = '#ef4444'; return; } if (!nick) { nickInput.focus(); nickInput.style.borderColor = '#ef4444'; return; } emailInput.style.borderColor = '#cbd5e1'; nickInput.style.borderColor = '#cbd5e1'; const fd = new FormData(); fd.append('action', 'factme_runner_save_email'); fd.append('email', email); fd.append('nickname', nick); fetch(ajaxUrl, { method: 'POST', body: fd }) .then(r => r.json()) .then(data => { if (!data.success) throw new Error('save failed'); localStorage.setItem(LS_EMAIL, email); localStorage.setItem(LS_NICK, nick); localStorage.setItem(LS_UNLOCKED, '1'); unlocked = true; saveScoreRemote(score); overlayTitle.textContent = 'Unlocked'; overlayText.textContent = 'Unlimited runs enabled. Your nickname is on the leaderboard.'; capture.classList.add('hidden'); startWrap.classList.remove('hidden'); startBtn.textContent = 'Play again'; updateMeta(); }) .catch(() => { overlayTitle.textContent = 'Error'; overlayText.textContent = 'Could not save your email right now. Please try again.'; }); }); function tapHandler(e){ e.preventDefault(); if (!running && !gameOver && canPlay()) startRun(); else if (running) jump(); } cvs.addEventListener('pointerdown', tapHandler); cvs.addEventListener('touchstart', tapHandler, { passive: false }); document.addEventListener('keydown', function(e){ if (e.code === 'Space' || e.code === 'ArrowUp') { e.preventDefault(); if (!running && !gameOver && canPlay()) startRun(); else if (running) jump(); } }); resizeCanvas(); window.addEventListener('resize', resizeCanvas); loadLeaderboard(); updateMeta(); overlay.classList.remove('hidden'); capture.classList.add('hidden'); startWrap.classList.remove('hidden'); if (unlocked) { overlayTitle.textContent = 'Tap to play'; overlayText.textContent = 'Unlimited runs unlocked.'; } else { overlayTitle.textContent = 'Tap to start'; overlayText.textContent = 'One free run. After your first death, enter email + nickname to keep playing.'; } })();