Spaces:
Running
Running
Upload folder using huggingface_hub
Browse files123456789101112131415161718191234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207<!doctype html><html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width" /> <title>My static Space</title> <link rel="stylesheet" href="style.css" /> </head> <body> <div class="card"> <h1>Welcome to your static Space!</h1> <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p> <p> Also don't forget to check the <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>. </p> </div> </body></html><!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"> <title>Dino Runner - Bitcoin Edition</title> <link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link href="https://fonts.googleapis.com/css2?family=Bangers&family=Orbitron:wght@400;700&display=swap" rel="stylesheet"> <style> * { margin: 0; padding: 0; box-sizing: border-box; }
body { overflow: hidden; background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%); font-family: 'Orbitron', sans-serif; touch-action: none; }
#gameCanvas { display: block; margin: 0 auto; background: linear-gradient(180deg, #87CEEB 0%, #E0F6FF 100%); }
.ui-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 100; }
.screen { position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; background: rgba(0, 0, 0, 0.85); opacity: 0; transition: opacity 0.5s ease; pointer-events: none; }
.screen.active { opacity: 1; pointer-events: all; }
.title { font-family: 'Bangers', cursive; font-size: clamp(2.5rem, 8vw, 5rem); color: #F7931A; text-shadow: 0 0 20px #F7931A, 0 0 40px #F7931A, 4px 4px 0 #000; letter-spacing: 4px; animation: pulse 2s ease-in-out infinite; }
.subtitle { font-size: clamp(1rem, 3vw, 1.5rem); color: #4ade80; margin-top: 10px; text-shadow: 0 0 10px #4ade80; }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
.btn { margin-top: 30px; padding: 15px 50px; font-family: 'Bangers', cursive; font-size: 1.8rem; color: #fff; background: linear-gradient(180deg, #F7931A 0%, #c77a15 100%); border: none; border-radius: 50px; cursor: pointer; transition: all 0.3s ease; box-shadow: 0 6px 0 #8c5a10, 0 10px 20px rgba(247, 147, 26, 0.4); text-transform: uppercase; letter-spacing: 2px; }
.btn:hover { transform: translateY(-3px); box-shadow: 0 9px 0 #8c5a10, 0 15px 30px rgba(247, 147, 26, 0.5); }
.btn:active { transform: translateY(3px); box-shadow: 0 3px 0 #8c5a10, 0 5px 10px rgba(247, 147, 26, 0.4); }
.controls-info { margin-top: 40px; color: #aaa; text-align: center; font-size: 0.9rem; line-height: 2; }
.controls-info span { color: #4ade80; font-weight: bold; }
.hud { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); display: flex; gap: 20px; z-index: 50; width: 90%; max-width: 600px; justify-content: space-between; }
.hud-item { background: rgba(0, 0, 0, 0.7); padding: 10px 20px; border-radius: 25px; border: 2px solid #F7931A; box-shadow: 0 0 15px rgba(247, 147, 26, 0.3); }
.hud-label { font-size: 0.7rem; color: #888; text-transform: uppercase; letter-spacing: 1px; }
.hud-value { font-size: 1.2rem; color: #F7931A; font-weight: bold; text-shadow: 0 0 10px #F7931A; }
.hud-value.distance { color: #4ade80; text-shadow: 0 0 10px #4ade80; }
.powerup-indicator { position: fixed; top: 80px; left: 50%; transform: translateX(-50%); display: flex; gap: 10px; z-index: 50; }
.powerup-badge { padding: 8px 16px; border-radius: 20px; font-size: 0.8rem; font-weight: bold; opacity: 0; transform: translateY(-20px); transition: all 0.3s ease; }
.powerup-badge.active { opacity: 1; transform: translateY(0); }
.powerup-badge.magnet { background: #9333ea; color: #fff; } .powerup-badge.multiplier { background: #eab308; color: #000; } .powerup-badge.shield { background: #3b82f6; color: #fff; } .powerup-badge.speed { background: #ef4444; color: #fff; }
.game-over-stats { text-align: center; margin: 20px 0; }
.stat-row { display: flex; justify-content: space-between; padding: 10px 30px; font-size: 1.2rem; color: #fff; }
.stat-value { color: #F7931A; font-weight: bold; }
.pause-btn { position: fixed; top: 20px; right: 20px; width: 50px; height: 50px; background: rgba(0, 0, 0, 0.7); border: 2px solid #F7931A; border-radius: 50%; color: #F7931A; font-size: 1.5rem; cursor: pointer; z-index: 60; transition: all 0.3s ease; }
.pause-btn:hover { background: #F7931A; color: #000; }
.built-with { position: fixed; bottom: 10px; left: 50%; transform: translateX(-50%); color: rgba(255, 255, 255, 0.5); font-size: 0.8rem; z-index: 200; }
.built-with a { color: #F7931A; text-decoration: none; }
.combo-display { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); font-family: 'Bangers', cursive; font-size: 3rem; color: #eab308; text-shadow: 0 0 20px #eab308, 0 0 40px #eab308; opacity: 0; z-index: 70; pointer-events: none; }
.combo-display.show { animation: comboPopup 1s ease-out forwards; }
@keyframes comboPopup { 0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); } 20% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); } 100% { opacity: 0; transform: translate(-50%, -80%) scale(1); } }
@media (max-width: 600px) { .hud { gap: 10px; } .hud-item { padding: 8px 12px; } .hud-value { font-size: 1rem; } } </style></head><body> <canvas id="gameCanvas"></canvas> <div class="hud" id="hud" style="display: none;"> <div class="hud-item"> <div class="hud-label">Distance</div> <div class="hud-value distance" id="distanceDisplay">0m</div> </div> <div class="hud-item"> <div class="hud-label">₿alance</div> <div class="hud-value" id="btcDisplay">₿ 0.00000000</div> </div> <div class="hud-item"> <div class="hud-label">Speed</div> <div class="hud-value" id="speedDisplay">1x</div> </div> </div>
<div class="powerup-indicator" id="powerupIndicator" style="display: none;"></div>
<button class="pause-btn" id="pauseBtn" style="display: none;">⏸</button>
<div class="combo-display" id="comboDisplay"></div>
<div class="ui-overlay"> <div class="screen active" id="startScreen"> <div class="title">🦖 DINO RUNNER</div> <div class="subtitle">₿ITCOIN EDITION</div> <button class="btn" id="startBtn">PLAY</button> <div class="controls-info"> <span>← →</span> Move Lanes<br> <span>↑</span> Jump | <span>↓</span> Slide<br> <span>SPACE</span> Jump | <span>SHIFT</span> Slide </div> </div>
<div class="screen" id="pauseScreen"> <div class="title" style="font-size: 3rem;">⏸ PAUSED</div> <button class="btn" id="resumeBtn">RESUME</button> <button class="btn" id="quitBtn" style="margin-top: 15px; background: linear-gradient(180deg, #ef4444 0%, #b91c1c 100%);">QUIT</button> </div>
<div class="screen" id="gameOverScreen"> <div class="title" style="color: #ef4444;">GAME OVER</div> <div class="game-over-stats"> <div class="stat-row"> <span>Distance</span> <span class="stat-value" id="finalDistance">0m</span> </div> <div class="stat-row"> <span>Total BTC</span> <span class="stat-value" id="finalBtc">₿ 0.00000000</span> </div> <div class="stat-row"> <span>Best Combo</span> <span class="stat-value" id="bestCombo">x1</span> </div> </div> <button class="btn" id="restartBtn">PLAY AGAIN</button> </div> </div>
<div class="built-with"> Built with <a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank">anycoder</a> </div>
<script> // ============================================ // GAME CONSTANTS & CONFIGURATION // ============================================ const CANVAS_WIDTH = 800; const CANVAS_HEIGHT = 500; const LANE_WIDTH = 120; const LANES = [-1, 0, 1]; // Left, Center, Right const LANE_POSITIONS = [ CANVAS_WIDTH / 2 - LANE_WIDTH, CANVAS_WIDTH / 2, CANVAS_WIDTH / 2 + LANE_WIDTH ];
const GROUND_Y = CANVAS_HEIGHT - 80; const GRAVITY = 0.8; const JUMP_FORCE = -16; const BASE_SPEED = 5; const MAX_SPEED = 15; const SPEED_INCREMENT = 0.001;
// ============================================ // GAME STATE // ============================================ const game = { canvas: null, ctx: null, running: false, paused: false, gameOver: false, distance: 0, speed: BASE_SPEED, lastTime: 0, deltaTime: 0, screenShake: 0, combo: 1, bestCombo: 1, comboTimer: 0 };
// Bitcoin economy const btc = { balance: 0, perCoin: 0.00000001, bonusCoinValue: 0.00000005 };
// Power-up states const powerups = { magnet: { active: false, duration: 0 }, multiplier: { active: false, duration: 0, value: 2 }, shield: { active: false }, speed: { active: false, duration: 0 } };
// ============================================ // DINOSAUR CHARACTER // ============================================ const dino = { x: CANVAS_WIDTH / 2, y: GROUND_Y, lane: 1, targetLane: 1, width: 60, height: 80, velocityY: 0, isJumping: false, isSliding: false, slideTimer: 0, runFrame: 0, runTimer: 0, bobOffset: 0, eyeBlink: 0, isHit: false, hitTimer: 0,
reset() { this.lane = 1; this.targetLane = 1; this.x = LANE_POSITIONS[1]; this.y = GROUND_Y; this.velocityY = 0; this.isJumping = false; this.isSliding = false; this.slideTimer = 0; this.runFrame = 0; this.bobOffset = 0; this.eyeBlink = 0; this.isHit = false; this.hitTimer = 0; },
update(dt) { // Lane movement with smooth interpolation this.targetLane = Math.max(0, Math.min(2, this.targetLane)); const targetX = LANE_POSITIONS[this.targetLane]; this.x += (targetX - this.x) * 0.15; this.lane = this.targetLane;
// Jump physics if (this.isJumping) { this.velocityY += GRAVITY; this.y += this.velocityY; if (this.y >= GROUND_Y) { this.y = GROUND_Y; this.isJumping = false; this.velocityY = 0; } }
// Slide mechanics if (this.isSliding) { this.slideTimer -= dt; if (this.slideTimer <= 0) { this.isSliding = false; } }
// Running animation this.runTimer += dt * 0.01 * game.speed; if (this.runTimer > 1) { this.runTimer = 0; this.runFrame = (this.runFrame + 1) % 4; }
// Bouncy idle animation if (!this.isJumping && !this.isSliding) { this.bobOffset = Math.sin(Date.now() * 0.01) * 3; } else { this.bobOffset = 0; }
// Eye blink this.eyeBlink = Math.random() < 0.005 ? 10 : Math.max(0, this.eyeBlink - 1);
// Hit effect if (this.isHit) { this.hitTimer -= dt; if (this.hitTimer <= 0) { this.isHit = false; } } },
jump() { if (!this.isJumping && !this.isSliding) { this.isJumping = true; this.velocityY = JUMP_FORCE; } },
slide() { if (!this.isJumping && !this.isSliding) { this.isSliding = true; this.slideTimer = 800; } },
moveLeft() { if (this.targetLane > 0) { this.targetLane--; } },
moveRight() { if (this.targetLane < 2) { this.targetLane++; } },
draw(ctx) { ctx.save(); ctx.translate(this.x, this.y + this.bobOffset);
// Hit flash effect if (this.isHit && Math.floor(this.hitTimer / 100) % 2 === 0) { ctx.globalAlpha = 0.5; }
const slideOffset = this.isSliding ? 30 : 0; const height = this.isSliding ? this.height - 30 : this.height;
// Body (green dinosaur) const bodyColor = '#22c55e'; const bodyDark = '#15803d'; // Main body ctx.fillStyle = bodyColor; ctx.beginPath(); ctx.ellipse(0, -height/2 + slideOffset, 28, 35, 0, 0, Math.PI * 2); ctx.fill();
// Tail ctx.beginPath(); ctx.moveTo(-25, -height/2 + slideOffset); ctx.quadraticCurveTo(-45, -height/2 + slideOffset - 10, -40, -height/2 + slideOffset + 15); ctx.quadraticCurveTo(-35, -height/2 + slideOffset + 20, -25, -height/2 + slideOffset + 10); ctx.fill();
// Legs (animated) const legOffset = this.isSliding ? 0 : Math.sin(this.runFrame * Math.PI / 2) * 8; ctx.fillStyle = bodyDark; // Left leg ctx.beginPath(); ctx.ellipse(-12, -10 + slideOffset + legOffset, 8, 15, 0.2, 0, Math.PI * 2); ctx.fill(); // Right leg ctx.beginPath(); ctx.ellipse(12, -10 + slideOffset - legOffset, 8, 15, -0.2, 0, Math.PI * 2); ctx.fill();
// Head ctx.fillStyle = bodyColor; ctx.beginPath(); ctx.ellipse(0, -height - 5, 25, 22, 0, 0, Math.PI * 2); ctx.fill();
// Snout ctx.beginPath(); ctx.ellipse(20, -height - 5, 15, 12, 0, 0, Math.PI * 2); ctx.fill();
// Nostril ctx.fillStyle = bodyDark; ctx.beginPath(); ctx.ellipse(28, -height - 8, 3, 2, 0, 0, Math.PI * 2); ctx.fill();
// Eye white ctx.fillStyle = '#fff'; ctx.beginPath(); ctx.ellipse(8, -height - 12, 10, 11, 0, 0, Math.PI * 2); ctx.fill();
// Eye pupil ctx.fillStyle = '#000'; ctx.beginPath(); ctx.ellipse(10, -height - 10, 5, 6, 0, 0, Math.PI * 2); ctx.fill();
// Eye shine ctx.fillStyle = '#fff'; ctx.beginPath(); ctx.ellipse(12, -height - 13, 2, 2, 0, 0, Math.PI * 2); ctx.fill();
// Eyelid (blink) if (this.eyeBlink > 0) { ctx.fillStyle = bodyDark; ctx.beginPath(); ctx.ellipse(8, -height - 12, 11, this.eyeBlink, 0, 0, Math.PI * 2); ctx.fill(); }
// Headband ctx.fillStyle = '#F7931A'; ctx.fillRect(-28, -height - 22, 56, 10); // Headband knot ctx.beginPath(); ctx.moveTo(-28, -height - 22); ctx.lineTo(-35, -height - 15); ctx.lineTo(-28, -height - 12); ctx.fill();
// Bitcoin symbol on headband ctx.fillStyle = '#fff'; ctx.font = 'bold 8px Arial'; ctx.textAlign = 'center'; ctx.fillText('₿', 0, -height - 15);
// Shield effect if (powerups.shield.active) { ctx.strokeStyle = '#3b82f6'; ctx.lineWidth = 3; ctx.globalAlpha = 0.6 + Math.sin(Date.now() * 0.01) * 0.3; ctx.beginPath(); ctx.arc(0, -height/2, 50, 0, Math.PI * 2); ctx.stroke(); ctx.globalAlpha = 1; }
ctx.restore(); },
getBounds() { const slideOffset = this.isSliding ? 30 : 0; return { x: this.x - 25, y: this.y - this.height + slideOffset, width: 50, height: this.height - slideOffset }; } };
// ============================================ // OBSTACLE SYSTEM // ============================================ const obstacles = []; const obstacleTypes = [ { name: 'barrier', width: 80, height: 60, color: '#ef4444', yOffset: 0 }, { name: 'lowBarrier', width: 80, height: 40, color: '#f97316', yOffset: 0 }, { name: 'arch', width: 100, height: 120, color: '#8b5cf6', yOffset: -40 } ];
function spawnObstacle() { const type = obstacleTypes[Math.floor(Math.random() * obstacleTypes.length)]; const lane = Math.floor(Math.random() * 3); obstacles.push({ x: LANE_POSITIONS[lane], y: GROUND_Y, lane: lane, ...type, passed: false }); }
function updateObstacles(dt) { // Spawn new obstacles based on speed const spawnChance = 0.02 + game.speed * 0.001; if (Math.random() < spawnChance && obstacles.length < 5) { const lastObstacle = obstacles[obstacles.length - 1]; if (!lastObstacle || lastObstacle.x < CANVAS_WIDTH - 200) { spawnObstacle(); } }
// Move and remove obstacles for (let i = obstacles.length - 1; i >= 0; i--) { obstacles[i].x -= game.speed * 60 * (dt / 1000); if (obstacles[i].x < -100) { obstacles.splice(i, 1); } } }
function drawObstacles(ctx) { obstacles.forEach(obs => { ctx.save(); ctx.translate(obs.x, obs.y + obs.yOffset);
// Glow effect ctx.shadowColor = obs.color; ctx.shadowBlur = 15;
if (obs.name === 'arch') { // Draw arch obstacle (must slide to pass) ctx.fillStyle = obs.color; // Left pillar ctx.fillRect(-50, -120, 20, 120); // Right pillar ctx.fillRect(30, -120, 20, 120); // Top bar ctx.fillRect(-50, -120, 100, 20); // Warning stripes ctx.fillStyle = '#fbbf24'; for (let i = 0; i < 3; i++) { ctx.fillRect(-40 + i * 30, -110, 10, 100); } } else if (obs.name === 'lowBarrier') { // Draw low barrier (must jump) ctx.fillStyle = obs.color; ctx.fillRect(-40, -40, 80, 40); // Hazard stripes ctx.fillStyle = '#fbbf24'; ctx.fillRect(-35, -35, 30, 5); ctx.fillRect(-5, -25, 30, 5); ctx.fillRect(-35, -15, 30, 5); } else { // Draw regular barrier ctx.fillStyle = obs.color; ctx.fillRect(-40, -60, 80, 60); // Warning symbol ctx.fillStyle = '#fbbf24'; ctx.beginPath(); ctx.moveTo(0, -45); ctx.lineTo(-15, -25); ctx.lineTo(15, -25); ctx.closePath(); ctx.fill(); ctx.fillStyle = '#000'; ctx.font = 'bold 12px Arial'; ctx.textAlign = 'center'; ctx.fillText('!', 0, -30); }
ctx.restore(); }); }
function checkObstacleCollision() { const dinoBounds = dino.getBounds(); for (const obs of obstacles) { const obsBounds = { x: obs.x - obs.width / 2, y: obs.y + obs.yOffset - (obs.name === 'arch' ? 120 : obs.height), width: obs.width, height: obs.name === 'arch' ? 120 : obs.height };
// Adjust for low barrier (can jump over) if (obs.name === 'lowBarrier' && dino.isJumping && dino.y < GROUND_Y - 30) { continue; }
// Adjust for arch (can slide under) if (obs.name === 'arch' && dino.isSliding) { continue; }
// Check collision if (dinoBounds.x < obsBounds.x + obsBounds.width && dinoBounds.x + dinoBounds.width > obsBounds.x && dinoBounds.y < obsBounds.y + obsBounds.height && dinoBounds.y + dinoBounds.height > obsBounds.y) { if (powerups.shield.active) { powerups.shield.active = false; game.screenShake = 10; updatePowerupUI(); return false; } return true; } } return false; }
// ============================================ // COIN SYSTEM (BITCOIN) // ============================================ const coins = []; const coinParticles = [];
function spawnCoins() { const lane = Math.floor(Math.random() * 3); const pattern = Math.random() < 0.3 ? 'arc' : 'line'; const isBonus = Math.random() < 0.1;
if (pattern === 'arc') { for (let i = 0; i < 5; i++) { coins.push({ x: LANE_POSITIONS[lane], y: GROUND_Y - 40 - Math.sin(i * 0.5) * 30, lane: lane, rotation: Math.random() * Math.PI * 2, glow: 0, value: isBonus ? btc.bonusCoinValue : btc.perCoin, isBonus: isBonus, collected: false }); } } else { const count = isBonus ? 3 : 5; for (let i = 0; i < count; i++) { coins.push({ x: LANE_POSITIONS[lane] - i * 40, y: GROUND_Y - 30, lane: lane, rotation: Math.random() * Math.PI * 2, glow: 0, value: isBonus ? btc.bonusCoinValue : btc.perCoin, isBonus: isBonus, collected: false }); } } }
function updateCoins(dt) { // Spawn coins if (Math.random() < 0.015) { spawnCoins(); }
// Magnet effect if (powerups.magnet.active) { coins.forEach(coin => { if (!coin.collected) { const dx = dino.x - coin.x; const dy = (dino.y - 30) - coin.y; const dist = Math.sqrt(dx * dx + dy * dy); if (dist < 200) { coin.x += dx * 0.1; coin.y += dy * 0.1; } } }); }
// Update coins for (let i = coins.length - 1; i >= 0; i--) { const coin = coins[i]; coin.x -= game.speed * 60 * (dt / 1000); coin.rotation += 0.05; coin.glow = (Math.sin(Date.now() * 0.005) + 1) / 2;
// Collection check if (!coin.collected) { const dx = dino.x - coin.x; const dy = (dino.y - 30) - coin.y; const dist = Math.sqrt(dx * dx + dy * dy); if (dist < 40) { coin.collected = true; collectCoin(coin); // Spawn particles for (let p = 0; p < 10; p++) { coinParticles.push({ x: coin.x, y: coin.y, vx: (Math.random() - 0.5) * 8, vy: (Math.random() - 0.5) * 8, life: 1, color: coin.isBonus ? '#eab308' : '#F7931A' }); } } }
if (coin.x < -50 || coin.collected) { coins.splice(i, 1); } }
// Update particles for (let i = coinParticles.length - 1; i >= 0; i--) { const p = coinParticles[i]; p.x += p.vx; p.y += p.vy; p.life -= 0.03; if (p.life <= 0) { coinParticles.splice(i, 1); } } }
function collectCoin(coin) { const value = coin.value * powerups.multiplier.value; btc.balance += value; // Combo system game.comboTimer = 2000; game.combo = Math.min(game.combo + 1, 10); if (game.combo > game.bestCombo) { game.bestCombo = game.combo; }
// Show combo if (game.combo >= 3) { showCombo(game.combo); }
updateHUD(); }
function showCombo(combo) { const comboEl = document.getElementById('comboDisplay'); comboEl.textContent = `x${combo} COMBO!`; comboEl.classList.remove('show'); void comboEl.offsetWidth; comboEl.classList.add('show'); }
function drawCoins(ctx) { // Draw coins coins.forEach(coin => { if (coin.collected) return; ctx.save(); ctx.translate(coin.x, coin.y);
// Glow effect const glowIntensity = coin.isBonus ? 25 : 15; ctx.shadowColor = coin.isBonus ? '#eab308' : '#F7931A'; ctx.shadowBlur = glowIntensity + coin.glow * 10;
// Coin body (3D rotation effect) const scaleX = Math.cos(coin.rotation); ctx.fillStyle = coin.isBonus ? '#eab308' : '#F7931A'; ctx.beginPath(); ctx.ellipse(0, 0, 18 * Math.abs(scaleX), 18, 0, 0, Math.PI * 2); ctx.fill();
// Bitcoin symbol if (Math.abs(scaleX) > 0.3) { ctx.fillStyle = '#fff'; ctx.font = 'bold 14px Arial'; ctx.textAlign = 'center'; ctx.textBaseline = 'middle'; ctx.fillText('₿', 0, 0); }
// Shine if (scaleX > 0.5) { ctx.fillStyle = 'rgba(255,255,255,0.4)'; ctx.beginPath(); ctx.ellipse(-5, -5, 5, 3, -0.5, 0, Math.PI * 2); ctx.fill(); }
ctx.restore(); });
// Draw particles coinParticles.forEach(p => { ctx.globalAlpha = p.life; ctx.fillStyle = p.color; ctx.beginPath(); ctx.arc(p.x, p.y, 3, 0, Math.PI * 2); ctx.fill(); }); ctx.globalAlpha = 1; }
// ============================================ // POWER-UP SYSTEM // ============================================ const powerupItems = []; const powerupTypes = [ { name: 'magnet', color: '#9333ea', symbol: '🧲', duration: 8000 }, { name: 'multiplier', color: '#eab308', symbol: 'x2', duration: 10000 }, { name: 'shield', color: '#3b82f6', symbol: '🛡', duration: 0 }, { name: 'speed', color: '#ef4444', symbol: '⚡', duration: 5000 } ];
function spawnPowerup() { const type = powerupTypes[Math.floor(Math.random() * powerupTypes.length)]; const lane = Math.floor(Math.random() * 3); powerupItems.push({ x: LANE_POSITIONS[lane], y: GROUND_Y - 50, lane: lane, ...type, rotation: 0, bobOffset: 0 }); }
function updatePowerups(dt) { // Spawn powerups if (Math.random() < 0.002) { spawnPowerup(); }
// Update powerup timers if (powerups.magnet.active) { powerups.magnet.duration -= dt; if (powerups.magnet.duration <= 0) { powerups.magnet.active = false; updatePowerupUI(); } }
if (powerups.multiplier.active) { powerups.multiplier.duration -= dt; if (powerups.multiplier.duration <= 0) { powerups.multiplier.active = false; powerups.multiplier.value = 1; updatePowerupUI(); } }
if (powerups.speed.active) { powerups.speed.duration -= dt; if (powerups.speed.duration <= 0) { powerups.speed.active = false; game.speed = Math.min(game.speed - 3, MAX_SPEED); updatePowerupUI(); } }
// Update powerup items for (let i = powerupItems.length - 1; i >= 0; i--) { const p = powerupItems[i]; p.x -= game.speed * 60 * (dt / 1000); p.rotation += 0.03; p.bobOffset = Math.sin(Date.now() * 0.005) * 5;
// Collection check const dx = dino.x - p.x; const dy = (dino.y - 30) - (p.y + p.bobOffset); const dist = Math.sqrt(dx * dx + dy * dy);
if (dist < 40) { activatePowerup(p.name, p.duration); powerupItems.splice(i, 1); continue; }
if (p.x < -50) { powerupItems.splice(i, 1); } } }
function activatePowerup(name, duration) { switch(name) { case 'magnet': powerups.magnet.active = true; powerups.magnet.duration = duration; break; case 'multiplier': powerups.multiplier.active = true; powerups.multiplier.value = 2; powerups.multiplier.duration = duration; break; case 'shield': powerups.shield.active = true; break; case 'speed': powerups.speed.active = true; powerups.speed.duration = duration; game.speed = Math.min(game.speed + 3, MAX_SPEED); break; } updatePowerupUI(); }
function updatePowerupUI() { const indicator = document.getElementById('powerupIndicator'); indicator.innerHTML = ''; if (powerups.magnet.active) { indicator.innerHTML += '<div class="powerup-badge magnet active">🧲 MAGNET</div>'; } if (powerups.multiplier.active) { indicator.innerHTML += '<div class="powerup-badge multiplier active">x2 MULTIPLIER</div>'; } if (powerups.shield.active) { indicator.innerHTML += '<div class="powerup-badge shield active">🛡 SHIELD</div>'; } if (powerups.speed.active) { indicator.innerHTML += '<div class="powerup-badge speed active">⚡ SPEED</div>'; } }
function drawPowerups(ctx) { powerupItems.forEach(p => { ctx.save(); ctx.translate(p.x, p.y + p.bobOffset); ctx.rotate(p.rotation);
// Glow ctx.shadowColor = p.color; ctx.shadowBlur = 20;
// Background circle ctx.fillStyle = p.color; ctx.beginPath(); ctx.arc(0, 0, 25, 0, Math.PI * 2); ctx.fill();
// Inner circle ctx.fillStyle = '#fff'; ctx.beginPath(); ctx.arc(0, 0, 18, 0, Math.PI * 2); ctx.fill();
// Symbol ctx.fillStyle = p.color; ctx.font = 'bold 16px Arial'; ctx.textAlign = 'center'; ctx.textBaseline = 'middle'; ctx.fillText(p.symbol, 0, 0);
ctx.restore(); }); }
// ============================================ // BACKGROUND & ENVIRONMENT // ============================================ const background = { layers: [ { speed: 0.2, y: 0, color: '#1e3a5f' }, { speed: 0.4, y: 50, color: '#2563eb' }, { speed: 0.6, y: 100, color: '#3b82f6' } ], clouds: [], buildings: [],
init() { // Generate clouds for (let i = 0; i < 10; i++) { this.clouds.push({ x: Math.random() * CANVAS_WIDTH, y: 30 + Math.random() * 80, size: 30 + Math.random() * 40, speed: 0.3 + Math.random() * 0.3 }); }
// Generate buildings for (let i = 0; i < 15; i++) { this.buildings.push({ x: i * 80, width: 40 + Math.random() * 40, height: 60 + Math.random() * 100, color: `hsl(${200 + Math.random() * 40}, 60%, ${20 + Math.random() * 20}%)` }); } },
update(dt) { const moveAmount = game.speed * 60 * (dt / 1000);
// Move clouds this.clouds.forEach(cloud => { cloud.x -= cloud.speed * moveAmount * 0.5; if (cloud.x < -100) { cloud.x = CANVAS_WIDTH + 50; cloud.y = 30 + Math.random() * 80; } });
// Move buildings this.buildings.forEach(building => { building.x -= moveAmount * 0.3; if (building.x < -building.width) { building.x = CANVAS_WIDTH + Math.random() * 50; building.height = 60 + Math.random() * 100; } }); },
draw(ctx) { // Sky gradient const gradient = ctx.createLinearGradient(0, 0, 0, CANVAS_HEIGHT); gradient.addColorStop(0, '#1e3a5f'); gradient.addColorStop(0.5, '#3b82f6'); gradient.addColorStop(1, '#60a5fa'); ctx.fillStyle = gradient; ctx.fillRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT);
// Clouds ctx.fillStyle = 'rgba(255, 255, 255, 0.8)'; this.clouds.forEach(cloud => { ctx.beginPath(); ctx.arc(cloud.x, cloud.y, cloud.size * 0.6, 0, Math.PI * 2); ctx.arc(cloud.x + cloud.size * 0.4, cloud.y - cloud.size * 0.2, cloud.size * 0.4, 0, Math.PI * 2); ctx.arc(cloud.x + cloud.size * 0.8, cloud.y, cloud.size * 0.5, 0, Math.PI * 2); ctx.fill(); });
// Distant buildings (parallax) this.buildings.forEach(building => { ctx.fillStyle = building.color; ctx.fillRect(building.x, GROUND_Y - building.height, building.width, building.height); // Windows ctx.fillStyle = 'rgba(255, 255, 150, 0.6)'; for (let wy = GROUND_Y - building.height + 10; wy < GROUND_Y - 10; wy += 15) { for (let wx = building.x + 5; wx < building.x + building.width - 10; wx += 12) { ifindex.html+1207-19