Spaces:
Running
Running
Upload folder using huggingface_hub
Browse files1 unmodified line234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211 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>BTC Dino Runner</title><link href="https://fonts.googleapis.com/css2?family=Fredoka+One&family=Nunito:wght@400;700;900&display=swap" rel="stylesheet"><style>:root {--bg-primary: #1a1a2e;--bg-secondary: #16213e;--accent-gold: #f7931a;--accent-green: #00d26a;--accent-cyan: #00d4ff;--text-primary: #ffffff;--text-secondary: #a0a0c0;--danger: #ff4757;--success: #2ed573;}* {margin: 0;padding: 0;box-sizing: border-box;}body {font-family: 'Nunito', sans-serif;background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);min-height: 100vh;overflow: hidden;display: flex;justify-content: center;align-items: center;}#gameContainer {position: relative;width: 100%;max-width: 800px;aspect-ratio: 16/9;border-radius: 16px;overflow: hidden;box-shadow:0 0 60px rgba(247, 147, 26, 0.2),0 0 120px rgba(0, 210, 106, 0.1),0 25px 50px rgba(0, 0, 0, 0.5);}#gameCanvas {width: 100%;height: 100%;display: block;background: #0f0f23;}.screen-overlay {position: absolute;top: 0;left: 0;width: 100%;height: 100%;display: flex;flex-direction: column;justify-content: center;align-items: center;background: rgba(15, 15, 35, 0.95);backdrop-filter: blur(10px);transition: opacity 0.5s ease, visibility 0.5s ease;z-index: 10;}.screen-overlay.hidden {opacity: 0;visibility: hidden;pointer-events: none;}.game-title {font-family: 'Fredoka One', cursive;font-size: clamp(2rem, 8vw, 4rem);background: linear-gradient(135deg, var(--accent-gold) 0%, #ffd700 50%, var(--accent-gold) 100%);-webkit-background-clip: text;-webkit-text-fill-color: transparent;background-clip: text;text-shadow: none;margin-bottom: 0.5rem;animation: titlePulse 2s ease-in-out infinite;}@keyframes titlePulse {0%, 100% { transform: scale(1); }50% { transform: scale(1.02); }}.subtitle {font-size: clamp(0.9rem, 3vw, 1.2rem);color: var(--text-secondary);margin-bottom: 2rem;}.start-dino-container {width: 150px;height: 150px;margin-bottom: 2rem;animation: dinoBounce 1s ease-in-out infinite;}@keyframes dinoBounce {0%, 100% { transform: translateY(0) rotate(-2deg); }50% { transform: translateY(-15px) rotate(2deg); }}.btn {font-family: 'Fredoka One', cursive;font-size: clamp(1rem, 4vw, 1.4rem);padding: 1rem 3rem;border: none;border-radius: 50px;cursor: pointer;transition: all 0.3s ease;position: relative;overflow: hidden;}.btn-primary {background: linear-gradient(135deg, var(--accent-gold) 0%, #ff9500 100%);color: #1a1a2e;box-shadow: 0 8px 30px rgba(247, 147, 26, 0.4);}.btn-primary:hover {transform: translateY(-3px) scale(1.05);box-shadow: 0 12px 40px rgba(247, 147, 26, 0.6);}.btn-primary:active {transform: translateY(0) scale(0.98);}.btn-secondary {background: rgba(255, 255, 255, 0.1);color: var(--text-primary);border: 2px solid rgba(255, 255, 255, 0.2);margin-top: 1rem;}.btn-secondary:hover {background: rgba(255, 255, 255, 0.2);border-color: rgba(255, 255, 255, 0.4);}.controls-info {margin-top: 2rem;display: flex;gap: 1rem;flex-wrap: wrap;justify-content: center;}.control-item {display: flex;align-items: center;gap: 0.5rem;background: rgba(255, 255, 255, 0.05);padding: 0.5rem 1rem;border-radius: 20px;font-size: 0.85rem;color: var(--text-secondary);}.key-badge {background: rgba(255, 255, 255, 0.15);padding: 0.25rem 0.6rem;border-radius: 6px;font-weight: 700;color: var(--text-primary);font-size: 0.75rem;}.stats-container {display: grid;grid-template-columns: repeat(2, 1fr);gap: 1rem;margin: 1.5rem 0;width: 100%;max-width: 300px;}.stat-item {background: rgba(255, 255, 255, 0.05);padding: 1rem;border-radius: 12px;text-align: center;}.stat-label {font-size: 0.75rem;color: var(--text-secondary);text-transform: uppercase;letter-spacing: 1px;}.stat-value {font-family: 'Fredoka One', cursive;font-size: 1.2rem;color: var(--accent-gold);margin-top: 0.25rem;}.high-score-badge {background: linear-gradient(135deg, var(--accent-green) 0%, #00a854 100%);color: white;padding: 0.5rem 1.5rem;border-radius: 20px;font-weight: 700;margin-bottom: 1rem;animation: badgePop 0.5s ease;}@keyframes badgePop {0% { transform: scale(0); }50% { transform: scale(1.2); }100% { transform: scale(1); }}.built-with {position: absolute;top: 10px;left: 10px;font-size: 0.7rem;color: var(--text-secondary);z-index: 100;text-decoration: none;opacity: 0.7;transition: opacity 0.3s;}.built-with:hover {opacity: 1;color: var(--accent-cyan);}/* Mobile touch controls */.touch-controls {position: absolute;bottom: 20px;left: 0;right: 0;display: none;justify-content: space-between;padding: 0 20px;z-index: 5;}@media (pointer: coarse) {.touch-controls {display: flex;}}.touch-btn {width: 60px;height: 60px;border-radius: 50%;background: rgba(255, 255, 255, 0.15);border: 2px solid rgba(255, 255, 255, 0.3);display: flex;justify-content: center;align-items: center;color: white;font-size: 1.5rem;backdrop-filter: blur(5px);transition: all 0.2s;-webkit-tap-highlight-color: transparent;}.touch-btn:active {background: rgba(255, 255, 255, 0.3);transform: scale(0.95);}.touch-btn-group {display: flex;gap: 15px;}/* Responsive adjustments */@media (max-width: 600px) {#gameContainer {border-radius: 0;max-width: 100%;height: 100vh;aspect-ratio: auto;}.stats-container {grid-template-columns: 1fr 1fr;padding: 0 1rem;}.controls-info {display: none;}}</style></head><body><div id="gameContainer"><a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank" class="built-with">Built with anycoder</a><canvas id="gameCanvas"></canvas><!-- Start Screen --><div id="startScreen" class="screen-overlay"><h1 class="game-title">BTC DINO RUN</h1><p class="subtitle">Collect Satoshi, Dodge Obstacles!</p><canvas id="startDinoCanvas" class="start-dino-container" width="150" height="150"></canvas><button id="startBtn" class="btn btn-primary">START RUNNING</button><div class="controls-info"><div class="control-item"><span class="key-badge">A/D</span> Move</div><div class="control-item"><span class="key-badge">W/SPACE</span> Jump</div><div class="control-item"><span class="key-badge">S</span> Slide</div><div class="control-item"><span class="key-badge">P/ESC</span> Pause</div></div></div><!-- Pause Screen --><div id="pauseScreen" class="screen-overlay hidden"><h2 class="game-title" style="font-size: 2.5rem;">PAUSED</h2><button id="resumeBtn" class="btn btn-primary">RESUME</button><button id="quitBtn" class="btn btn-secondary">QUIT TO MENU</button></div><!-- Game Over Screen --><div id="gameOverScreen" class="screen-overlay hidden"><h2 class="game-title" style="font-size: 2.5rem;">GAME OVER</h2><div id="newHighScore" class="high-score-badge" style="display: none;">NEW HIGH SCORE!</div><div class="stats-container"><div class="stat-item"><div class="stat-label">Distance</div><div class="stat-value" id="finalDistance">0m</div></div><div class="stat-item"><div class="stat-label">BTC Collected</div><div class="stat-value" id="finalBTC">0.00000000</div></div><div class="stat-item"><div class="stat-label">Top Speed</div><div class="stat-value" id="finalSpeed">0</div></div><div class="stat-item"><div class="stat-label">Best Combo</div><div class="stat-value" id="finalCombo">x0</div></div></div><button id="restartBtn" class="btn btn-primary">PLAY AGAIN</button><button id="menuBtn" class="btn btn-secondary">MAIN MENU</button></div><!-- Touch Controls --><div class="touch-controls" id="touchControls"><div class="touch-btn-group"><button class="touch-btn" id="touchLeft">◀</button><button class="touch-btn" id="touchRight">▶</button></div><div class="touch-btn-group"><button class="touch-btn" id="touchSlide">▼</button><button class="touch-btn" id="touchJump">▲</button></div></div></div><script>// ==========================================// GAME CONFIGURATION// ==========================================const CONFIG = {// Canvas dimensionsCANVAS_WIDTH: 800,CANVAS_HEIGHT: 450,// Lane systemLANE_COUNT: 3,LANE_WIDTH: 120,// Dinosaur propertiesDINO_WIDTH: 60,DINO_HEIGHT: 80,DINO_JUMP_FORCE: -15,DINO_GRAVITY: 0.6,DINO_SLIDE_SCALE: 0.4,// Game speedINITIAL_SPEED: 8,MAX_SPEED: 25,SPEED_INCREMENT: 0.002,// ObstaclesOBSTACLE_SPAWN_RATE: 0.025,MIN_OBSTACLE_GAP: 300,// CoinsCOIN_SPAWN_RATE: 0.04,COIN_VALUE_MIN: 0.00000001,COIN_VALUE_MAX: 0.00000010,BONUS_COIN_CHANCE: 0.1,BONUS_COIN_MULTIPLIER: 5,// Power-upsPOWERUP_SPAWN_RATE: 0.008,POWERUP_DURATION: 8000,MAGNET_RANGE: 150,// VisualPARALLAX_LAYERS: 4,PARTICLE_COUNT: 50};// ==========================================// UTILITY FUNCTIONS// ==========================================const Utils = {lerp: (a, b, t) => a + (b - a) * t,clamp: (val, min, max) => Math.max(min, Math.min(max, val)),random: (min, max) => Math.random() * (max - min) + min,randomInt: (min, max) => Math.floor(Utils.random(min, max + 1)),easeOut: (t) => 1 - Math.pow(1 - t, 3),easeInOut: (t) => t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2,formatBTC: (value) => {return value.toFixed(8);},formatDistance: (value) => {if (value >= 1000) {return (value / 1000).toFixed(2) + 'km';}return Math.floor(value) + 'm';},hexToRgba: (hex, alpha) => {const r = parseInt(hex.slice(1, 3), 16);const g = parseInt(hex.slice(3, 5), 16);const b = parseInt(hex.slice(5, 7), 16);return `rgba(${r},${g},${b},${alpha})`;}};// ==========================================// PARTICLE SYSTEM// ==========================================class Particle {constructor(x, y, color, velocity, size, life) {this.x = x;this.y = y;this.color = color;this.vx = velocity.x;this.vy = velocity.y;this.size = size;this.life = life;this.maxLife = life;this.gravity = 0.1;}update(dt) {this.x += this.vx * dt;this.y += this.vy * dt;this.vy += this.gravity * dt;this.life -= dt;}draw(ctx) {const alpha = Utils.clamp(this.life / this.maxLife, 0, 1);ctx.save();ctx.globalAlpha = alpha;ctx.fillStyle = this.color;ctx.beginPath();ctx.arc(this.x, this.y, this.size * alpha, 0, Math.PI * 2);ctx.fill();ctx.restore();}get isDead() {return this.life <= 0;}}class ParticleSystem {constructor() {this.particles = [];}emit(x, y, count, config) {for (let i = 0; i < count; i++) {const angle = Utils.random(0, Math.PI * 2);const speed = Utils.random(config.minSpeed || 1, config.maxSpeed || 5);const velocity = {x: Math.cos(angle) * speed,y: Math.sin(angle) * speed - 2};const particle = new Particle(x + Utils.random(-5, 5),y + Utils.random(-5, 5),config.colors[Utils.randomInt(0, config.colors.length - 1)],velocity,Utils.random(config.minSize || 2, config.maxSize || 6),Utils.random(config.minLife || 20, config.maxLife || 40));this.particles.push(particle);}}update(dt) {this.particles.forEach(p => p.update(dt));this.particles = this.particles.filter(p => !p.isDead);}draw(ctx) {this.particles.forEach(p => p.draw(ctx));}}// ==========================================// BACKGROUND SYSTEM// ==========================================class BackgroundLayer {constructor(speed, y, height, color1, color2, hasDetails = false) {this.speed = speed;this.y = y;this.height = height;this.color1 = color1;this.color2 = color2;this.offset = 0;this.hasDetails = hasDetails;this.details = [];if (hasDetails) {this.generateDetails();}}generateDetails() {for (let i = 0; i < 20; i++) {this.details.push({x: Utils.random(0, CONFIG.CANVAS_WIDTH * 3),type: Utils.randomInt(0, 2),size: Utils.random(20, 60)});}}update(gameSpeed, dt) {this.offset += this.speed * gameSpeed * dt;if (this.offset > CONFIG.CANVAS_WIDTH) {this.offset -= CONFIG.CANVAS_WIDTH;}}draw(ctx, canvasWidth, canvasHeight) {// Draw gradient backgroundconst gradient = ctx.createLinearGradient(0, this.y, 0, this.y + this.height);gradient.addColorStop(0, this.color1);gradient.addColorStop(1, this.color2);ctx.fillStyle = gradient;ctx.fillRect(0, this.y, canvasWidth, this.height);if (this.hasDetails) {this.drawDetails(ctx, canvasWidth);}}drawDetails(ctx, canvasWidth) {ctx.fillStyle = 'rgba(255,255,255,0.03)';this.details.forEach(detail => {let x = (detail.x - this.offset * 0.5) % (canvasWidth * 2);if (x < -100) x += canvasWidth * 2;if (detail.type === 0) {// Building silhouettectx.fillRect(x, this.y + this.height - detail.size, detail.size * 0.6, detail.size);} else if (detail.type === 1) {// Tree silhouettectx.beginPath();ctx.moveTo(x, this.y + this.height);ctx.lineTo(x + detail.size / 2, this.y + this.height - detail.size);ctx.lineTo(x + detail.size, this.y + this.height);ctx.fill();} else {// Hillctx.beginPath();ctx.arc(x, this.y + this.height, detail.size, Math.PI, 0);ctx.fill();}});}}// ==========================================// TRACK/GROUND SYSTEM// ==========================================class Track {constructor() {this.lanes = [];this.lanePositions = [];this.calculateLanePositions();this.groundOffset = 0;this.trackLines = [];// Generate track line patternsfor (let i = 0; i < 50; i++) {this.trackLines.push({x: Utils.random(0, CONFIG.CANVAS_WIDTH * 2),width: Utils.random(2, 8),alpha: Utils.random(0.1, 0.3)});}}calculateLanePositions() {const centerX = CONFIG.CANVAS_WIDTH / 2;const totalWidth = CONFIG.LANE_COUNT * CONFIG.LANE_WIDTH;const startX = centerX - totalWidth / 2 + CONFIG.LANE_WIDTH / 2;for (let i = 0; i < CONFIG.LANE_COUNT; i++) {this.lanePositions.push(startX + i * CONFIG.LANE_WIDTH);}}getLanePosition(laneIndex) {return this.lanePositions[Utils.clamp(laneIndex, 0, CONFIG.LANE_COUNT - 1)];}update(gameSpeed, dt) {this.groundOffset += gameSpeed * dt;if (this.groundOffset > 100) {this.groundOffset -= 100;}}draw(ctx, canvasWidth, canvasHeight) {const groundY = canvasHeight - 100;// Main groundconst groundGradient = ctx.createLinearGradient(0, groundY, 0, canvasHeight);groundGradient.addColorStop(0, '#2d4a3e');groundGradient.addColorStop(0.3, '#1e3a2e');groundGradient.addColorStop(1, '#0f1f1a');ctx.fillStyle = groundGradient;ctx.fillRect(0, groundY, canvasWidth, canvasHeight - groundY);// Lane dividersctx.strokeStyle = 'rgba(255,255,255,0.15)';ctx.lineWidth = 2;ctx.setLineDash([20, 20]);for (let i = 0; i <= CONFIG.LANE_COUNT; i++) {const x = this.lanePositions[0] - CONFIG.LANE_WIDTH / 2 + i * CONFIG.LANE_WIDTH;ctx.beginPath();ctx.moveTo(x, groundY);ctx.lineTo(x, canvasHeight);ctx.stroke();}ctx.setLineDash([]);// Track lines for motion effectthis.trackLines.forEach(line => {let x = (line.x - this.groundOffset * 3) % (canvasWidth * 2);if (x < -50) x += canvasWidth * 2;ctx.fillStyle = `rgba(255,255,255,${line.alpha})`;ctx.fillRect(x, groundY + 5, line.width, 2);ctx.fillRect(x, groundY + 15, line.width * 0.5, 1);});// Ground top edge highlightctx.strokeStyle = 'rgba(0,210,106,0.5)';ctx.lineWidth = 3;ctx.beginPath();ctx.moveTo(0, groundY);ctx.lineTo(canvasWidth, groundY);ctx.stroke();}}// ==========================================// DINOSAUR PLAYER// ==========================================class Dinosaur {constructor(track) {this.track = track;this.lane = 1; // Start in middle lanethis.targetLane = 1;this.x = track.getLanePosition(this.lane);this.y = CONFIG.CANVAS_HEIGHT - 100 - CONFIG.DINO_HEIGHT;this.groundY = this.y;this.width = CONFIG.DINO_WIDTH;this.height = CONFIG.DINO_HEIGHT;// Physicsthis.vy = 0;this.isJumping = false;this.isSliding = false;this.slideTimer = 0;this.laneTransition = 0;this.targetX = this.x;// Animationthis.runFrame = 0;this.runTimer = 0;this.bounceOffset = 0;this.bounceTimer = 0;this.tiltAngle = 0;// Power-up statesthis.hasShield = false;this.hasMagnet = false;this.hasMultiplier = false;this.hasSpeedBoost = false;// Visual effectsthis.invincibleTimer = 0;this.flashTimer = 0;}jump() {if (!this.isJumping && !this.isSliding) {this.isJumping = true;this.vy = CONFIG.DINO_JUMP_FORCE;}}slide() {if (!this.isJumping && !this.isSliding) {this.isSliding = true;this.slideTimer = 600; // ms}}moveLeft() {if (this.targetLane > 0) {this.targetLane--;this.targetX = this.track.getLanePosition(this.targetLane);this.laneTransition = 1;this.tiltAngle = -0.2;}}moveRight() {if (this.targetLane < CONFIG.LANE_COUNT - 1) {this.targetLane++;this.targetX = this.track.getLanePosition(this.targetLane);this.laneTransition = 1;this.tiltAngle = 0.2;}}update(dt) {// Lane transitionif (this.laneTransition > 0) {this.laneTransition -= dt * 0.008;if (this.laneTransition <= 0) {this.laneTransition = 0;this.lane = this.targetLane;}this.x = Utils.lerp(this.x, this.targetX, 0.15);}// Tilt recoverythis.tiltAngle = Utils.lerp(this.tiltAngle, 0, 0.1);// Jump physicsif (this.isJumping) {this.vy += CONFIG.DINO_GRAVITY * dt;this.y += this.vy * dt;if (this.y >= this.groundY) {this.y = this.groundY;this.isJumping = false;this.vy = 0;}}// Slide timerif (this.isSliding) {this.slideTimer -= dt;if (this.slideTimer <= 0) {this.isSliding = false;}}// Running animationthis.runTimer += dt;if (this.runTimer > 80) {this.runTimer = 0;this.runFrame = (this.runFrame + 1) % 4;}// Bounce effectif (!this.isJumping && !this.isSliding) {this.bounceTimer += dt * 0.01;this.bounceOffset = Math.sin(this.bounceTimer * 2) * 3;}// Invincibility flashif (this.invincibleTimer > 0) {this.invincibleTimer -= dt;this.flashTimer += dt;}}draw(ctx) {ctx.save();// Positionconst drawX = this.x;let drawY = this.y + this.bounceOffset;let scale = 1;// Slide transformationif (this.isSliding) {drawY = this.groundY + this.height * 0.5;scale = CONFIG.DINO_SLIDE_SCALE;}ctx.translate(drawX, drawY);ctx.rotate(this.tiltAngle);// Flash effect for invincibilityif (this.invincibleTimer > 0 && Math.floor(this.flashTimer / 50) % 2 === 0) {ctx.globalAlpha = 0.5;}// Shield effectif (this.hasShield) {ctx.beginPath();ctx.arc(0, -this.height * scale / 2, this.width * 0.8, 0, Math.PI * 2);ctx.strokeStyle = 'rgba(0,212,255,0.6)';ctx.lineWidth = 3;ctx.stroke();ctx.fillStyle = 'rgba(0,212,255,0.1)';ctx.fill();}// Draw dinosaur bodythis.drawBody(ctx, scale);ctx.restore();}drawBody(ctx, scale) {const s = scale;// Body (main oval)ctx.fillStyle = '#2ecc71';ctx.beginPath();ctx.ellipse(0, -35 * s, 25 * s, 35 * s, 0, 0, Math.PI * 2);ctx.fill();// Belly highlightctx.fillStyle = '#58d68d';ctx.beginPath();ctx.ellipse(5 * s, -30 * s, 15 * s, 25 * s, 0.2, 0, Math.PI * 2);ctx.fill();// Headctx.fillStyle = '#2ecc71';ctx.beginPath();ctx.ellipse(15 * s, -60 * s, 20 * s, 18 * s, 0.3, 0, Math.PI * 2);ctx.fill();// Head highlightctx.fillStyle = '#58d68d';ctx.beginPath();ctx.ellipse(18 * s, -62 * s, 12 * s, 10 * s, 0.3, 0, Math.PI * 2);ctx.fill();// Eyes (big expressive eyes)// Left eye whitectx.fillStyle = '#ffffff';ctx.beginPath();ctx.ellipse(22 * s, -65 * s, 8 * s, 10 * s, 0, 0, Math.PI * 2);ctx.fill();// Right eye whitectx.beginPath();ctx.ellipse(35 * s, -63 * s, 7 * s, 9 * s, 0, 0, Math.PI * 2);ctx.fill();// Pupilsctx.fillStyle = '#1a1a2e';ctx.beginPath();ctx.arc(24 * s, -64 * s, 4 * s, 0, Math.PI * 2);ctx.fill();ctx.beginPath();ctx.arc(36 * s, -62 * s, 3.5 * s, 0, Math.PI * 2);ctx.fill();// Eye shinectx.fillStyle = '#ffffff';ctx.beginPath();ctx.arc(25 * s, -66 * s, 1.5 * s, 0, Math.PI * 2);ctx.fill();ctx.beginPath();ctx.arc(37 * s, -64 * s, 1.2 * s, 0, Math.PI * 2);ctx.fill();// Headbandctx.fillStyle = '#e74c3c';ctx.beginPath();ctx.moveTo(-5 * s, -75 * s);ctx.lineTo(35 * s, -70 * s);ctx.lineTo(33 * s, -65 * s);ctx.lineTo(-7 * s, -70 * s);ctx.closePath();ctx.fill();// Bitcoin symbol on headbandctx.fillStyle = '#f7931a';ctx.beginPath();ctx.arc(15 * s, -72 * s, 8 * s, 0, Math.PI * 2);ctx.fill();// Draw ₿ symbolctx.fillStyle = '#ffffff';ctx.font = `bold ${10 * s}px Arial`;ctx.textAlign = 'center';ctx.textBaseline = 'middle';ctx.fillText('₿', 15 * s, -72 * s);// Mouth (smile)ctx.strokeStyle = '#1a5a3a';ctx.lineWidth = 2 * s;ctx.beginPath();ctx.arc(30 * s, -52 * s, 6 * s, 0.2, Math.PI - 0.2);ctx.stroke();// Armsctx.fillStyle = '#2ecc71';const armAngle = this.isSliding ? 0.5 : Math.sin(this.runTimer * 0.05) * 0.3;ctx.save();ctx.translate(-20 * s, -40 * s);ctx.rotate(armAngle);ctx.beginPath();ctx.ellipse(0, 10 * s, 6 * s, 15 * s, 0, 0, Math.PI * 2);ctx.fill();ctx.restore();// Legsif (!this.isSliding) {const legOffset = this.runFrame % 2 === 0 ? 5 : -5;// Left legctx.fillStyle = '#27ae60';ctx.beginPath();ctx.ellipse(-10 * s + legOffset * s, -5 * s, 8 * s, 12 * s, legOffset * 0.02, 0, Math.PI * 2);ctx.fill();// Right legctx.beginPath();ctx.ellipse(10 * s - legOffset * s, -5 * s, 8 * s, 12 * s, -legOffset * 0.02, 0, Math.PI * 2);ctx.fill();}// Tailctx.fillStyle = '#2ecc71';ctx.beginPath();ctx.moveTo(-25 * s, -35 * s);ctx.quadraticCurveTo(-45 * s, -30 * s, -50 * s, -45 * s);ctx.quadraticCurveTo(-40 * s, -50 * s, -25 * s, -45 * s);ctx.fill();// Magnet effect indicatorif (this.hasMagnet) {ctx.strokeStyle = 'rgba(255,215,0,0.5)';ctx.lineWidth = 2;ctx.beginPath();ctx.arc(0, -35 * s, 40 * s, 0, Math.PI * 2);ctx.stroke();}}getHitbox() {const slideOffset = this.isSliding ? this.height * 0.6 : 0;return {x: this.x - this.width / 2 + 10,y: this.y + slideOffset,width: this.width - 20,height: this.height * (this.isSliding ? CONFIG.DINO_SLIDE_SCALE : 1) - 10};}}// ==========================================// OBSTACLE SYSTEM// ==========================================class Obstacle {constructor(lane, type, track, groundY) {this.lane = lane;this.type = type;this.x = track.getLanePosition(lane);this.y = groundY;this.width = 50;this.height = 60;this.needsJump = true;this.needsSlide = false;this.setupByType();}setupByType() {switch (this.type) {case 'barrier':this.width = 50;this.height = 70;this.needsJump = true;this.needsSlide = false;break;case 'lowBarrier':this.width = 60;this.height = 35;this.needsJump = false;this.needsSlide = true;break;case 'doubleBarrier':this.width = 45;this.height = 90;this.needsJump = true;this.needsSlide = false;break;case 'spike':this.width = 40;this.height = 50;this.needsJump = true;this.needsSlide = false;break;case 'crate':this.width = 55;this.height = 55;this.needsJump = true;this.needsSlide = false;break;}}update(gameSpeed, dt) {this.x -= gameSpeed * dt;}draw(ctx) {ctx.save();ctx.translate(this.x, this.y);switch (this.type) {case 'barrier':this.drawBarrier(ctx);break;case 'lowBarrier':this.drawLowBarrier(ctx);break;case 'doubleBarrier':this.drawDoubleBarrier(ctx);break;case 'spike':this.drawSpike(ctx);break;case 'crate':this.drawCrate(ctx);break;}ctx.restore();}drawBarrier(ctx) {// Main barrier bodyconst gradient = ctx.createLinearGradient(0, -this.height, 0, 0);gradient.addColorStop(0, '#c0392b');gradient.addColorStop(1, '#922b21');ctx.fillStyle = gradient;ctx.fillRect(-this.width / 2, -this.height, this.width, this.height);// Warning stripesctx.fillStyle = '#f1c40f';for (let i = 0; i < 3; i++) {ctx.fillRect(-this.width / 2 + 5, -this.height + 15 + i * 25, this.width - 10, 8);}// Top capctx.fillStyle = '#e74c3c';ctx.fillRect(-this.width / 2 - 5, -this.height - 5, this.width + 10, 10);}drawLowBarrier(ctx) {// Low pipe/barrierconst gradient = ctx.createLinearGradient(0, -this.height, 0, 0);gradient.addColorStop(0, '#7f8c8d');gradient.addColorStop(0.5, '#95a5a6');gradient.addColorStop(1, '#7f8c8d');ctx.fillStyle = gradient;ctx.fillRect(-this.width / 2, -this.height, this.width, this.height);// Highlightsctx.fillStyle = 'rgba(255,255,255,0.3)';ctx.fillRect(-this.width / 2 + 5, -this.height + 3, 10, this.height - 6);}drawDoubleBarrier(ctx) {// Two stacked barriersctx.fillStyle = '#8e44ad';ctx.fillRect(-this.width / 2, -this.height * 0.55, this.width, this.height * 0.55);ctx.fillRect(-this.width / 2, -this.height, this.width, this.height * 0.45);// Warning symbolsctx.fillStyle = '#f39c12';ctx.font = 'bold 20px Arial';ctx.textAlign = 'center';ctx.fillText('!', 0, -this.height * 0.3);ctx.fillText('!', 0, -this.height * 0.8);}drawSpike(ctx) {ctx.fillStyle = '#7f8c8d';ctx.beginPath();ctx.moveTo(-this.width / 2, 0);ctx.lineTo(0, -this.height);ctx.lineTo(this.width / 2, 0);ctx.closePath();ctx.fill();// Shinectx.fillStyle = 'rgba(255,255,255,0.3)';ctx.beginPath();ctx.moveTo(-this.width / 4, -this.height * 0.3);ctx.lineTo(0, -this.height * 0.8);ctx.lineTo(this.width / 8, -this.height * 0.3);ctx.closePath();ctx.fill();}drawCrate(ctx) {// Wooden crateconst gradient = ctx.createLinearGradient(0, -this.height, 0, 0);gradient.addColorStop(0, '#d68910');gradient.addColorStop(1, '#b9770e');ctx.fillStyle = gradient;ctx.fillRect(-this.width / 2, -this.height, this.width, this.height);// Cross planksctx.strokeStyle = '#7e5109';ctx.lineWidth = 3;ctx.beginPath();ctx.moveTo(-this.width / 2, -this.height);ctx.lineTo(this.width / 2, 0);ctx.moveTo(this.width / 2, -this.height);ctx.lineTo(-this.width / 2, 0);ctx.stroke();// Borderctx.strokeStyle = '#6e4a09';ctx.lineWidth = 4;ctx.strokeRect(-this.width / 2, -this.height, this.width, this.height);}getHitbox() {return {x: this.x - this.width / 2 + 5,y: this.y - this.height + 5,width: this.width - 10,height: this.height - 10};}get isOffScreen() {return this.x < -100;}}// ==========================================// COIN SYSTEM// ==========================================class Coin {constructor(lane, track, groundY, isBonus = false) {this.lane = lane;this.x = track.getLanePosition(lane);this.y = groundY - 60;this.baseY = this.y;this.radius = 18;this.isBonus = isBonus;this.rotation = 0;this.bobOffset = Utils.random(0, Math.PI * 2);this.glowIntensity = 0;this.glowDirection = 1;// BTC valueif (isBonus) {this.value = Utils.random(CONFIG.COIN_VALUE_MIN, CONFIG.COIN_VALUE_MAX) * CONFIG.BONUS_COIN_MULTIPLIER;} else {this.value = Utils.random(CONFIG.COIN_VALUE_MIN, CONFIG.COIN_VALUE_MAX);}}update(gameSpeed, dt) {this.x -= gameSpeed * dt;this.rotation += dt * 0.01;this.bobOffset += dt * 0.005;this.y = this.baseY + Math.sin(this.bobOffset) * 8;// Glow pulsethis.glowIntensity += this.glowDirection * dt * 0.003;if (this.glowIntensity > 1) {this.glowDirection = -1;} else if (this.glowIntensity < 0) {this.glowDirection = 1;}}draw(ctx) {ctx.save();ctx.translate1 unmodified line234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821 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>Bitcoin Dino: Endless Runner</title><style>:root {--primary-color: #f7931a; /* Bitcoin Orange */--accent-color: #00ff00; /* Dino Green */--dark-bg: #1a1a2e;--ui-bg: rgba(0, 0, 0, 0.85);--text-color: #ffffff;--font-main: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;}* {box-sizing: border-box;user-select: none;-webkit-user-select: none;touch-action: none; /* Prevent browser zooming/scrolling */}body, html {margin: 0;padding: 0;width: 100%;height: 100%;overflow: hidden;background-color: var(--dark-bg);font-family: var(--font-main);color: var(--text-color);}#game-container {position: relative;width: 100%;height: 100%;display: flex;justify-content: center;align-items: center;}canvas {display: block;box-shadow: 0 0 50px rgba(0,0,0,0.5);}/* UI OVERLAYS */.ui-layer {position: absolute;top: 0;left: 0;width: 100%;height: 100%;pointer-events: none; /* Let clicks pass through to canvas when playing */display: flex;flex-direction: column;justify-content: center;align-items: center;transition: opacity 0.3s ease;}.hidden {opacity: 0;pointer-events: none !important;}.visible {opacity: 1;pointer-events: auto !important;background: rgba(0,0,0,0.6);backdrop-filter: blur(5px);}/* HUD */#hud {justify-content: space-between;flex-direction: row;align-items: flex-start;padding: 20px;height: auto;z-index: 10;}.hud-panel {background: rgba(0, 0, 0, 0.5);padding: 10px 20px;border-radius: 15px;border: 2px solid var(--primary-color);box-shadow: 0 4px 10px rgba(0,0,0,0.3);display: flex;flex-direction: column;gap: 5px;min-width: 150px;}.hud-label {font-size: 0.8rem;color: #aaa;text-transform: uppercase;letter-spacing: 1px;}.hud-value {font-size: 1.5rem;font-weight: bold;color: var(--text-color);font-variant-numeric: tabular-nums;}#btc-value {color: var(--primary-color);font-size: 1.8rem;}.powerup-indicator {position: absolute;top: 80px;right: 20px;display: flex;gap: 10px;}.active-powerup {background: var(--primary-color);color: white;padding: 5px 10px;border-radius: 5px;font-size: 0.9rem;animation: pulse 1s infinite;}@keyframes pulse {0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(247, 147, 26, 0.7); }70% { transform: scale(1.1); box-shadow: 0 0 0 10px rgba(247, 147, 26, 0); }100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(247, 147, 26, 0); }}/* MENUS */.menu-content {background: var(--ui-bg);padding: 40px;border-radius: 20px;text-align: center;border: 4px solid var(--primary-color);box-shadow: 0 0 50px var(--primary-color);max-width: 500px;width: 90%;animation: float 3s ease-in-out infinite;}@keyframes float {0% { transform: translateY(0px); }50% { transform: translateY(-20px); }100% { transform: translateY(0px); }}h1 {font-size: 3rem;margin: 0 0 20px 0;color: var(--accent-color);text-shadow: 3px 3px 0px #000;line-height: 1.1;}h2 {color: var(--primary-color);margin-bottom: 30px;}p {font-size: 1.1rem;line-height: 1.6;color: #ddd;margin-bottom: 30px;}.btn {background: linear-gradient(45deg, var(--primary-color), #ff7f00);border: none;padding: 15px 40px;font-size: 1.5rem;color: white;font-weight: bold;border-radius: 50px;cursor: pointer;transition: transform 0.2s, box-shadow 0.2s;font-family: var(--font-main);text-transform: uppercase;box-shadow: 0 5px 15px rgba(247, 147, 26, 0.4);margin-top: 20px;}.btn:hover {transform: scale(1.05);box-shadow: 0 8px 20px rgba(247, 147, 26, 0.6);}.btn:active {transform: scale(0.95);}.controls-hint {margin-top: 30px;display: grid;grid-template-columns: 1fr 1fr;gap: 15px;text-align: left;font-size: 0.9rem;}.key {background: #333;padding: 5px 10px;border-radius: 5px;font-family: monospace;border-bottom: 2px solid #111;}/* Mobile Controls Overlay */#mobile-controls {position: absolute;bottom: 20px;width: 100%;height: 150px;pointer-events: none;display: none; /* Shown via JS on touch devices */z-index: 20;}.touch-zone {position: absolute;bottom: 0;width: 33.33%;height: 100%;pointer-events: auto;/* background: rgba(255,255,255,0.1); Debugging */}.touch-label {position: absolute;bottom: 20px;width: 100%;text-align: center;color: rgba(255,255,255,0.3);font-size: 2rem;pointer-events: none;}#zone-left { left: 0; }#zone-jump { left: 33.33%; }#zone-slide { right: 33.33%; }@media (max-width: 768px) {h1 { font-size: 2rem; }.hud-panel { min-width: 100px; padding: 5px 10px; }.hud-value { font-size: 1.2rem; }#btc-value { font-size: 1.4rem; }#mobile-controls { display: block; }}</style></head><body><div id="game-container"><canvas id="gameCanvas"></canvas><!-- HUD --><div id="hud" class="ui-layer"><div class="hud-panel"><span class="hud-label">Distance</span><span class="hud-value" id="score-dist">0 m</span></div><div class="powerup-indicator" id="powerup-container"><!-- Active powerups appear here --></div><div class="hud-panel" style="align-items: flex-end;"><span class="hud-label">BTC Balance</span><span class="hud-value" id="btc-value">0.00000000</span></div></div><!-- Start Screen --><div id="start-screen" class="ui-layer visible"><div class="menu-content"><h1>BITCOIN DINO</h1><p>Run endless, mine BTC, and survive the obstacles!</p><div class="controls-hint"><div><span class="key">←</span> <span class="key">→</span> Move Lanes</div><div><span class="key">↑</span> or <span class="key">Space</span> Jump</div><div><span class="key">↓</span> Slide</div><div><span class="key">P</span> Pause Game</div></div><button class="btn" id="start-btn">START MINING</button></div></div><!-- Game Over Screen --><div id="game-over-screen" class="ui-layer hidden"><div class="menu-content"><h1 style="color: #ff4444;">CRASHED!</h1><p>Your BTC mining session has ended.</p><div class="hud-panel" style="margin: 20px auto; width: auto;"><span class="hud-label">Final Distance</span><span class="hud-value" id="final-score-dist">0 m</span><span class="hud-label" style="margin-top:10px;">BTC Earned</span><span class="hud-value" id="final-btc" style="color: var(--primary-color);">0.00000000</span></div><button class="btn" id="restart-btn">CONTINUE MINING</button></div></div><!-- Pause Screen --><div id="pause-screen" class="ui-layer hidden"><div class="menu-content"><h1>PAUSED</h1><p>Take a breather, miner.</p><button class="btn" id="resume-btn">RESUME</button></div></div><!-- Mobile Controls --><div id="mobile-controls"><div id="zone-left" class="touch-zone"><div class="touch-label">←</div></div><div id="zone-jump" class="touch-zone"><div class="touch-label">↑</div></div><div id="zone-slide" class="touch-zone"><div class="touch-label">↓</div></div></div></div><script>/*** BITCOIN DINO - ENDLESS RUNNER* Production Grade Implementation*/// --- CONFIGURATION & CONSTANTS ---const CONFIG = {canvasWidth: 800,canvasHeight: 450,laneWidth: 100, // Base width, scaled latergravity: 0.6,jumpForce: -12,speedBase: 8,speedMax: 25,speedIncrement: 0.005, // Speed increase per framecolors: {dino: '#4CAF50', // GreendinoDark: '#388E3C',skin: '#81C784',headband: '#111',coin: '#f7931a',coinInner: '#FFB900',obstacle: '#555',obstacleTop: '#777',skyTop: '#2b32b2',skyBottom: '#1488cc',ground: '#222',grid: '#333'}};// --- UTILITIES ---const Utils = {randomRange: (min, max) => Math.random() * (max - min) + min,checkAABB: (rect1, rect2) => {return (rect1.x < rect2.x + rect2.w &&rect1.x + rect1.w > rect2.x &&rect1.y < rect2.y + rect2.h &&rect1.y + rect1.h > rect2.y);},formatBTC: (amount) => {// Ensure exactly 8 decimal placesreturn amount.toFixed(8);}};// --- INPUT HANDLING ---class InputHandler {constructor(game) {this.game = game;this.keys = {left: false,right: false,up: false,down: false};// Keyboardwindow.addEventListener('keydown', (e) => this.handleKey(e, true));window.addEventListener('keyup', (e) => this.handleKey(e, false));// Mobile Touchconst zoneLeft = document.getElementById('zone-left');const zoneJump = document.getElementById('zone-jump');const zoneSlide = document.getElementById('zone-slide');const addTouch = (element, action) => {element.addEventListener('touchstart', (e) => { e.preventDefault(); this.triggerAction(action); });element.addEventListener('mousedown', (e) => { e.preventDefault(); this.triggerAction(action); });};addTouch(zoneLeft, 'left');addTouch(zoneJump, 'jump');addTouch(zoneSlide, 'slide');// Pause Togglewindow.addEventListener('keydown', (e) => {if (e.key.toLowerCase() === 'p') this.game.togglePause();});}handleKey(e, isDown) {const key = e.key.toLowerCase();if (key === 'arrowleft' || key === 'a') this.keys.left = isDown;if (key === 'arrowright' || key === 'd') this.keys.right = isDown;if (key === 'arrowup' || key === 'w' || key === ' ') this.keys.up = isDown;if (key === 'arrowdown' || key === 's') this.keys.down = isDown;if (isDown && this.keys.up) this.game.player.jump();if (isDown && this.keys.down) this.game.player.slide(true);if (!isDown && this.keys.down) this.game.player.slide(false);}triggerAction(action) {if (this.game.gameState !== 'PLAYING') return;if (action === 'left') this.game.player.moveLane(-1);if (action === 'right') this.game.player.moveLane(1);if (action === 'jump') this.game.player.jump();if (action === 'slide') this.game.player.slide(true);}}// --- PARTICLE SYSTEM ---class Particle {constructor(x, y, color, type = 'coin') {this.x = x;this.y = y;this.color = color;this.type = type;this.size = Utils.randomRange(3, 6);this.speedX = Utils.randomRange(-3, 3);this.speedY = Utils.randomRange(-3, 3);this.life = 1.0; // Opacitythis.decay = Utils.randomRange(0.02, 0.05);}update() {this.x += this.speedX;this.y += this.speedY;this.life -= this.decay;this.size *= 0.95;}draw(ctx) {ctx.save();ctx.globalAlpha = this.life;ctx.fillStyle = this.color;ctx.beginPath();ctx.arc(this.x, this.y, this.size, 0, Math.PI * 2);ctx.fill();ctx.restore();}}// --- GAME ENTITIES ---class Coin {constructor(lane, x) {this.lane = lane; // 0, 1, 2this.x = 0; // Calculated in updatethis.y = 0;this.w = 30;this.h = 30;this.active = true;this.btcValue = Utils.randomRange(0.00000001, 0.00000005);this.bonusChance = 0.1;if (Math.random() < this.bonusChance) this.btcValue *= 5;// Animation varsthis.rotation = 0;this.baseY = 0; // Set during spawn}update(speed, laneCenterX, laneY) {this.x = laneCenterX(this.lane) - this.w / 2;this.y = laneY + 20;this.rotation += 0.1;this.x -= speed;}draw(ctx) {if (!this.active) return;ctx.save();ctx.translate(this.x + this.w/2, this.y + this.h/2);// Spin effectconst scaleX = Math.abs(Math.cos(this.rotation));ctx.scale(scaleX, 1);// Glowctx.shadowBlur = 15;ctx.shadowColor = CONFIG.colors.coin;// Coin Bodyctx.fillStyle = CONFIG.colors.coin;ctx.beginPath();ctx.arc(0, 0, this.w/2, 0, Math.PI * 2);ctx.fill();ctx.lineWidth = 2;ctx.strokeStyle = '#b35900';ctx.stroke();// BTC Symbolctx.fillStyle = '#000';ctx.font = 'bold 16px Arial';ctx.textAlign = 'center';ctx.textBaseline = 'middle';ctx.fillText('₿', 0, 1);ctx.restore();}}class Obstacle {constructor(lane, x, type) {this.lane = lane;this.x = x;this.y = 0;this.w = 60;this.h = 60;this.type = type; // 'barrier', 'low_barrier', 'high_hazard'this.active = true;// Setup dimensions based on typeif (type === 'low_barrier') {this.h = 30;this.y = 0; // On groundthis.color = '#e74c3c';} else if (type === 'high_hazard') {this.w = 50;this.h = 50;this.y = 110; // In air (requires slide)this.color = '#8e44ad';} else {// Standard barrierthis.w = 60;this.h = 60;this.y = 0;this.color = '#34495e';}}update(speed) {this.x -= speed;}draw(ctx) {if (!this.active) return;// Draw Shadowctx.fillStyle = 'rgba(0,0,0,0.3)';ctx.fillRect(this.x + 5, this.y + 5, this.w, this.h);// Draw Obstaclectx.fillStyle = this.color;ctx.fillRect(this.x, this.y, this.w, this.h);// Detailctx.strokeStyle = '#2c3e50';ctx.lineWidth = 3;ctx.strokeRect(this.x + 5, this.y + 5, this.w - 10, this.h - 10);// Warning stripesctx.fillStyle = 'rgba(255,255,255,0.2)';if (this.type === 'barrier') {ctx.beginPath();ctx.moveTo(this.x, this.y);ctx.lineTo(this.x + 20, this.y);ctx.lineTo(this.x, this.y + 20);ctx.fill();}}}class PowerUp {constructor(lane, x, type) {this.lane = lane;this.x = x;this.y = 0;this.w = 40;this.h = 40;this.type = type; // 'magnet', 'shield', 'multiplier'this.active = true;this.oscillation = 0;}update(speed, laneCenterX, laneY) {this.x = laneCenterX(this.lane) - this.w / 2;this.y = laneY - 40; // Floating abovethis.oscillation += 0.1;this.y += Math.sin(this.oscillation) * 10;this.x -= speed;}draw(ctx) {if (!this.active) return;const cx = this.x + this.w/2;const cy = this.y + this.h/2;// Glowctx.shadowBlur = 20;if (this.type === 'shield') {ctx.shadowColor = '#00bcd4';ctx.fillStyle = '#00bcd4';ctx.beginPath();ctx.arc(cx, cy, 15, 0, Math.PI*2);ctx.fill();ctx.fillStyle = '#fff';ctx.font = '12px Arial';ctx.textAlign = 'center';ctx.textBaseline = 'middle';ctx.fillText('S', cx, cy);} else if (this.type === 'magnet') {ctx.shadowColor = '#ffeb3b';ctx.fillStyle = '#ffeb3b';ctx.fillRect(cx - 15, cy - 10, 30, 20);ctx.fillStyle = '#333';ctx.font = '12px Arial';ctx.textAlign = 'center';ctx.textBaseline = 'middle';ctx.fillText('M', cx, cy);} else if (this.type === 'multiplier') {ctx.shadowColor = '#e91e63';ctx.fillStyle = '#e91e63';ctx.beginPath();ctx.moveTo(cx, cy - 15);ctx.lineTo(cx + 15, cy + 15);ctx.lineTo(cx - 15, cy + 15);ctx.fill();ctx.fillStyle = '#fff';ctx.font = 'bold 16px Arial';ctx.textAlign = 'center';ctx.textBaseline = 'middle';ctx.fillText('2x', cx, cy);}ctx.shadowBlur = 0;}}class Dino {constructor(game) {this.game = game;this.lane = 1; // Start middlethis.x = 0;this.y = 0;this.vy = 0;this.width = 50;this.height = 60;this.isJumping = false;this.isSliding = false;this.slideTimer = 0;this.color = CONFIG.colors.dino;this.animTimer = 0;}update() {// Calculate X position based on laneconst laneWidth = this.game.laneWidth;const centerX = (this.game.width / 2) - (laneWidth * 1.5); // Offset to start of lanesthis.x = centerX + (this.lane * laneWidth) + (laneWidth - this.width) / 2;// Physicsif (this.isJumping) {this.y += this.vy;this.vy += CONFIG.gravity;// Ground collisionif (this.y >= this.game.groundY - this.height) {this.y = this.game.groundY - this.height;this.isJumping = false;this.vy = 0;this.game.spawnParticles(this.x + this.width/2, this.y + this.height, '#fff', 5);}} else {this.y = this.game.groundY - this.height;}// Slide Logicif (this.isSliding) {this.height = 35;this.width = 60;this.slideTimer--;if (this.slideTimer <= 0) {this.slide(false);}} else {this.height = 60;this.width = 50;}// Animationthis.animTimer += 0.2;}moveLane(dir) {const newLane = this.lane + dir;if (newLane >= 0 && newLane <= 2) {this.lane = newLane;this.game.spawnParticles(this.x + this.width/2, this.y + this.height, '#fff', 3);}}jump() {if (!this.isJumping) {this.vy = CONFIG.jumpForce;this.isJumping = true;}}slide(active) {this.isSliding = active;this.slideTimer = 60; // Frames}draw(ctx) {const cx = this.x + this.width / 2;const cy = this.y + this.height / 2;// Bodyctx.fillStyle = this.color;ctx.beginPath();// Rounded rect for bodyctx.roundRect(this.x, this.y, this.width, this.height, 10);ctx.fill();// Headbandctx.fillStyle = CONFIG.colors.headband;ctx.fillRect(this.x, this.y + 5, this.width, 10);// Bitcoin Symbol on Headbandctx.fillStyle = CONFIG.colors.coin;ctx.font = 'bold 12px Arial';ctx.textAlign = 'center';ctx.textBaseline = 'middle';ctx.fillText('₿', cx, this.y + 10);// Eyesctx.fillStyle = '#fff';const eyeOffset = this.isSliding ? 10 : 12;const eyeY = this.isSliding ? this.y + 15 : this.y + 18;// Left Eyectx.beginPath();ctx.arc(cx - eyeOffset, eyeY, 8, 0, Math.PI * 2);ctx.fill();// Right Eyectx.beginPath();ctx.arc(cx + eyeOffset, eyeY, 8, 0, Math.PI * 2);ctx.fill();// Pupils (Look direction based on lane if needed, but static for now)ctx.fillStyle = '#000';ctx.beginPath();ctx.arc(cx - eyeOffset, eyeY, 3, 0, Math.PI * 2);ctx.arc(cx + eyeOffset, eyeY, 3, 0, Math.PI * 2);ctx.fill();// Legs (Simple animation)if (!this.isJumping) {ctx.fillStyle = CONFIG.colors.dinoDark;const legOffset = Math.sin(this.animTimer) * 10;// Left Legctx.fillRect(this.x + 10 + legOffset, this.y + this.height, 10, 10);// Right Legctx.fillRect(this.x + 30 - legOffset, this.y + this.height, 10, 10);}}}// --- BACKGROUND & ENVIRONMENT ---class Background {constructor(width, height) {this.width = width;this.height = height;this.groundY = height - 50;this.offsetX = 0;this.speed = 0;}update(speed) {this.offsetX -= speed;if (this.offsetX <= -this.width) this.offsetX = 0;}draw(ctx) {// Sky Gradientconst gradient = ctx.createLinearGradient(0, 0, 0, this.height);gradient.addColorStop(0, CONFIG.colors.skyTop);gradient.addColorStop(1, CONFIG.colors.skyBottom);ctx.fillStyle = gradient;ctx.fillRect(0, 0, this.width, this.height);// Distant Mountains (Parallax)ctx.fillStyle = 'rgba(0,0,0,0.2)';ctx.beginPath();for(let i=0; i<this.width/100 + 2; i++) {const h = 100 + Math.random() * 50; // Static noise for variety if we used time, but let's keep it simple shapesconst x = (i * 100) + this.offsetX * 0.2;ctx.moveTo(x, this.height - 50);ctx.lineTo(x + 50, this.height - 50 - h);ctx.lineTo(x + 100, this.height - 50);}ctx.fill();// Grid Floor (Synthwave style)const groundY = this.groundY;ctx.fillStyle = CONFIG.colors.ground;ctx.fillRect(0, groundY, this.width, 50);// Moving Grid Linesctx.strokeStyle = CONFIG.colors.grid;ctx.lineWidth = 2;ctx.beginPath();// Horizontal linesfor (let i = 0; i < 10; i++) {const y = groundY + (i * 10) + (this.offsetX * 0.5 % 10);if (y < groundY) continue;ctx.moveTo(0, y);ctx.lineTo(this.width, y);}// Vertical lines (Perspective effect)const centerX = this.width / 2;for (let i = -10; i < 10; i++) {const x = centerX + (i * 100) + (this.offsetX % 100);ctx.moveTo(x, groundY);ctx.lineTo(centerX + (i * 300), this.height);}ctx.stroke();// Ground Top Borderctx.fillStyle = '#444';ctx.fillRect(0, groundY, this.width, 5);}}// --- MAIN GAME ENGINE ---class Game {constructor() {this.canvas = document.getElementById('gameCanvas');this.ctx = this.canvas.getContext('2d');this.width = window.innerWidth;this.height = window.innerHeight;// Adjust canvas for high DPIconst dpr = window.devicePixelRatio || 1;this.canvas.width = this.width * dpr;this.canvas.height = this.height * dpr;this.ctx.scale(dpr, dpr);this.width = this.width;this.height = this.height;this.laneWidth = this.width / 3;this.groundY = this.height - 80;this.state = 'START'; // START, PLAYING, PAUSED, GAMEOVERthis.score = 0;this.btcBalance = 0.00000000;this.gameSpeed = CONFIG.speedBase;this.distance = 0;this.entities = {coins: [],obstacles: [],powerups: [],particles: []};this.dino = new Dino(this);this.background = new Background(this.width, this.height);this.input = new InputHandler(this);this.lastSpawnTime = 0;this.spawnInterval = 1500; // msthis.shieldActive = false;this.multiplierActive = false;// UI Elementsthis.ui = {start: document.getElementById('start-screen'),gameOver: document.getElementById('game-over-screen'),pause: document.getElementById('pause-screen'),hud: document.getElementById('hud'),dist: document.getElementById('score-dist'),btc: document.getElementById('btc-value'),finalDist: document.getElementById('final-score-dist'),finalBtc: document.getElementById('final-btc'),powerupContainer: document.getElementById('powerup-container')};this.bindUI();this.loop = this.loop.bind(this);requestAnimationFrame(this.loop);}bindUI() {document.getElementById('start-btn').addEventListener('click', () => this.start());document.getElementById('restart-btn').addEventListener('click', () => this.start());document.getElementById('resume-btn').addEventListener('click', () => this.togglePause());}start() {this.state = 'PLAYING';this.score = 0;this.distance = 0;this.btcBalance = 0.00000000;this.gameSpeed = CONFIG.speedBase;this.entities = { coins: [], obstacles: [], powerups: [], particles: [] };this.dino = new Dino(this);this.shieldActive = false;this.multiplierActive = false;this.ui.start.classList.add('hidden');this.ui.start.classList.remove('visible');this.ui.gameOver.classList.add('hidden');this.ui.gameOver.classList.remove('visible');this.ui.pause.classList.add('hidden');this.ui.pause.classList.remove('visible');this.ui.hud.classList.remove('hidden');this.updatePowerupUI();}togglePause() {if (this.state === 'PLAYING') {this.state = 'PAUSED';this.ui.pause.classList.remove('hidden');this.ui.pause.classList.add('visible');} else if (this.state === 'PAUSED') {this.state = 'PLAYING';this.ui.pause.classList.add('hidden');this.ui.pause.classList.remove('visible');}}gameOver() {this.state = 'GAMEOVER';this.ui.hud.classList.add('hidden');this.ui.gameOver.classList.remove('hidden');this.ui.gameOver.classList.add('visible');this.ui.finalDist.innerText = Math.floor(this.distance) + " m";this.ui.finalBtc.innerText = Utils.formatBTC(this.btcBalance);}spawnEntities() {const now = Date.now();if (now - this.lastSpawnTime > this.spawnInterval) {this.lastSpawnTime = now;// Randomly choose what to spawnconst rand = Math.random();// Determine laneconst lane = Math.floor(Math.random() * 3);const spawnX = this.width + 100;if (rand < 0.6) {// Spawn Obstacleconst type = Math.random() < 0.33 ? 'low_barrier' : (Math.random() < 0.5 ? 'high_hazard' : 'barrier');this.entities.obstacles.push(new Obstacle(lane, spawnX, type));// Sometimes spawn coins around obstaclesif (Math.random() > 0.5) {const coinLane = (lane + 1) % 3;this.entities.coins.push(new Coin(coinLane, spawnX + 100));}} else if (rand < 0.9) {// Spawn Coinsconst coinCount = Math.floor(Utils.randomRange(3, 8));for (let i = 0; i < coinCount; i++) {this.entities.coins.push(new Coin(lane, spawnX + (i * 60)));}} else {// Spawn Powerupconst pType = Math.random() < 0.4 ? 'shield' : (Math.random() < 0.7 ? 'magnet' : 'multiplier');this.entities.powerups.push(new PowerUp(lane, spawnX, pType));}// Decrease spawn interval slightly as speed increasesthis.spawnInterval = Math.max(600, 1500 - (this.gameSpeed * 20));}}spawnParticles(x, y, color, count) {for(let i=0; i<count; i++) {this.entities.particles.push(new Particle(x, y, color));}}checkCollisions() {const dinoRect = { x: this.dino.x, y: this.dino.y, w: this.dino.width, h: this.dino.height };// Coinsthis.entities.coins.forEach(coin => {if (coin.active && Utils.checkAABB(dinoRect, {x: coin.x, y: coin.y, w: coin.w, h: coin.h})) {coin.active = false;const value = this.multiplierActive ? coin.btcValue * 2 : coin.btcValue;this.btcBalance += value;this.spawnParticles(coin.x, coin.y, CONFIG.colors.coin, 5);}});// Obstaclesthis.entities.obstacles.forEach(obs => {if (obs.active && Utils.checkAABB(dinoRect, {x: obs.x, y: obs.y, w: obs.w, h: obs.h})) {if (this.shieldActive) {this.shieldActive = false;obs.active = false;this.spawnParticles(obs.x, obs.y, '#00bcd4', 10);this.spawnParticles(this.dino.x, this.dino.y, '#00bcd4', 10);} else {this.spawnParticles(this.dino.x, this.dino.y, CONFIG.colors.dino, 20);this.gameOver();}}});// Powerupsthis.entities.powerups.forEach(p => {if (p.active && Utils.checkAABB(dinoRect, {x: p.x, y: p.y, w: p.w, h: p.h})) {p.active = false;this.activatePowerUp(p.type);this.spawnParticles(p.x, p.y, '#fff', 10);}});}activatePowerUp(type) {if (type === 'shield') {this.shieldActive = true;this.updatePowerupUI();setTimeout(() => {this.shieldActive = false;this.updatePowerupUI();}, 5000);} else if (type === 'multiplier') {this.multiplierActive = true;this.updatePowerupUI();setTimeout(() => {this.multiplierActive = false;this.updatePowerupUI();}, 5000);} else if (type === 'magnet') {// Simple implementation: attract coins for 5 secondsconst magnetTime = 5000;const magnetInterval = setInterval(() => {if (this.state !== 'PLAYING') {clearInterval(magnetInterval);return;}this.entities.coins.forEach(coin => {if (coin.active && coin.lane === this.dino.lane) {const dist = Math.abs((this.dino.x + this.dino.width/2) - (coin.x + coin.w/2));if (dist < 200) {coin.x += (this.dino.x - coin.x) * 0.2; // Move towards dino}}});}, 50);setTimeout(() => clearInterval(magnetInterval), magnetTime);}}updatePowerupUI() {this.ui.powerupContainer.innerHTML = '';if (this.shieldActive) {const el = document.createElement('div');el.className = 'active-powerup';el.innerText = 'SHIELD';this.ui.powerupContainer.appendChild(el);}if (this.multiplierActive) {const el = document.createElement('div');el.className = 'active-powerup';el.innerText = '2X BTC';this.ui.powerupContainer.appendChild(el);}}update() {if (this.state !== 'PLAYING') return;// Difficulty scalingthis.gameSpeed = Math.min(CONFIG.speedMax, this.gameSpeed + CONFIG.speedIncrement);this.distance += this.gameSpeed * 0.05;this.score = Math.floor(this.distance);this.background.update(this.gameSpeed);this.dino.update();this.spawnEntities();// Update Entitiesthis.entities.coins.forEach(c => c.update(this.gameSpeed, (lane) => (this.width/2) - (this.laneWidth*1.5) + (lane * this.laneWidth) + (this.laneWidth/2), this.groundY));this.entities.obstacles.forEach(o => o.update(this.gameSpeed));this.entities.powerups.forEach(p => p.update(this.gameSpeed, (lane) => (this.width/2) - (this.laneWidth*1.5) + (lane * this.laneWidth) + (this.laneWidth/2), this.groundY));this.entities.particles.forEach(p => p.update());// Cleanup off-screen entitiesthis.entities.coins = this.entities.coins.filter(c => c.x + c.w > -50);this.entities.obstacles = this.entities.obstacles.filter(o => o.x + o.w > -50);this.entities.powerups = this.entities.powerups.filter(p => p.x + p.w > -50);this.entities.particles = this.entities.particles.filter(p => p.life > 0);this.checkCollisions();// Update HUDthis.ui.dist.innerText = Math.floor(this.distance) + " m";this.ui.btc.innerText = Utils.formatBTC(this.btcBalance);}draw() {this.ctx.clearRect(0, 0, this.width, this.height);this.background.draw(this.ctx);// Draw Lanes (Subtle)this.ctx.strokeStyle = 'rgba(255,255,255,0.1)';this.ctx.lineWidth = 2;this.ctx.beginPath();for(let i=1; i<3; i++) {const x = (this.width/2) - (this.laneWidth * 1.5) + (i * this.laneWidth);this.ctx.moveTo(x, 0);this.ctx.lineTo(x, this.height);}this.ctx.stroke();this.entities.powerups.forEach(p => p.draw(this.ctx));this.entities.obstacles.forEach(o => o.draw(this.ctx));this.entities.coins.forEach(c => c.draw(this.ctx));this.dino.draw(this.ctx);this.entities.particles.forEach(p => p.draw(this.ctx));}loop() {this.update();this.draw();requestAnimationFrame(this.loop);}}// Initialize Gamewindow.onload = () => {const game = new Game();};</script></body></html>
index.html+1048-1087