Spaces:
Running
Running
Upload folder using huggingface_hub
Browse files1 unmodified line234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021 unmodified line<html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><title>₿itcoin Dino Run</title><script src="https://cdn.tailwindcss.com"></script><link href="https://fonts.googleapis.com/css2?family=Fredoka+One&family=VT323&display=swap" rel="stylesheet"><style>body {margin: 0;overflow: hidden;background-color: #1a202c;font-family: 'Fredoka One', cursive;touch-action: none; /* Prevent pull-to-refresh on mobile */}canvas {display: block;}.ui-layer {position: absolute;top: 0;left: 0;width: 100%;height: 100%;pointer-events: none;display: flex;flex-direction: column;justify-content: space-between;padding: 20px;box-sizing: border-box;}.interactive {pointer-events: auto;}.hidden {display: none !important;}/* Retro Scanline Effect */.scanlines {background: linear-gradient(to bottom,rgba(255,255,255,0),rgba(255,255,255,0) 50%,rgba(0,0,0,0.1) 50%,rgba(0,0,0,0.1));background-size: 100% 4px;position: absolute;top: 0; left: 0; right: 0; bottom: 0;pointer-events: none;z-index: 10;}/* Glitch Text Animation */@keyframes glitch {0% { transform: translate(0) }20% { transform: translate(-2px, 2px) }40% { transform: translate(-2px, -2px) }60% { transform: translate(2px, 2px) }80% { transform: translate(2px, -2px) }100% { transform: translate(0) }}.glitch-hover:hover {animation: glitch 0.3s cubic-bezier(.25, .46, .45, .94) both infinite;color: #F7931A;}.hud-text {font-family: 'VT323', monospace;text-shadow: 2px 2px 0px #000;}</style></head><body><!-- Canvas Layer --><canvas id="gameCanvas"></canvas><div class="scanlines"></div><!-- UI Layer --><div id="uiLayer" class="ui-layer"><!-- HUD (Top) --><div id="hud" class="hidden w-full flex justify-between items-start z-20"><div class="flex flex-col gap-1"><div class="text-yellow-400 text-3xl hud-text tracking-wider"><span class="text-white">SCORE:</span> <span id="scoreDisplay">0</span></div><div class="text-orange-500 text-2xl hud-text tracking-wider flex items-center gap-2"><span class="text-white">BTC:</span> <span id="btcDisplay">0.00000000</span> ₿</div></div><div class="flex flex-col items-end gap-1"><div class="text-cyan-400 text-2xl hud-text">SPEED: <span id="speedDisplay">0</span> km/h</div><div id="powerupStatus" class="flex gap-2"><!-- Icons injected via JS --></div></div></div><!-- Start Screen --><div id="startScreen" class="absolute inset-0 flex flex-col items-center justify-center bg-black/80 backdrop-blur-sm z-30 interactive"><h1 class="text-6xl md:text-8xl text-green-400 mb-2 tracking-tighter drop-shadow-[0_5px_5px_rgba(0,0,0,0.8)]" style="font-family: 'Fredoka One'">DINO <span class="text-orange-500">₿</span> RUN</h1><p class="text-gray-300 mb-8 text-xl font-sans">Collect Sats. Dodge Obstacles. To the Moon.</p><div class="flex gap-4 mb-8"><div class="flex flex-col items-center bg-gray-800 p-4 rounded-lg border border-gray-700"><div class="w-8 h-8 border-2 border-white rounded mb-2 flex items-center justify-center text-white">←</div><span class="text-xs text-gray-400">LEFT</span></div><div class="flex flex-col items-center bg-gray-800 p-4 rounded-lg border border-gray-700"><div class="w-8 h-8 border-2 border-white rounded mb-2 flex items-center justify-center text-white">→</div><span class="text-xs text-gray-400">RIGHT</span></div><div class="flex flex-col items-center bg-gray-800 p-4 rounded-lg border border-gray-700"><div class="w-8 h-8 border-2 border-white rounded mb-2 flex items-center justify-center text-white">↑</div><span class="text-xs text-gray-400">JUMP</span></div><div class="flex flex-col items-center bg-gray-800 p-4 rounded-lg border border-gray-700"><div class="w-8 h-8 border-2 border-white rounded mb-2 flex items-center justify-center text-white">↓</div><span class="text-xs text-gray-400">SLIDE</span></div></div><button id="startBtn" class="glitch-hover bg-green-500 hover:bg-green-400 text-black text-2xl px-12 py-4 rounded-full shadow-[0_0_20px_rgba(74,222,128,0.6)] transition-all transform hover:scale-105 font-bold border-4 border-green-700">START RUNNING</button></div><!-- Game Over Screen --><div id="gameOverScreen" class="hidden absolute inset-0 flex flex-col items-center justify-center bg-red-900/90 backdrop-blur-md z-40 interactive"><h2 class="text-6xl text-white mb-2 drop-shadow-lg">CRASHED!</h2><div class="bg-black/50 p-6 rounded-xl border border-red-500 mb-8 text-center min-w-[300px]"><div class="text-gray-300 text-lg mb-1">Distance</div><div class="text-4xl text-white mb-4" id="finalScore">0m</div><div class="text-gray-300 text-lg mb-1">Total BTC Mined</div><div class="text-4xl text-orange-400 font-mono" id="finalBTC">0.00000000</div></div><button id="restartBtn" class="glitch-hover bg-white text-red-600 text-2xl px-10 py-3 rounded-full shadow-lg hover:bg-gray-100 transition-all font-bold">TRY AGAIN</button></div><!-- Mobile Controls (Visible only on touch devices via logic, but here for structure) --><div id="mobileControls" class="hidden w-full h-full absolute top-0 left-0 z-10"><div class="w-1/2 h-full absolute left-0" id="touchLeft"></div><div class="w-1/2 h-full absolute right-0" id="touchRight"></div><div class="absolute bottom-10 left-10 w-20 h-20 bg-white/10 rounded-full backdrop-blur" id="btnJump">JUMP</div><div class="absolute bottom-10 right-10 w-20 h-20 bg-white/10 rounded-full backdrop-blur" id="btnSlide">SLIDE</div></div></div><script>/*** BITCOIN DINO RUN* A high-performance HTML5 Canvas Endless Runner*/// --- Configuration ---const CONFIG = {lanes: 3,laneWidth: 0, // Calculated dynamicallybaseSpeed: 600, // Pixels per secondmaxSpeed: 1400,acceleration: 5, // Speed increase per secondgravity: 2500,jumpForce: -900,colors: {dino: '#4ade80', // Tailwind green-400dinoDark: '#166534',headband: '#ef4444', // Redbtc: '#F7931A',ground: '#374151',groundLight: '#4b5563'}};// --- State Management ---const state = {screen: 'start', // start, playing, gameoverlastTime: 0,score: 0, // Distancebtc: 0.00000000,speed: 0,lane: 1, // 0, 1, 2isJumping: false,isSliding: false,jumpVelocity: 0,y: 0, // Vertical position (0 is ground)slideTimer: 0,magnetTimer: 0,multiplierTimer: 0,shieldTimer: 0,multiplier: 1,frame: 0,cameraShake: 0};// --- Assets & Objects ---const canvas = document.getElementById('gameCanvas');const ctx = canvas.getContext('2d');let entities = {obstacles: [],coins: [],particles: [],bgLayers: []};// --- Input Handling ---const keys = { ArrowUp: false, ArrowDown: false, ArrowLeft: false, ArrowRight: false, w: false, s: false, a: false, d: false, Space: false };window.addEventListener('keydown', (e) => {if(keys.hasOwnProperty(e.key) || e.code === 'Space') keys[e.key] = true;handleInput(e.key, true);});window.addEventListener('keyup', (e) => {if(keys.hasOwnProperty(e.key) || e.code === 'Space') keys[e.key] = false;handleInput(e.key, false);});// Touch controlslet touchStartX = 0;let touchStartY = 0;canvas.addEventListener('touchstart', e => {touchStartX = e.changedTouches[0].screenX;touchStartY = e.changedTouches[0].screenY;}, {passive: false});canvas.addEventListener('touchend', e => {const touchEndX = e.changedTouches[0].screenX;const touchEndY = e.changedTouches[0].screenY;handleSwipe(touchStartX, touchStartY, touchEndX, touchEndY);}, {passive: false});function handleSwipe(sx, sy, ex, ey) {const dx = ex - sx;const dy = ey - sy;if (Math.abs(dx) > Math.abs(dy)) {// Horizontalif (Math.abs(dx) > 30) {if (dx > 0) changeLane(1);else changeLane(-1);}} else {// Verticalif (Math.abs(dy) > 30) {if (dy < 0) jump();else slide();}}}function handleInput(key, isDown) {if (state.screen !== 'playing') return;if (isDown) {if (key === 'ArrowLeft' || key === 'a') changeLane(-1);if (key === 'ArrowRight' || key === 'd') changeLane(1);if (key === 'ArrowUp' || key === 'w' || key === ' ') jump();if (key === 'ArrowDown' || key === 's') slide();}}function changeLane(dir) {const newLane = state.lane + dir;if (newLane >= 0 && newLane < CONFIG.lanes) {state.lane = newLane;createDust(state.lane, 0, 5);}}function jump() {if (!state.isJumping && !state.isSliding) {state.isJumping = true;state.jumpVelocity = CONFIG.jumpForce;createDust(state.lane, 0, 10);}}function slide() {if (!state.isSliding && !state.isJumping) {state.isSliding = true;state.slideTimer = 0.8; // seconds}}// --- Game Loop ---function resize() {canvas.width = window.innerWidth;canvas.height = window.innerHeight;CONFIG.laneWidth = canvas.width / CONFIG.lanes;}window.addEventListener('resize', resize);resize();function initGame() {state.score = 0;state.btc = 0.00000000;state.speed = CONFIG.baseSpeed;state.lane = 1;state.isJumping = false;state.isSliding = false;state.y = 0;state.multiplier = 1;state.magnetTimer = 0;state.shieldTimer = 0;state.multiplierTimer = 0;entities.obstacles = [];entities.coins = [];entities.particles = [];// Initialize Background Layersentities.bgLayers = [{ speedMod: 0.1, color: '#111827', elements: generateBgElements(20, 50) }, // Far{ speedMod: 0.3, color: '#1f2937', elements: generateBgElements(10, 100) }, // Mid{ speedMod: 0.6, color: '#374151', elements: generateBgElements(5, 200) } // Near];state.screen = 'playing';state.lastTime = performance.now();requestAnimationFrame(loop);}function generateBgElements(count, heightVar) {let arr = [];for(let i=0; i<count; i++) {arr.push({x: Math.random() * canvas.width * 2,y: canvas.height - 150 - Math.random() * heightVar,w: 50 + Math.random() * 100,h: 50 + Math.random() * heightVar});}return arr;}function loop(timestamp) {if (state.screen !== 'playing') return;const dt = Math.min((timestamp - state.lastTime) / 1000, 0.1); // Cap dtstate.lastTime = timestamp;state.frame++;update(dt);draw();requestAnimationFrame(loop);}// --- Update Logic ---function update(dt) {// Speed progressionif (state.speed < CONFIG.maxSpeed) {state.speed += CONFIG.acceleration * dt;}// Scorestate.score += (state.speed * dt) / 100;// Physicsif (state.isJumping) {state.y += state.jumpVelocity * dt;state.jumpVelocity += CONFIG.gravity * dt;if (state.y >= 0) {state.y = 0;state.isJumping = false;createDust(state.lane, 0, 5);}}if (state.isSliding) {state.slideTimer -= dt;if (state.slideTimer <= 0) state.isSliding = false;}// Timersif (state.magnetTimer > 0) state.magnetTimer -= dt;if (state.multiplierTimer > 0) state.multiplierTimer -= dt;if (state.shieldTimer > 0) state.shieldTimer -= dt;else state.multiplier = 1;// Camera Shake decayif (state.cameraShake > 0) state.cameraShake *= 0.9;if (state.cameraShake < 0.5) state.cameraShake = 0;// SpawningspawnManager(dt);// Entity Updates & CollisionupdateEntities(dt);// ParticlesupdateParticles(dt);// UI Updatedocument.getElementById('scoreDisplay').innerText = Math.floor(state.score);document.getElementById('speedDisplay').innerText = Math.floor(state.speed / 10);document.getElementById('btcDisplay').innerText = state.btc.toFixed(8);// Update Powerup Iconsconst pContainer = document.getElementById('powerupStatus');pContainer.innerHTML = '';if (state.magnetTimer > 0) pContainer.innerHTML += '<div class="w-6 h-6 rounded-full bg-blue-500 border-2 border-white shadow-lg animate-pulse"></div>';if (state.multiplierTimer > 0) pContainer.innerHTML += '<div class="w-6 h-6 rounded-full bg-yellow-500 border-2 border-white shadow-lg animate-pulse">x2</div>';if (state.shieldTimer > 0) pContainer.innerHTML += '<div class="w-6 h-6 rounded-full bg-purple-500 border-2 border-white shadow-lg animate-pulse">S</div>';}function spawnManager(dt) {// Simple spawn logic based on distance traveled// We track a virtual "distance since last spawn"if (!state.spawnTimer) state.spawnTimer = 0;state.spawnTimer -= state.speed * dt;if (state.spawnTimer <= 0) {// Determine what to spawnconst r = Math.random();const lane = Math.floor(Math.random() * 3);// 30% chance for coin row, 40% obstacle, 30% mixedif (r < 0.3) {spawnCoinRow(lane);} else if (r < 0.7) {spawnObstacle(lane);} else {spawnCoinRow(lane);// Spawn obstacle in different lanelet otherLane = (lane + 1) % 3;if(Math.random() > 0.5) otherLane = (lane + 2) % 3;spawnObstacle(otherLane);}// Reset timer (random interval based on speed)state.spawnTimer = 400 + Math.random() * 600;}}function spawnObstacle(lane) {const type = Math.random() > 0.5 ? 'barrier' : 'train'; // simplified typesentities.obstacles.push({x: canvas.width + 100,lane: lane,type: type,width: type === 'train' ? 300 : 80,height: type === 'train' ? 140 : 80,z: 0, // Ground levelactive: true});}function spawnCoinRow(lane) {const count = 5 + Math.floor(Math.random() * 5);const startX = canvas.width + 100;for (let i = 0; i < count; i++) {// Check for powerup spawnlet isPowerup = Math.random() < 0.05;let type = 'btc';if (isPowerup) {const pType = Math.random();if (pType < 0.33) type = 'magnet';else if (pType < 0.66) type = 'multiplier';else type = 'shield';}entities.coins.push({x: startX + (i * 80),lane: lane,y: 0, // Ground relativetype: type,active: true,rot: 0});}}function updateEntities(dt) {const moveDist = state.speed * dt;// Update Obstaclesentities.obstacles.forEach(obs => {obs.x -= moveDist;// Collisionif (obs.active && obs.x < getLaneCenter(state.lane) + 40 && obs.x > getLaneCenter(state.lane) - 40) {// Check Z depth (simple Y check here)// Obstacles are on ground (y=0) unless we had aerial ones.// Player Y is negative when jumping.let hit = false;if (state.isJumping) {// Jumping over barrier is okay, train is too high? Let's say train hits jumpers.if (obs.type === 'train' && state.y > -100) hit = true;} else if (state.isSliding) {// Sliding under train is okay? Let's say yes.if (obs.type === 'barrier') hit = true;} else {// Runninghit = true;}if (hit) {if (state.shieldTimer > 0) {obs.active = false; // Break obstaclecreateExplosion(obs.x, canvas.height/2 + 50, '#fff');} else {gameOver();}}}});// Cleanup Obstaclesentities.obstacles = entities.obstacles.filter(o => o.x > -200);// Update Coinsconst playerX = getLaneCenter(state.lane);const playerY = canvas.height/2 + 100 + state.y; // Approx player screen Yentities.coins.forEach(coin => {coin.x -= moveDist;coin.rot += dt * 5;// Magnet Logiclet magnetRange = 300;let cx = coin.x;let cy = getLaneY(coin.lane) - 50; // Coin height offset// Simple magnet pullif (state.magnetTimer > 0) {const dist = Math.hypot(cx - playerX, cy - playerY);if (dist < magnetRange) {coin.x += (playerX - cx) * dt * 5;// Adjust lane visually for magnet effect? Hard with lane system.// Just pull X for now.}}// Collectionif (coin.active && Math.abs(coin.x - playerX) < 50 && coin.lane === state.lane) {// Check height (can collect while jumping)if (Math.abs(state.y) < 100) {collectCoin(coin);}}});entities.coins = entities.coins.filter(c => c.x > -100);}function collectCoin(coin) {coin.active = false;if (coin.type === 'btc') {const val = 0.00000001 * state.multiplier;state.btc += val;createFloatingText(coin.x, getLaneY(coin.lane) - 50, `+${val.toFixed(8)}`);createSparkle(coin.x, getLaneY(coin.lane) - 50, CONFIG.colors.btc);} else if (coin.type === 'magnet') {state.magnetTimer = 10;createFloatingText(coin.x, getLaneY(coin.lane) - 50, "MAGNET!");} else if (coin.type === 'multiplier') {state.multiplierTimer = 10;state.multiplier = 2;createFloatingText(coin.x, getLaneY(coin.lane) - 50, "x2 BTC!");} else if (coin.type === 'shield') {state.shieldTimer = 10;createFloatingText(coin.x, getLaneY(coin.lane) - 50, "SHIELD!");}}// --- Rendering ---function draw() {// Clearctx.fillStyle = '#111827'; // Dark bgctx.fillRect(0, 0, canvas.width, canvas.height);// Camera Shakectx.save();if (state.cameraShake > 0) {const dx = (Math.random() - 0.5) * state.cameraShake;const dy = (Math.random() - 0.5) * state.cameraShake;ctx.translate(dx, dy);}// Draw Background (Parallax)drawBackground();// Draw GrounddrawGround();// Draw Entities// Sort by Y for pseudo-depthconst renderList = [...entities.obstacles.map(o => ({...o, t: 'obs', y: 0})),...entities.coins.map(c => ({...c, t: 'coin', y: 0}))];// Player Y is relative to ground. Ground is at canvas.height/2 + 100.const groundY = canvas.height / 2 + 100;// Draw Player Shadowconst playerX = getLaneCenter(state.lane);const playerY = groundY + state.y;ctx.fillStyle = 'rgba(0,0,0,0.3)';ctx.beginPath();ctx.ellipse(playerX, groundY, 30 * (1 - Math.abs(state.y)/500), 10 * (1 - Math.abs(state.y)/500), 0, 0, Math.PI*2);ctx.fill();// Draw PlayerdrawDino(playerX, playerY, state.isSliding);// Draw Coins & Obstacles// We need to interleave them based on their "depth" (which is just lane order for now, or simple Z)// Since it's a runner, things just come towards camera.// Draw order: Back lane -> Front lane? Or just Y position.// Let's draw everything at their lane Y.entities.obstacles.forEach(obs => {const x = obs.x;const y = groundY;drawObstacle(x, y, obs);});entities.coins.forEach(coin => {const x = coin.x;const y = groundY - 50; // FloatdrawCoin(x, y, coin);});// ParticlesdrawParticles();ctx.restore();}function drawBackground() {// Sky gradientconst grad = ctx.createLinearGradient(0, 0, 0, canvas.height);grad.addColorStop(0, '#0f172a');grad.addColorStop(1, '#1e293b');ctx.fillStyle = grad;ctx.fillRect(0,0, canvas.width, canvas.height);// Parallax Layersentities.bgLayers.forEach(layer => {ctx.fillStyle = layer.color;layer.elements.forEach(el => {// Move elementel.x -= (state.speed * 0.1) * layer.speedMod; // Slow movementif (el.x < -200) el.x = canvas.width + Math.random() * 200;// Draw simple building/rock shapectx.beginPath();ctx.roundRect(el.x, el.y, el.w, canvas.height - el.y, 10);ctx.fill();});});}function drawGround() {const horizon = canvas.height / 2 + 100;// Roadctx.fillStyle = '#374151';ctx.fillRect(0, horizon, canvas.width, canvas.height - horizon);// Lane markingsctx.strokeStyle = '#4b5563';ctx.lineWidth = 4;ctx.setLineDash([40, 40]);ctx.lineDashOffset = -state.score * 2; // Animate linesfor(let i=1; i<CONFIG.lanes; i++) {const x = i * CONFIG.laneWidth;ctx.beginPath();ctx.moveTo(x, horizon);ctx.lineTo(x, canvas.height);ctx.stroke();}ctx.setLineDash([]);}function drawDino(x, y, sliding) {ctx.save();ctx.translate(x, y);// Bounce animationif (!state.isJumping && !sliding) {const bounce = Math.sin(state.frame * 0.2) * 5;ctx.translate(0, -bounce);}if (sliding) {ctx.rotate(-Math.PI / 2); // Rotate to slidectx.translate(0, -20);}// Shadow/Glowctx.shadowColor = 'rgba(74, 222, 128, 0.4)';ctx.shadowBlur = 20;// Body (Rounded Rect)ctx.fillStyle = CONFIG.colors.dino;ctx.beginPath();ctx.roundRect(-30, -80, 60, 70, 15);ctx.fill();// Headctx.beginPath();ctx.arc(0, -90, 35, 0, Math.PI * 2);ctx.fill();// Headbandctx.fillStyle = CONFIG.colors.headband;ctx.fillRect(-36, -100, 72, 15);// Knotctx.beginPath();ctx.moveTo(30, -95);ctx.lineTo(50, -105);ctx.lineTo(50, -85);ctx.fill();// Bitcoin Symbol on Headbandctx.fillStyle = '#F7931A';ctx.font = 'bold 20px monospace';ctx.textAlign = 'center';ctx.textBaseline = 'middle';ctx.fillText('₿', 0, -92);// Eyesctx.fillStyle = 'white';ctx.beginPath();ctx.ellipse(-10, -95, 10, 12, 0, 0, Math.PI*2);ctx.ellipse(10, -95, 10, 12, 0, 0, Math.PI*2);ctx.fill();// Pupils (look forward, or at coins?)ctx.fillStyle = 'black';ctx.beginPath();ctx.arc(-8, -95, 4, 0, Math.PI*2);ctx.arc(12, -95, 4, 0, Math.PI*2);ctx.fill();// Armsctx.fillStyle = CONFIG.colors.dino;if (sliding) {// Arms tucked} else {// Running armsconst armAngle = Math.sin(state.frame * 0.3) * 0.5;ctx.beginPath();ctx.ellipse(-25, -50, 10, 25, armAngle, 0, Math.PI*2);ctx.ellipse(25, -50, 10, 25, -armAngle, 0, Math.PI*2);ctx.fill();}// Legs (if not sliding)if (!sliding) {const legOffset = Math.sin(state.frame * 0.3) * 15;ctx.fillStyle = CONFIG.colors.dinoDark;// Left Legctx.beginPath();ctx.roundRect(-20 + legOffset, -10, 15, 30, 5);ctx.fill();// Right Legctx.beginPath();ctx.roundRect(5 - legOffset, -10, 15, 30, 5);ctx.fill();}// Shield Effectif (state.shieldTimer > 0) {ctx.strokeStyle = `rgba(168, 85, 247, ${Math.abs(Math.sin(state.frame * 0.1))})`;ctx.lineWidth = 5;ctx.beginPath();ctx.arc(0, -60, 60, 0, Math.PI*2);ctx.stroke();}ctx.restore();}function drawObstacle(x, y, obs) {ctx.save();ctx.translate(x, y);if (obs.type === 'barrier') {ctx.fillStyle = '#ef4444'; // Red barrier// 3D-ish boxctx.fillRect(-40, -obs.height, obs.width, obs.height);// Stripectx.fillStyle = '#fca5a5';ctx.beginPath();ctx.moveTo(-40, -obs.height);ctx.lineTo(40, -obs.height);ctx.lineTo(-40, 0);ctx.fill();// Borderctx.strokeStyle = '#7f1d1d';ctx.lineWidth = 3;ctx.strokeRect(-40, -obs.height, obs.width, obs.height);} else {// Trainctx.fillStyle = '#1e3a8a'; // Bluectx.fillRect(-obs.width/2, -obs.height, obs.width, obs.height);// Windowsctx.fillStyle = '#93c5fd';ctx.fillRect(-obs.width/2 + 10, -obs.height + 10, obs.width - 20, 40);// Detailctx.fillStyle = '#172554';ctx.fillRect(-obs.width/2, -20, obs.width, 10);}ctx.restore();}function drawCoin(x, y, coin) {if (!coin.active) return;ctx.save();ctx.translate(x, y);// Spin effect (scale X)const scaleX = Math.abs(Math.sin(coin.rot));ctx.scale(scaleX, 1);if (coin.type === 'btc') {ctx.fillStyle = CONFIG.colors.btc;ctx.shadowColor = CONFIG.colors.btc;ctx.shadowBlur = 15;ctx.beginPath();ctx.arc(0, 0, 20, 0, Math.PI*2);ctx.fill();ctx.fillStyle = '#fff';ctx.font = 'bold 20px sans-serif';ctx.textAlign = 'center';ctx.textBaseline = 'middle';ctx.fillText('₿', 0, 2);} else {// Powerupsctx.fillStyle = coin.type === 'magnet' ? '#3b82f6' : (coin.type === 'shield' ? '#a855f7' : '#eab308');ctx.shadowColor = ctx.fillStyle;ctx.shadowBlur = 15;ctx.beginPath();ctx.arc(0, 0, 15, 0, Math.PI*2);ctx.fill();ctx.fillStyle = 'white';ctx.font = '16px sans-serif';ctx.textAlign = 'center';ctx.textBaseline = 'middle';let icon = '?';if(coin.type === 'magnet') icon = 'M';if(coin.type === 'shield') icon = 'S';if(coin.type === 'multiplier') icon = 'x2';ctx.fillText(icon, 0, 2);}ctx.restore();}// --- Particle System ---function createDust(lane, y, count) {const cx = getLaneCenter(lane);const cy = getLaneY(lane);for(let i=0; i<count; i++) {entities.particles.push({x: cx + (Math.random()-0.5)*40,y: cy,vx: (Math.random()-0.5)*100,vy: -Math.random()*100,life: 0.5,color: 'rgba(255,255,255,0.5)',size: Math.random()*5+2,type: 'dust'});}}function createSparkle(x, y, color) {for(let i=0; i<10; i++) {entities.particles.push({x: x,y: y,vx: (Math.random()-0.5)*300,vy: (Math.random()-0.5)*300,life: 0.8,color: color,size: Math.random()*4+2,type: 'sparkle'});}}function createExplosion(x, y, color) {for(let i=0; i<20; i++) {entities.particles.push({x: x,y: y,vx: (Math.random()-0.5)*400,vy: (Math.random()-0.5)*400,life: 1.0,color: color,size: Math.random()*6+3,type: 'debris'});}}function createFloatingText(x, y, text) {entities.particles.push({x: x,y: y,vx: 0,vy: -50,life: 1.5,text: text,type: 'text'});}function updateParticles(dt) {entities.particles.forEach(p => {p.x += p.vx * dt;p.y += p.vy * dt;p.life -= dt;if (p.type === 'dust' || p.type === 'sparkle') {p.vy += 100 * dt; // gravity}});entities.particles = entities.particles.filter(p => p.life > 0);}function drawParticles() {entities.particles.forEach(p => {ctx.save();ctx.globalAlpha = Math.max(0, p.life);if (p.type === 'text') {ctx.fillStyle = '#F7931A';ctx.font = 'bold 20px Fredoka One';ctx.fillText(p.text, p.x, p.y);} else {ctx.fillStyle = p.color;ctx.beginPath();ctx.arc(p.x, p.y, p.size, 0, Math.PI*2);ctx.fill();}ctx.restore();});}// --- Helpers ---function getLaneCenter(laneIndex) {return (laneIndex * CONFIG.laneWidth) + (CONFIG.laneWidth / 2);}function getLaneY(laneIndex) {// In this perspective, all lanes are same Y on screenreturn canvas.height / 2 + 100;}function gameOver() {state.screen = 'gameover';state.cameraShake = 20;document.getElementById('hud').classList.add('hidden');document.getElementById('gameOverScreen').classList.remove('hidden');document.getElementById('finalScore').innerText = Math.floor(state.score) + "m";document.getElementById('finalBTC').innerText = state.btc.toFixed(8);}// --- Initialization ---document.getElementById('startBtn').addEventListener('click', () => {document.getElementById('startScreen').classList.add('hidden');document.getElementById('hud').classList.remove('hidden');initGame();});document.getElementById('restartBtn').addEventListener('click', () => {document.getElementById('gameOverScreen').classList.add('hidden');document.getElementById('hud').classList.remove('hidden');initGame();});// Initial Renderresize();drawBackground();// Draw a static dino for the start screen backgroundctx.fillStyle = '#111827';ctx.fillRect(0, 0, canvas.width, canvas.height);drawBackground();drawGround();drawDino(canvas.width/2, canvas.height/2 + 100, false);</script></body></html>1 unmodified line23456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221 unmodified line<html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"><title>Dino Run - Bitcoin Edition</title><style>@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Exo+2:wght@300;400;600;700&display=swap');* {margin: 0;padding: 0;box-sizing: border-box;}:root {--primary: #F7931A;--primary-dark: #E88A0C;--secondary: #4CAF50;--accent: #00E5FF;--dark: #1a1a2e;--light: #ffffff;--glass: rgba(255, 255, 255, 0.1);--glass-border: rgba(255, 255, 255, 0.2);}body {font-family: 'Exo 2', sans-serif;background: var(--dark);overflow: hidden;touch-action: none;user-select: none;}#gameContainer {position: relative;width: 100vw;height: 100vh;display: flex;justify-content: center;align-items: center;background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);}#gameCanvas {display: block;background: transparent;}.ui-overlay {position: absolute;top: 0;left: 0;width: 100%;height: 100%;pointer-events: none;z-index: 10;}.screen {position: absolute;top: 0;left: 0;width: 100%;height: 100%;display: flex;flex-direction: column;justify-content: center;align-items: center;background: rgba(26, 26, 46, 0.95);backdrop-filter: blur(10px);transition: opacity 0.5s ease, transform 0.5s ease;pointer-events: auto;}.screen.hidden {opacity: 0;transform: scale(1.1);pointer-events: none;}.title {font-family: 'Orbitron', monospace;font-size: clamp(2rem, 8vw, 5rem);font-weight: 900;background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 50%, var(--secondary) 100%);-webkit-background-clip: text;-webkit-text-fill-color: transparent;background-clip: text;text-shadow: 0 0 60px rgba(247, 147, 26, 0.5);margin-bottom: 1rem;animation: titleGlow 2s ease-in-out infinite;}@keyframes titleGlow {0%, 100% { filter: brightness(1); }50% { filter: brightness(1.3); }}.subtitle {font-size: clamp(1rem, 3vw, 1.5rem);color: rgba(255, 255, 255, 0.7);margin-bottom: 3rem;letter-spacing: 0.3em;text-transform: uppercase;}.btn {font-family: 'Orbitron', monospace;font-size: clamp(1rem, 2.5vw, 1.3rem);font-weight: 700;padding: 1rem 3rem;border: 2px solid var(--primary);background: transparent;color: var(--primary);cursor: pointer;position: relative;overflow: hidden;transition: all 0.3s ease;text-transform: uppercase;letter-spacing: 0.1em;margin: 0.5rem;}.btn::before {content: '';position: absolute;top: 0;left: -100%;width: 100%;height: 100%;background: linear-gradient(90deg, transparent, var(--primary), transparent);transition: left 0.5s ease;}.btn:hover::before {left: 100%;}.btn:hover {background: var(--primary);color: var(--dark);box-shadow: 0 0 30px rgba(247, 147, 26, 0.5);transform: scale(1.05);}.btn-secondary {border-color: var(--accent);color: var(--accent);}.btn-secondary:hover {background: var(--accent);box-shadow: 0 0 30px rgba(0, 229, 255, 0.5);}.hud {position: absolute;top: 0;left: 0;width: 100%;padding: 1rem 2rem;display: flex;justify-content: space-between;align-items: flex-start;pointer-events: none;}.hud-left, .hud-right {display: flex;flex-direction: column;gap: 0.5rem;}.hud-item {background: var(--glass);border: 1px solid var(--glass-border);padding: 0.5rem 1rem;border-radius: 8px;backdrop-filter: blur(5px);}.hud-label {font-size: 0.7rem;color: rgba(255, 255, 255, 0.6);text-transform: uppercase;letter-spacing: 0.1em;}.hud-value {font-family: 'Orbitron', monospace;font-size: 1.2rem;font-weight: 700;color: var(--light);}.hud-value.btc {color: var(--primary);}.hud-value.speed {color: var(--accent);}.hud-center {position: absolute;top: 1rem;left: 50%;transform: translateX(-50%);display: flex;gap: 1rem;}.powerup-indicator {width: 50px;height: 50px;border-radius: 50%;display: flex;justify-content: center;align-items: center;font-size: 1.5rem;opacity: 0.3;transition: all 0.3s ease;background: var(--glass);border: 2px solid var(--glass-border);}.powerup-indicator.active {opacity: 1;animation: pulse 1s ease-in-out infinite;}.powerup-indicator.magnet { border-color: var(--accent); color: var(--accent); }.powerup-indicator.shield { border-color: #E91E63; color: #E91E63; }.powerup-indicator.multiplier { border-color: var(--primary); color: var(--primary); }.powerup-indicator.speed { border-color: var(--secondary); color: var(--secondary); }@keyframes pulse {0%, 100% { transform: scale(1); }50% { transform: scale(1.1); }}.pause-btn {position: absolute;top: 1rem;right: 1rem;width: 50px;height: 50px;border-radius: 50%;background: var(--glass);border: 2px solid var(--glass-border);color: white;font-size: 1.5rem;cursor: pointer;pointer-events: auto;transition: all 0.3s ease;display: flex;justify-content: center;align-items: center;}.pause-btn:hover {background: var(--primary);border-color: var(--primary);}.controls-hint {position: absolute;bottom: 2rem;left: 50%;transform: translateX(-50%);display: flex;gap: 2rem;color: rgba(255, 255, 255, 0.5);font-size: 0.8rem;}.control-key {display: flex;align-items: center;gap: 0.5rem;}.key {background: var(--glass);border: 1px solid var(--glass-border);padding: 0.3rem 0.6rem;border-radius: 4px;font-family: 'Orbitron', monospace;font-size: 0.7rem;}.final-score {font-family: 'Orbitron', monospace;font-size: clamp(1.5rem, 5vw, 3rem);color: var(--primary);margin: 1rem 0;}.final-btc {font-family: 'Orbitron', monospace;font-size: clamp(1rem, 3vw, 1.5rem);color: var(--accent);margin-bottom: 2rem;}.game-over-stats {display: flex;gap: 2rem;margin-bottom: 2rem;}.stat-item {text-align: center;}.stat-value {font-family: 'Orbitron', monospace;font-size: 1.5rem;color: white;}.stat-label {font-size: 0.8rem;color: rgba(255, 255, 255, 0.6);}.new-record {color: var(--secondary);font-family: 'Orbitron', monospace;animation: recordPulse 0.5s ease-in-out infinite;}@keyframes recordPulse {0%, 100% { transform: scale(1); }50% { transform: scale(1.05); }}.mobile-controls {display: none;position: absolute;bottom: 2rem;left: 0;width: 100%;justify-content: space-between;padding: 0 2rem;pointer-events: auto;}@media (max-width: 768px) {.mobile-controls {display: flex;}.controls-hint {display: none;}}.mobile-btn {width: 70px;height: 70px;border-radius: 50%;background: var(--glass);border: 2px solid var(--glass-border);color: white;font-size: 1.5rem;display: flex;justify-content: center;align-items: center;transition: all 0.2s ease;}.mobile-btn:active {transform: scale(0.9);background: var(--primary);border-color: var(--primary);}.mobile-btn.vertical {flex-direction: column;gap: 0.5rem;}.powered-by {position: absolute;bottom: 1rem;left: 50%;transform: translateX(-50%);font-size: 0.8rem;color: rgba(255, 255, 255, 0.4);text-decoration: none;transition: color 0.3s ease;}.powered-by:hover {color: var(--primary);}.combo-display {position: absolute;top: 50%;left: 50%;transform: translate(-50%, -50%);font-family: 'Orbitron', monospace;font-size: 2rem;color: var(--primary);text-shadow: 0 0 20px var(--primary);opacity: 0;transition: all 0.3s ease;pointer-events: none;}.combo-display.show {opacity: 1;animation: comboAnim 0.5s ease-out;}@keyframes comboAnim {0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }50% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }100% { transform: translate(-50%, -50%) scale(1); opacity: 0; }}</style></head><body><div id="gameContainer"><canvas id="gameCanvas"></canvas><!-- Start Screen --><div id="startScreen" class="screen"><h1 class="title">DINO RUN</h1><p class="subtitle">Bitcoin Edition</p><button class="btn" id="startBtn">START GAME</button><div class="controls-hint"><div class="control-key"><span class="key">←</span><span class="key">→</span> Move</div><div class="control-key"><span class="key">↑</span> Jump</div><div class="control-key"><span class="key">↓</span> Slide</div></div></div><!-- HUD --><div id="hud" class="ui-overlay" style="display: none;"><div class="hud"><div class="hud-left"><div class="hud-item"><div class="hud-label">Distance</div><div class="hud-value" id="distanceDisplay">0m</div></div></div><div class="hud-center"><div class="powerup-indicator magnet" id="magnetIndicator">🧲</div><div class="powerup-indicator shield" id="shieldIndicator">🛡️</div><div class="powerup-indicator multiplier" id="multiplierIndicator">×2</div><div class="powerup-indicator speed" id="speedIndicator">⚡</div></div><div class="hud-right"><div class="hud-item"><div class="hud-label">Balance</div><div class="hud-value btc" id="btcDisplay">₿ 0.00000000</div></div><div class="hud-item"><div class="hud-label">Speed</div><div class="hud-value speed" id="speedDisplay">0 km/h</div></div></div></div><button class="pause-btn" id="pauseBtn">⏸</button><div class="mobile-controls"><div class="mobile-btn vertical"><span id="mobileJump">↑</span><span>Jump</span></div><div class="mobile-btn" id="mobileLeft">←</div><div class="mobile-btn" id="mobileRight">→</div><div class="mobile-btn vertical"><span id="mobileSlide">↓</span><span>Slide</span></div></div><div class="combo-display" id="comboDisplay"></div></div><!-- Pause Screen --><div id="pauseScreen" class="screen hidden"><h1 class="title">PAUSED</h1><button class="btn" id="resumeBtn">RESUME</button><button class="btn btn-secondary" id="quitBtn">QUIT</button></div><!-- Game Over Screen --><div id="gameOverScreen" class="screen hidden"><h1 class="title">GAME OVER</h1><div class="game-over-stats"><div class="stat-item"><div class="stat-value" id="finalDistance">0m</div><div class="stat-label">Distance</div></div><div class="stat-item"><div class="stat-value" id="finalBtc">₿ 0.00000000</div><div class="stat-label">Earned</div></div></div><div class="final-score" id="newRecordText" style="display: none;">NEW RECORD!</div><button class="btn" id="restartBtn">PLAY AGAIN</button><button class="btn btn-secondary" id="homeBtn">HOME</button></div><a href="https://huggingface.co/spaces/akhaliq/anycoder" class="powered-by" target="_blank">Built with anycoder</a></div><script>// ============================================// GAME CONFIGURATION// ============================================const CONFIG = {CANVAS_WIDTH: 1200,CANVAS_HEIGHT: 700,LANE_COUNT: 3,LANE_WIDTH: 200,PLAYER_WIDTH: 80,PLAYER_HEIGHT: 100,BASE_SPEED: 400,MAX_SPEED: 1200,SPEED_INCREMENT: 10,GRAVITY: 1800,JUMP_FORCE: -650,SLIDE_DURATION: 600,COIN_VALUE: 0.00000001,BONUS_COIN_VALUE: 0.00000005,SPAWN_INTERVAL_BASE: 1500,POWERUP_CHANCE: 0.08,MAGNET_DURATION: 8000,SHIELD_DURATION: 10000,MULTIPLIER_DURATION: 10000,SPEED_BOOST_DURATION: 5000,COIN_SPIN_SPEED: 3,PARTICLE_COUNT: 5};// ============================================// GAME STATE// ============================================const game = {canvas: null,ctx: null,width: 0,height: 0,state: 'start', // start, playing, paused, gameoverdeltaTime: 0,lastTime: 0,distance: 0,btcBalance: 0,speed: CONFIG.BASE_SPEED,currentLane: 1,targetLane: 1,player: {x: 0,y: 0,width: CONFIG.PLAYER_WIDTH,height: CONFIG.PLAYER_HEIGHT,velocityY: 0,isJumping: false,isSliding: false,slideTimer: 0,animFrame: 0,animTimer: 0,runCycle: 0},obstacles: [],coins: [],powerups: [],particles: [],background: {layers: [],groundOffset: 0},effects: {shake: 0,speedLines: []},powerups: {magnet: { active: false, timer: 0 },shield: { active: false, timer: 0 },multiplier: { active: false, timer: 0 },speedBoost: { active: false, timer: 0 }},combo: {count: 0,timer: 0,multiplier: 1},spawnTimer: 0,highScore: 0,keys: {}};// ============================================// INITIALIZATION// ============================================function init() {game.canvas = document.getElementById('gameCanvas');game.ctx = game.canvas.getContext('2d');resizeCanvas();window.addEventListener('resize', resizeCanvas);setupEventListeners();initBackground();game.lastTime = performance.now();requestAnimationFrame(gameLoop);}function resizeCanvas() {const container = document.getElementById('gameContainer');const aspectRatio = CONFIG.CANVAS_WIDTH / CONFIG.CANVAS_HEIGHT;let width = container.clientWidth;let height = container.clientHeight;if (width / height > aspectRatio) {width = height * aspectRatio;} else {height = width / aspectRatio;}game.canvas.width = CONFIG.CANVAS_WIDTH;game.canvas.height = CONFIG.CANVAS_HEIGHT;game.canvas.style.width = width + 'px';game.canvas.style.height = height + 'px';game.width = CONFIG.CANVAS_WIDTH;game.height = CONFIG.CANVAS_HEIGHT;}function setupEventListeners() {// Keyboardwindow.addEventListener('keydown', (e) => {game.keys[e.code] = true;if (game.state === 'playing') {handleInput(e.code);}});window.addEventListener('keyup', (e) => {game.keys[e.code] = false;});// Buttonsdocument.getElementById('startBtn').addEventListener('click', startGame);document.getElementById('pauseBtn').addEventListener('click', pauseGame);document.getElementById('resumeBtn').addEventListener('click', resumeGame);document.getElementById('quitBtn').addEventListener('click', quitToMenu);document.getElementById('restartBtn').addEventListener('click', restartGame);document.getElementById('homeBtn').addEventListener('click', quitToMenu);// Mobile controlsdocument.getElementById('mobileLeft').addEventListener('touchstart', () => {if (game.state === 'playing') changeLane(-1);});document.getElementById('mobileRight').addEventListener('touchstart', () => {if (game.state === 'playing') changeLane(1);});document.getElementById('mobileJump').parentElement.addEventListener('touchstart', (e) => {e.preventDefault();if (game.state === 'playing') jump();});document.getElementById('mobileSlide').parentElement.addEventListener('touchstart', (e) => {e.preventDefault();if (game.state === 'playing') slide();});}// ============================================// INPUT HANDLING// ============================================function handleInput(code) {switch(code) {case 'ArrowLeft':case 'KeyA':changeLane(-1);break;case 'ArrowRight':case 'KeyD':changeLane(1);break;case 'ArrowUp':case 'KeyW':case 'Space':jump();break;case 'ArrowDown':case 'KeyS':slide();break;case 'Escape':pauseGame();break;}}function changeLane(direction) {const newLane = game.targetLane + direction;if (newLane >= 0 && newLane < CONFIG.LANE_COUNT) {game.targetLane = newLane;}}function jump() {if (!game.player.isJumping && !game.player.isSliding) {game.player.isJumping = true;game.player.velocityY = CONFIG.JUMP_FORCE;}}function slide() {if (!game.player.isJumping && !game.player.isSliding) {game.player.isSliding = true;game.player.slideTimer = CONFIG.SLIDE_DURATION;}}// ============================================// GAME STATE MANAGEMENT// ============================================function startGame() {document.getElementById('startScreen').classList.add('hidden');document.getElementById('hud').style.display = 'block';resetGame();game.state = 'playing';}function pauseGame() {if (game.state === 'playing') {game.state = 'paused';document.getElementById('pauseScreen').classList.remove('hidden');}}function resumeGame() {game.state = 'playing';document.getElementById('pauseScreen').classList.add('hidden');game.lastTime = performance.now();}function quitToMenu() {game.state = 'start';document.getElementById('pauseScreen').classList.add('hidden');document.getElementById('gameOverScreen').classList.add('hidden');document.getElementById('hud').style.display = 'none';document.getElementById('startScreen').classList.remove('hidden');}function restartGame() {document.getElementById('gameOverScreen').classList.add('hidden');resetGame();game.state = 'playing';}function gameOver() {game.state = 'gameover';const isNewRecord = game.distance > game.highScore;if (isNewRecord) {game.highScore = Math.floor(game.distance);}document.getElementById('finalDistance').textContent = Math.floor(game.distance) + 'm';document.getElementById('finalBtc').textContent = '₿ ' + game.btcBalance.toFixed(8);document.getElementById('newRecordText').style.display = isNewRecord ? 'block' : 'none';document.getElementById('gameOverScreen').classList.remove('hidden');}function resetGame() {game.distance = 0;game.btcBalance = 0;game.speed = CONFIG.BASE_SPEED;game.currentLane = 1;game.targetLane = 1;game.spawnTimer = 0;game.effects.shake = 0;game.combo = { count: 0, timer: 0, multiplier: 1 };game.player = {x: getLaneX(1),y: game.height - 180,width: CONFIG.PLAYER_WIDTH,height: CONFIG.PLAYER_HEIGHT,velocityY: 0,isJumping: false,isSliding: false,slideTimer: 0,animFrame: 0,animTimer: 0,runCycle: 0};game.obstacles = [];game.coins = [];game.powerups = {magnet: { active: false, timer: 0 },shield: { active: false, timer: 0 },multiplier: { active: false, timer: 0 },speedBoost: { active: false, timer: 0 }};game.particles = [];updateHUD();}// ============================================// GAME LOOP// ============================================function gameLoop(timestamp) {game.deltaTime = Math.min((timestamp - game.lastTime) / 1000, 0.1);game.lastTime = timestamp;if (game.state === 'playing') {update();render();}requestAnimationFrame(gameLoop);}function update() {// Update speedif (game.powerups.speedBoost.active) {game.speed = CONFIG.MAX_SPEED * 1.3;} else {game.speed = Math.min(CONFIG.MAX_SPEED, CONFIG.BASE_SPEED + game.distance * 0.5);}// Update distancegame.distance += game.speed * game.deltaTime / 60;// Update playerupdatePlayer();// Update lane positionconst targetX = getLaneX(game.targetLane);game.player.x += (targetX - game.player.x) * 10 * game.deltaTime;game.currentLane = game.player.x;// Spawn objectsgame.spawnTimer -= game.deltaTime * 1000;if (game.spawnTimer <= 0) {spawnObjects();const spawnInterval = Math.max(800, CONFIG.SPAWN_INTERVAL_BASE - game.distance * 0.5);game.spawnTimer = spawnInterval;}// Update objectsupdateObstacles();updateCoins();updatePowerups();updateParticles();// Update powerup timersupdatePowerupTimers();// Update comboif (game.combo.timer > 0) {game.combo.timer -= game.deltaTime * 1000;} else {game.combo.count = 0;game.combo.multiplier = 1;}// Update backgroundupdateBackground();// Update screen shakeif (game.effects.shake > 0) {game.effects.shake *= 0.9;}// Speed linesif (game.speed > CONFIG.BASE_SPEED * 1.5) {if (Math.random() < 0.3) {game.effects.speedLines.push({x: game.width,y: Math.random() * game.height,length: 50 + Math.random() * 100,speed: 1500 + Math.random() * 500,alpha: 0.3 + Math.random() * 0.4});}}game.effects.speedLines = game.effects.speedLines.filter(line => {line.x -= line.speed * game.deltaTime;return line.x + line.length > 0;});// Check collisionscheckCollisions();// Update HUDupdateHUD();}function updatePlayer() {const groundY = game.height - 180;// Jump physicsif (game.player.isJumping) {game.player.velocityY += CONFIG.GRAVITY * game.deltaTime;game.player.y += game.player.velocityY * game.deltaTime;if (game.player.y >= groundY) {game.player.y = groundY;game.player.isJumping = false;game.player.velocityY = 0;}} else {game.player.y = groundY;}// Slideif (game.player.isSliding) {game.player.slideTimer -= game.deltaTime * 1000;if (game.player.slideTimer <= 0) {game.player.isSliding = false;}}// Animationgame.player.animTimer += game.deltaTime * 1000;if (game.player.animTimer > 100) {game.player.animTimer = 0;game.player.runCycle = (game.player.runCycle + 0.2) % (Math.PI * 2);}}function getLaneX(lane) {const totalWidth = CONFIG.LANE_COUNT * CONFIG.LANE_WIDTH;const startX = (game.width - totalWidth) / 2;return startX + lane * CONFIG.LANE_WIDTH + CONFIG.LANE_WIDTH / 2;}// ============================================// SPAWNING// ============================================function spawnObjects() {const lane = Math.floor(Math.random() * CONFIG.LANE_COUNT);const type = Math.random();// Spawn obstacleif (type < 0.6) {spawnObstacle(lane);}// Spawn coinsif (Math.random() < 0.7) {spawnCoinPattern(lane);}// Spawn powerupif (Math.random() < CONFIG.POWERUP_CHANCE) {spawnPowerup(lane);}}function spawnObstacle(lane) {const obstacleTypes = ['barrier', 'barrier_tall', 'gap'];const type = obstacleTypes[Math.floor(Math.random() * obstacleTypes.length)];game.obstacles.push({x: getLaneX(lane),y: game.height - 180,width: type === 'barrier_tall' ? 60 : 80,height: type === 'barrier_tall' ? 120 : 80,type: type,lane: lane,passed: false});}function spawnCoinPattern(lane) {const pattern = Math.floor(Math.random() * 3);const startX = getLaneX(lane);if (pattern === 0) {// Horizontal linefor (let i = 0; i < 5; i++) {game.coins.push({x: startX + (i - 2) * 50,y: game.height - 200 - Math.random() * 100,radius: 25,value: CONFIG.COIN_VALUE,rotation: Math.random() * Math.PI * 2,glow: 0});}} else if (pattern === 1) {// Arcfor (let i = 0; i < 5; i++) {const angle = (i / 4) * Math.PI - Math.PI / 2;game.coins.push({x: startX + Math.cos(angle) * 80,y: game.height - 200 + Math.sin(angle) * 50,radius: 25,value: CONFIG.COIN_VALUE,rotation: Math.random() * Math.PI * 2,glow: 0});}} else {// Single bonus coingame.coins.push({x: startX,y: game.height - 250,radius: 35,value: CONFIG.BONUS_COIN_VALUE,rotation: Math.random() * Math.PI * 2,glow: 1});}}function spawnPowerup(lane) {const types = ['magnet', 'shield', 'multiplier', 'speedBoost'];const type = types[Math.floor(Math.random() * types.length)];game.powerups.push({x: getLaneX(lane),y: game.height - 250,width: 50,height: 50,type: type,rotation: 0,bounce: 0});}// ============================================// UPDATE OBJECTS// ============================================function updateObstacles() {game.obstacles = game.obstacles.filter(obs => {obs.x -= game.speed * game.deltaTime;// Remove if off screenif (obs.x < -100) {return false;}// Check if passedif (!obs.passed && obs.x < game.player.x - 50) {obs.passed = true;addCombo();}return true;});}function updateCoins() {game.coins = game.coins.filter(coin => {coin.x -= game.speed * game.deltaTime;coin.rotation += CONFIG.COIN_SPIN_SPEED * game.deltaTime;coin.glow = (coin.glow + 0.1) % (Math.PI * 2);// Magnet effectif (game.powerups.magnet.active) {const dx = game.player.x - coin.x;const dy = (game.player.y + game.player.height / 2) - coin.y;const dist = Math.sqrt(dx * dx + dy * dy);if (dist < 300) {coin.x += dx * 0.1;coin.y += dy * 0.1;}}// Remove if off screenreturn coin.x > -50;});}function updatePowerups() {game.powerups = game.powerups.filter(pu => {pu.x -= game.speed * game.deltaTime;pu.rotation += 2 * game.deltaTime;pu.bounce += 5 * game.deltaTime;return pu.x > -50;});}function updateParticles() {game.particles = game.particles.filter(p => {p.x += p.vx * game.deltaTime;p.y += p.vy * game.deltaTime;p.life -= game.deltaTime;p.vy += 500 * game.deltaTime;return p.life > 0;});}function updatePowerupTimers() {const updatePowerup = (name, duration) => {if (game.powerups[name].active) {game.powerups[name].timer -= game.deltaTime * 1000;if (game.powerups[name].timer <= 0) {game.powerups[name].active = false;}}};updatePowerup('magnet', CONFIG.MAGNET_DURATION);updatePowerup('shield', CONFIG.SHIELD_DURATION);updatePowerup('multiplier', CONFIG.MULTIPLIER_DURATION);updatePowerup('speedBoost', CONFIG.SPEED_BOOST_DURATION);// Update indicatorsdocument.getElementById('magnetIndicator').classList.toggle('active', game.powerups.magnet.active);document.getElementById('shieldIndicator').classList.toggle('active', game.powerups.shield.active);document.getElementById('multiplierIndicator').classList.toggle('active', game.powerups.multiplier.active);document.getElementById('speedIndicator').classList.toggle('active', game.powerups.speedBoost.active);}function addCombo() {game.combo.count++;game.combo.timer = 2000;game.combo.multiplier = Math.min(5, 1 + Math.floor(game.combo.count / 5));if (game.combo.count > 0 && game.combo.count % 5 === 0) {showCombo(game.combo.multiplier + 'x COMBO!');}}function showCombo(text) {const comboEl = document.getElementById('comboDisplay');comboEl.textContent = text;comboEl.classList.remove('show');void comboEl.offsetWidth;comboEl.classList.add('show');}// ============================================// COLLISION DETECTION// ============================================function checkCollisions() {const playerBox = {x: game.player.x - game.player.width / 2,y: game.player.y,width: game.player.width,height: game.player.isSliding ? game.player.height / 2 : game.player.height};// Check obstacle collisionsfor (const obs of game.obstacles) {const obsBox = {x: obs.x - obs.width / 2,y: obs.y - obs.height,width: obs.width,height: obs.height};if (boxCollision(playerBox, obsBox)) {if (game.powerups.shield.active) {// Use shieldgame.powerups.shield.active = false;game.effects.shake = 10;createParticles(obs.x, obs.y - obs.height / 2, '#E91E63', 10);} else {gameOver();return;}}}// Check coin collisionsgame.coins = game.coins.filter(coin => {const dx = coin.x - game.player.x;const dy = coin.y - (game.player.y + game.player.height / 2);const dist = Math.sqrt(dx * dx + dy * dy);if (dist < coin.radius + 40) {// Collect coinlet value = coin.value;if (game.powerups.multiplier.active) {value *= 2;}value *= game.combo.multiplier;game.btcBalance += value;createParticles(coin.x, coin.y, '#F7931A', CONFIG.PARTICLE_COUNT);return false;}return true;});// Check powerup collisionsgame.powerups = game.powerups.filter(pu => {const dx = pu.x - game.player.x;const dy = pu.y - (game.player.y + game.player.height / 2);const dist = Math.sqrt(dx * dx + dy * dy);if (dist < 50) {activatePowerup(pu.type);createParticles(pu.x, pu.y, getPowerupColor(pu.type), 15);return false;}return true;});}function boxCollision(a, b) {return a.x < b.x + b.width &&a.x + a.width > b.x &&a.y < b.y + b.height &&a.y + a.height > b.y;}function activatePowerup(type) {switch(type) {case 'magnet':game.powerups.magnet.active = true;game.powerups.magnet.timer = CONFIG.MAGNET_DURATION;break;case 'shield':game.powerups.shield.active = true;game.powerups.shield.timer = CONFIG.SHIELD_DURATION;break;case 'multiplier':game.powerups.multiplier.active = true;game.powerups.multiplier.timer = CONFIG.MULTIPLIER_DURATION;break;case 'speedBoost':game.powerups.speedBoost.active = true;game.powerups.speedBoost.timer = CONFIG.SPEED_BOOST_DURATION;break;}}function getPowerupColor(type) {const colors = {magnet: '#00E5FF',shield: '#E91E63',multiplier: '#F7931A',speedBoost: '#4CAF50'};return colors[type] || '#ffffff';}function createParticles(x, y, color, count) {for (let i = 0; i < count; i++) {const angle = (Math.PI * 2 * i) / count + Math.random() * 0.5;const speed = 200 + Math.random() * 300;game.particles.push({x: x,y: y,vx: Math.cos(angle) * speed,vy: Math.sin(angle) * speed - 200,color: color,size: 3 + Math.random() * 5,life: 1});}}// ============================================// BACKGROUND// ============================================function initBackground() {game.background.layers = [{ color: '#1a1a3e', speed: 0.2, y: 0, height: game.height },{ color: '#252550', speed: 0.4, y: game.height * 0.3, height: game.height * 0.7 },{ color: '#2d2d5a', speed: 0.6, y: game.height * 0.5, height: game.height * 0.5 }];}function updateBackground() {game.background.groundOffset += game.speed * game.deltaTime;if (game.background.groundOffset > 100) {game.background.groundOffset = 0;}}// ============================================// RENDERING// ============================================function render() {const ctx = game.ctx;// Apply screen shakectx.save();if (game.effects.shake > 0.5) {ctx.translate((Math.random() - 0.5) * game.effects.shake,(Math.random() - 0.5) * game.effects.shake);}// Clearctx.fillStyle = '#1a1a2e';ctx.fillRect(0, 0, game.width, game.height);// Draw backgroundrenderBackground(ctx);// Draw lanesrenderLanes(ctx);// Draw groundrenderGround(ctx);// Draw obstaclesrenderObstacles(ctx);// Draw coinsrenderCoins(ctx);// Draw
index.html+1165-845