Spaces:
Running
Running
Upload folder using huggingface_hub
Browse files1 unmodified line234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162633 unmodified lines676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221 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;3 unmodified linesflex-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);// Draw1 unmodified line2345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152533 unmodified lines57585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971 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 Dash: Dino Runner</title><link href="https://fonts.googleapis.com/css2?family=Fredoka+One&family=Press+Start+2P&display=swap" rel="stylesheet"><style>:root {--primary: #4CAF50;--accent: #FFD700;--bg-dark: #1a1a2e;--ui-bg: rgba(0, 0, 0, 0.85);--text-color: #ffffff;}* {box-sizing: border-box;user-select: none;-webkit-user-select: none;touch-action: none;}body, html {margin: 0;padding: 0;width: 100%;height: 100%;overflow: hidden;background-color: var(--bg-dark);font-family: 'Fredoka One', cursive;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-screen {position: absolute;top: 0;left: 0;3 unmodified linesflex-direction: column;justify-content: center;align-items: center;background: rgba(0, 0, 0, 0.6);backdrop-filter: blur(5px);z-index: 10;transition: opacity 0.3s ease;}.hidden {opacity: 0;pointer-events: none;z-index: -1;}h1 {font-size: 3rem;color: var(--primary);text-shadow: 4px 4px 0px #2E7D32;margin-bottom: 0.5rem;text-align: center;line-height: 1.2;}.btc-display {font-family: 'Press Start 2P', monospace;font-size: 1.5rem;color: var(--accent);margin: 1rem 0;text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);}.instructions {font-size: 1rem;color: #ccc;margin-bottom: 2rem;text-align: center;line-height: 1.6;max-width: 600px;padding: 0 20px;}.key-badge {display: inline-block;background: #444;padding: 4px 8px;border-radius: 4px;border-bottom: 2px solid #222;color: white;font-family: sans-serif;font-size: 0.8rem;margin: 0 2px;}button {background: linear-gradient(180deg, #4CAF50 0%, #2E7D32 100%);border: none;border-radius: 50px;padding: 15px 40px;font-size: 1.5rem;color: white;font-family: 'Fredoka One', cursive;cursor: pointer;box-shadow: 0 6px 0 #1B5E20, 0 10px 10px rgba(0,0,0,0.3);transition: transform 0.1s, box-shadow 0.1s;text-transform: uppercase;}button:active {transform: translateY(4px);box-shadow: 0 2px 0 #1B5E20, 0 4px 4px rgba(0,0,0,0.3);}button:hover {filter: brightness(1.1);}/* HUD */#hud {position: absolute;top: 0;left: 0;width: 100%;padding: 15px 20px;display: flex;justify-content: space-between;align-items: flex-start;pointer-events: none;z-index: 5;}.hud-item {background: rgba(0, 0, 0, 0.5);padding: 8px 15px;border-radius: 12px;border: 1px solid rgba(255, 255, 255, 0.1);display: flex;flex-direction: column;align-items: center;}.hud-label {font-size: 0.7rem;text-transform: uppercase;color: #aaa;letter-spacing: 1px;}.hud-value {font-family: 'Press Start 2P', monospace;font-size: 1rem;color: white;}#pause-btn {pointer-events: auto;background: rgba(255, 255, 255, 0.2);border-radius: 50%;width: 40px;height: 40px;display: flex;justify-content: center;align-items: center;font-size: 1.2rem;padding: 0;box-shadow: none;border: 2px solid white;}#pause-btn:active {transform: scale(0.95);}/* Built with anycoder */.footer-link {position: absolute;bottom: 10px;right: 10px;font-size: 0.7rem;color: rgba(255, 255, 255, 0.4);text-decoration: none;z-index: 20;}.footer-link:hover {color: rgba(255, 255, 255, 0.8);}/* Power-up Indicators */.powerup-indicator {position: absolute;top: 80px;left: 50%;transform: translateX(-50%);display: flex;gap: 10px;}.pu-icon {width: 30px;height: 30px;background: rgba(0,0,0,0.6);border-radius: 50%;display: flex;justify-content: center;align-items: center;font-size: 14px;border: 2px solid rgba(255,255,255,0.3);opacity: 0;transition: opacity 0.3s;}.pu-icon.active {opacity: 1;animation: pulse 1s infinite;}@keyframes pulse {0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 215, 0, 0.7); }70% { transform: scale(1.1); box-shadow: 0 0 0 10px rgba(255, 215, 0, 0); }100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 215, 0, 0); }}</style></head><body><div id="game-container"><canvas id="gameCanvas"></canvas><!-- HUD --><div id="hud" class="hidden"><div class="hud-item"><span class="hud-label">Distance</span><span class="hud-value" id="dist-val">0m</span></div><div id="pause-btn">❚❚</div><div class="hud-item"><span class="hud-label">BTC Balance</span><span class="hud-value" id="btc-val">0.00000000</span></div></div><div id="powerup-container" class="powerup-indicator hidden"><div id="pu-shield" class="pu-icon" title="Shield">🛡️</div><div id="pu-magnet" class="pu-icon" title="Magnet">🧲</div><div id="pu-mul" class="pu-icon" title="Multiplier x2">2x</div></div><!-- Start Screen --><div id="start-screen" class="ui-screen"><h1>BITCOIN DASH</h1><div class="btc-display" id="start-btc-display">0.00000000</div><div class="instructions"><p>RUN, DUCK, & JUMP to collect Bitcoin.</p><p>Use <span class="key-badge">←</span> <span class="key-badge">→</span> to Switch Lanes</p><p>Press <span class="key-badge">↑</span> or <span class="key-badge">SPACE</span> to Jump</p><p>Press <span class="key-badge">↓</span> to Slide</p><p style="margin-top:10px; color: var(--primary)">Avoid barriers and gaps!</p></div><button id="start-btn">START RUN</button></div><!-- Game Over Screen --><div id="game-over-screen" class="ui-screen hidden"><h1 style="color: #ff5252; text-shadow: 4px 4px 0 #b71c1c;">CRASHED!</h1><div class="btc-display" id="final-btc-display">0.00000000</div><p style="margin: 10px 0 20px 0; font-size: 1.2rem;">Distance: <span id="final-dist">0</span>m</p><button id="restart-btn">TRY AGAIN</button></div><a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank" class="footer-link">Built with anycoder</a></div><script>/*** BITCOIN DASH - AAA Game Engine* Pure HTML5 Canvas Implementation*/// --- CONFIGURATION & CONSTANTS ---const CONSTANTS = {LANE_COUNT: 3,LANE_WIDTH_BASE: 100, // Will be scaled by screen widthRUN_SPEED_BASE: 0.5, // World units per frameGRAVITY: 0.015,JUMP_FORCE: -0.35,SLIDE_DURATION: 40,COIN_VALUE: 0.00000001,BONUS_COIN_VALUE: 0.00000005,COLORS: {PLAYER: '#4CAF50',PLAYER_OUTLINE: '#2E7D32',COIN: '#FFD700',COIN_OUTLINE: '#F57F17',OBSTACLE: '#263238',OBSTACLE_ACCENT: '#546E7A',GROUND: '#ECEFF1',SKY: '#87CEEB'}};// --- UTILS ---const Utils = {random: (min, max) => Math.random() * (max - min) + min,randomInt: (min, max) => Math.floor(Math.random() * (max - min + 1) + min),lerp: (start, end, t) => start * (1 - t) + end * t,clamp: (val, min, max) => Math.min(Math.max(val, min), max),formatBTC: (num) => num.toFixed(8),// Draw Bitcoin SymboldrawBitcoinSymbol: (ctx, x, y, size, rotation) => {ctx.save();ctx.translate(x, y);ctx.rotate(rotation);ctx.font = `${size}px Arial`;ctx.textAlign = 'center';ctx.textBaseline = 'middle';ctx.fillStyle = CONSTANTS.COLORS.COIN;ctx.shadowColor = 'rgba(0,0,0,0.3)';ctx.shadowBlur = 5;ctx.fillText('₿', 0, 0);ctx.restore();}};// --- INPUT HANDLER ---class InputHandler {constructor() {this.keys = {left: false,right: false,up: false,down: false};this.touchStartX = 0;this.touchStartY = 0;window.addEventListener('keydown', (e) => this.handleKey(e, true));window.addEventListener('keyup', (e) => this.handleKey(e, false));// Touch handlingwindow.addEventListener('touchstart', (e) => {this.touchStartX = e.touches[0].clientX;this.touchStartY = e.touches[0].clientY;}, {passive: false});window.addEventListener('touchend', (e) => {if (!game.isPlaying) return;const touchEndX = e.changedTouches[0].clientX;const touchEndY = e.changedTouches[0].clientY;this.handleSwipe(touchEndX, touchEndY);}, {passive: false});}handleKey(e, isDown) {switch(e.code) {case 'ArrowLeft':case 'KeyA': this.keys.left = isDown; break;case 'ArrowRight':case 'KeyD': this.keys.right = isDown; break;case 'ArrowUp':case 'Space':case 'KeyW':if (isDown && !this.keys.up) game.player.jump();this.keys.up = isDown;break;case 'ArrowDown':case 'KeyS':if (isDown && !this.keys.down) game.player.slide();this.keys.down = isDown;break;}}handleSwipe(endX, endY) {const dx = endX - this.touchStartX;const dy = endY - this.touchStartY;const absDx = Math.abs(dx);const absDy = Math.abs(dy);if (absDx > absDy) {// Horizontalif (absDx > 30) {if (dx > 0) game.player.switchLane(1);else game.player.switchLane(-1);}} else {// Verticalif (absDy > 30) {if (dy > 0) game.player.slide();else game.player.jump();}}}}// --- PARTICLE SYSTEM ---class Particle {constructor(x, y, color, speed) {this.x = x;this.y = y;this.color = color;this.size = Utils.random(2, 5);this.speedX = Utils.random(-speed, speed);this.speedY = Utils.random(-speed, speed);this.life = 1.0;this.decay = Utils.random(0.02, 0.05);}update() {this.x += this.speedX;this.y += this.speedY;this.life -= this.decay;this.size *= 0.95;}draw(ctx) {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.globalAlpha = 1.0;}}// --- ENTITIES ---class Player {constructor(game) {this.game = game;this.width = 40;this.height = 60;this.lane = 1; // 0: Left, 1: Center, 2: Rightthis.targetX = 0;this.x = 0;this.y = 0;this.vy = 0;this.isJumping = false;this.isSliding = false;this.slideTimer = 0;this.color = CONSTANTS.COLORS.PLAYER;// Animation propertiesthis.runCycle = 0;}update() {// Lane Switching Logicconst laneWidth = this.game.laneWidth;const targetLX = (this.lane - 1) * laneWidth;this.targetX = Utils.lerp(this.x, targetLX, 0.2);this.x = this.targetX;// Jump Physicsif (this.isJumping) {this.y += this.vy;this.vy += CONSTANTS.GRAVITY;if (this.y >= 0) {this.y = 0;this.isJumping = false;this.vy = 0;}}// Slide Logicif (this.isSliding) {this.slideTimer--;if (this.slideTimer <= 0) {this.isSliding = false;}}// Run Animationthis.runCycle += 0.15 + (this.game.speed / 1000);}jump() {if (!this.isJumping && !this.isSliding) {this.isJumping = true;this.vy = CONSTANTS.JUMP_FORCE;this.game.spawnParticles(this.x + this.width/2, this.y + this.height, 5, '#fff');}}slide() {if (!this.isJumping && !this.isSliding) {this.isSliding = true;this.slideTimer = CONSTANTS.SLIDE_DURATION;this.height = 30; // Shrink height}}switchLane(dir) {const newLane = this.lane + dir;if (newLane >= 0 && newLane < CONSTANTS.LANE_COUNT) {this.lane = newLane;}}draw(ctx) {ctx.save();// Position calculationconst drawX = this.x + this.width / 2;const drawY = this.game.groundY - this.height + this.y;// Squash and stretch based on statelet scaleX = 1;let scaleY = 1;if (this.isJumping) {scaleX = 0.8;scaleY = 1.2;} else if (this.isSliding) {scaleX = 0.8;scaleY = 0.5;} else {// Run bobbingconst bob = Math.sin(this.runCycle) * 2;ctx.translate(0, bob);}ctx.translate(drawX, drawY);ctx.scale(scaleX, scaleY);// Draw Dino (Stylized)// Bodyctx.fillStyle = this.color;ctx.strokeStyle = CONSTANTS.COLORS.PLAYER_OUTLINE;ctx.lineWidth = 3;// Round bodyctx.beginPath();ctx.ellipse(0, 10, 20, 25, 0, 0, Math.PI * 2);ctx.fill();ctx.stroke();// Headctx.beginPath();ctx.arc(15, -10, 18, 0, Math.PI * 2);ctx.fill();ctx.stroke();// Eyesctx.fillStyle = 'white';ctx.beginPath();ctx.arc(20, -15, 6, 0, Math.PI * 2);ctx.fill();ctx.stroke();ctx.fillStyle = 'black';ctx.beginPath();ctx.arc(22, -15, 2.5, 0, Math.PI * 2);ctx.fill();// Headband with Bitcoinctx.fillStyle = '#FFD700'; // Goldctx.beginPath();ctx.ellipse(15, -10, 18, 8, 0, 0, Math.PI * 2);ctx.fill();ctx.stroke();// Bitcoin Symbol on Headbandctx.save();ctx.rotate(Math.PI / 4);ctx.fillStyle = '#000';ctx.font = 'bold 14px Arial';ctx.textAlign = 'center';ctx.textBaseline = 'middle';ctx.fillText('₿', 0, 0);ctx.restore();// Legs (Simple animation)if (!this.isSliding) {ctx.strokeStyle = this.color;ctx.lineWidth = 4;ctx.lineCap = 'round';const legOffset = Math.sin(this.runCycle) * 10;// Back Legctx.beginPath();ctx.moveTo(-5, 25);ctx.lineTo(-5 - legOffset, 40);ctx.stroke();// Front Legctx.beginPath();ctx.moveTo(5, 25);ctx.lineTo(5 + (legOffset * -1), 40);ctx.stroke();}// Tailctx.beginPath();ctx.moveTo(-20, 10);ctx.quadraticCurveTo(-35, 5, -40, 20);ctx.stroke();ctx.restore();// Shield Effectif (this.game.playerPowerups.shield) {ctx.save();ctx.strokeStyle = 'rgba(100, 200, 255, 0.6)';ctx.lineWidth = 3;ctx.setLineDash([5, 5]);ctx.beginPath();ctx.arc(drawX, drawY + this.height/2, 45, 0, Math.PI * 2);ctx.stroke();ctx.restore();}}getBounds() {// Return collision boxlet h = this.height;let y = this.y;// If sliding, hitbox is lower (ducking under bars)if (this.isSliding) {h = 30;y = this.y + 30; // Shift up}// If jumping, hitbox is smaller (don't hit low bars)if (this.isJumping) {h = 30;}return {x: this.x + 10,y: y + 10,width: this.width - 20,height: h - 20};}}class Obstacle {constructor(game, lane, type) {this.game = game;this.lane = lane;this.x = 0;this.y = 0;this.type = type; // 'barrier', 'low', 'high', 'gap'this.passed = false;// Dimensionsthis.width = game.laneWidth * 0.8;this.height = type === 'gap' ? 0 : 50;// Positioningconst laneW = game.laneWidth;this.x = (lane - 1) * laneW + (laneW - this.width) / 2;this.y = game.groundY - this.height;}update() {this.y -= this.game.speed;}draw(ctx) {if (this.type === 'gap') {// Draw hole in groundctx.fillStyle = '#1a1a2e'; // Sky colorctx.fillRect(this.x, this.y, this.width, 20);// Edgectx.fillStyle = '#546E7A';ctx.fillRect(this.x, this.y + 20, this.width, 5);return;}ctx.fillStyle = CONSTANTS.COLORS.OBSTACLE;ctx.strokeStyle = CONSTANTS.COLORS.OBSTACLE_ACCENT;ctx.lineWidth = 3;// Draw based on typeif (this.type === 'low') {// Low barrier (jumpable)ctx.fillRect(this.x, this.y, this.width, 20);ctx.strokeRect(this.x, this.y, this.width, 20);// Decorative stripesctx.fillStyle = '#37474F';ctx.fillRect(this.x + 5, this.y + 5, this.width - 10, 10);} else if (this.type === 'high') {// High barrier (cannot duck under, must jump)ctx.fillRect(this.x, this.y, this.width, this.height);ctx.strokeRect(this.x, this.y, this.width, this.height);// Warning stripesctx.strokeStyle = '#FF5252';ctx.beginPath();for(let i=0; i<this.width; i+=20) {ctx.moveTo(this.x + i, this.y);ctx.lineTo(this.x + i + 10, this.y + this.height);}ctx.stroke();} else {// Standard barrierctx.fillRect(this.x, this.y, this.width, this.height);ctx.strokeRect(this.x, this.y, this.width, this.height);// Gold trimctx.fillStyle = '#B0BEC5';ctx.fillRect(this.x + 5, this.y + 5, this.width - 10, 5);}}getBounds() {return { x: this.x, y: this.y, width: this.width, height: this.height };}}class Coin {constructor(game, lane, isBonus) {this.game = game;this.lane = lane;this.isBonus = isBonus;this.x = 0;this.y = 0;this.size = isBonus ? 25 : 15;this.rotation = 0;this.collected = false;const laneW = game.laneWidth;this.x = (lane - 1) * laneW + laneW / 2;this.y = game.groundY - 80; // Float slightly}update() {this.y -= this.game.speed;this.rotation += 0.1;// Magnet effectif (this.game.playerPowerups.magnet && !this.collected) {const pBounds = this.game.player.getBounds();const dx = (pBounds.x + pBounds.width/2) - (this.x);const dy = (pBounds.y) - (this.y);const dist = Math.sqrt(dx*dx + dy*dy);if (dist < 150) {this.x += dx * 0.1;this.y += dy * 0.1;}}}draw(ctx) {if (this.collected) return;ctx.save();ctx.translate(this.x, this.y);// Glowctx.shadowColor = CONSTANTS.COLORS.COIN;ctx.shadowBlur = 15;Utils.drawBitcoinSymbol(ctx, 0, 0, this.size, this.rotation);ctx.restore();}getBounds() {return { x: this.x - this.size/2, y: this.y - this.size/2, width: this.size, height: this.size };}}class PowerUp {constructor(game, lane, type) {this.game = game;this.lane = lane;this.type = type; // 'shield', 'magnet', 'mul'this.x = 0;this.y = 0;this.width = 30;this.height = 30;this.timer = 0;this.collected = false;const laneW = game.laneWidth;this.x = (lane - 1) * laneW + laneW / 2;this.y = game.groundY - 60;}update() {this.y -= this.game.speed;this.timer++;}draw(ctx) {if (this.collected) return;ctx.save();ctx.translate(this.x, this.y);ctx.rotate(this.timer * 0.05);ctx.fillStyle = 'rgba(255, 255, 255, 0.2)';ctx.strokeStyle = '#fff';ctx.lineWidth = 2;ctx.beginPath();ctx.arc(0, 0, 15, 0, Math.PI * 2);ctx.fill();ctx.stroke();// Iconctx.font = '16px Arial';ctx.textAlign = 'center';ctx.textBaseline = 'middle';ctx.fillStyle = '#fff';let icon = '';if(this.type === 'shield') icon = '🛡️';if(this.type === 'magnet') icon = '🧲';if(this.type === 'mul') icon = 'x2';ctx.fillText(icon, 0, 0);ctx.restore();}getBounds() {return { x: this.x - 15, y: this.y - 15, width: 30, height: 30 };}}// --- MAIN GAME ENGINE ---class Game {constructor() {this.canvas = document.getElementById('gameCanvas');this.ctx = this.canvas.getContext('2d');this.input = new InputHandler();// Statethis.isRunning = false;this.isPaused = false;this.lastTime = 0;this.score = 0;this.distance = 0;this.speed = CONSTANTS.RUN_SPEED_BASE;this.btcBalance = 0.00000000;// Entitiesthis.player = null;this.obstacles = [];this.coins = [];this.particles = [];this.powerups = [];// Spawningthis.spawnTimer = 0;this.spawnRate = 60;// Visualsthis.laneWidth = 100;this.groundY = 0;this.bgOffset = 0;this.screenShake = 0;// Powerupsthis.playerPowerups = {shield: false,magnet: false,mul: false};this.powerupTimers = {};this.resize();window.addEventListener('resize', () => this.resize());// UI Bindingsdocument.getElementById('start-btn').addEventListener('click', () => this.start());document.getElementById('restart-btn').addEventListener('click', () => this.start());document.getElementById('pause-btn').addEventListener('click', () => this.togglePause());// Initial Drawthis.drawBackground();}resize() {this.canvas.width = window.innerWidth;this.canvas.height = window.innerHeight;this.laneWidth = this.canvas.width / 3;this.groundY = this.canvas.height * 0.75;if (!this.isRunning) {this.drawBackground();}}start() {// Reset Game Statethis.isRunning = true;this.isPaused = false;this.score = 0;this.distance = 0;this.speed = CONSTANTS.RUN_SPEED_BASE;this.obstacles = [];this.coins = [];this.particles = [];this.powerups = [];this.btcBalance = parseFloat(document.getElementById('start-btc-display').innerText);this.spawnTimer = 0;// Reset Playerthis.player = new Player(this);this.playerPowerups = { shield: false, magnet: false, mul: false };// UIdocument.getElementById('start-screen').classList.add('hidden');document.getElementById('game-over-screen').classList.add('hidden');document.getElementById('hud').classList.remove('hidden');document.getElementById('powerup-container').classList.remove('hidden');this.updateHUD();this.updatePowerupUI();this.lastTime = performance.now();requestAnimationFrame((t) => this.loop(t));}togglePause() {if (!this.isRunning) return;this.isPaused = !this.isPaused;document.getElementById('pause-btn').innerText = this.isPaused ? '▶' : '❚❚';if (!this.isPaused) {this.lastTime = performance.now();requestAnimationFrame((t) => this.loop(t));}}spawnParticles(x, y, count, color) {for (let i = 0; i < count; i++) {this.particles.push(new Particle(x, y, color, 5));}}spawn() {this.spawnTimer--;// Difficulty Scalingconst difficultyMod = Math.min(this.distance / 5000, 1); // Cap at 2x speedconst currentSpawnRate = Math.max(20, 60 - Math.floor(this.distance / 200));if (this.spawnTimer <= 0) {const lane = Utils.randomInt(0, 2);const rand = Math.random();// Spawn Obstacleif (rand < 0.4) {const type = Math.random() > 0.7 ? 'high' : (Math.random() > 0.5 ? 'low' : 'barrier');this.obstacles.push(new Obstacle(this, lane, type));}// Spawn Coinselse if (rand < 0.8) {const isBonus = Math.random() > 0.8;this.coins.push(new Coin(this, lane, isBonus));}// Spawn Powerupelse if (rand < 0.9) {const pTypes = ['shield', 'magnet', 'mul'];const pType = pTypes[Utils.randomInt(0, 2)];this.powerups.push(new PowerUp(this, lane, pType));}this.spawnTimer = currentSpawnRate;}}checkCollisions() {const pBounds = this.player.getBounds();// Obstaclesfor (let obs of this.obstacles) {const oBounds = obs.getBounds();if (this.rectIntersect(pBounds, oBounds)) {if (this.playerPowerups.shield) {// Destroy obstacle, keep shieldthis.playerPowerups.shield = false;this.spawnParticles(obs.x + obs.width/2, obs.y + obs.height/2, 10, '#87CEEB');this.obstacles = this.obstacles.filter(o => o !== obs);this.screenShake = 5;} else {this.gameOver();}}}// Coinsfor (let coin of this.coins) {if (coin.collected) continue;const cBounds = coin.getBounds();if (this.rectIntersect(pBounds, cBounds)) {coin.collected = true;let val = coin.isBonus ? CONSTANTS.BONUS_COIN_VALUE : CONSTANTS.COIN_VALUE;if (this.playerPowerups.mul) val *= 2;this.btcBalance += val;this.score += 10;this.spawnParticles(coin.x, coin.y, 5, CONSTANTS.COLORS.COIN);}}// Powerupsfor (let pu of this.powerups) {if (pu.collected) continue;const pBounds = pu.getBounds();if (this.rectIntersect(pBounds, pBounds)) { // Use static bounds for powerupspu.collected = true;this.activatePowerup(pu.type);}}}activatePowerup(type) {this.spawnParticles(this.player.x, this.player.y, 20, '#fff');const duration = 600; // 10 seconds at 60fpsif (type === 'shield') {this.playerPowerups.shield = true;this.powerupTimers.shield = duration;document.getElementById('pu-shield').classList.add('active');} else if (type === 'magnet') {this.playerPowerups.magnet = true;this.powerupTimers.magnet = duration;document.getElementById('pu-magnet').classList.add('active');} else if (type === 'mul') {this.playerPowerups.mul = true;this.powerupTimers.mul = duration;document.getElementById('pu-mul').classList.add('active');}}updatePowerupUI() {const ids = ['pu-shield', 'pu-magnet', 'pu-mul'];ids.forEach(id => document.getElementById(id).classList.remove('active'));}rectIntersect(r1, r2) {return !(r2.x > r1.x + r1.width ||r2.x + r2.width < r1.x ||r2.y > r1.y + r1.height ||r2.y + r2.height < r1.y);}update(deltaTime) {if (this.isPaused) return;// Speed Increasethis.speed += 0.0001;this.distance += this.speed;this.score += 1;// Update Entitiesthis.player.update();this.spawn();this.obstacles.forEach(o => o.update());this.obstacles = this.obstacles.filter(o => o.y > -100);this.coins.forEach(c => c.update());this.coins = this.coins.filter(c => c.y > -100);this.powerups.forEach(p => p.update());this.powerups = this.powerups.filter(p => p.y > -100);this.particles.forEach(p => p.update());this.particles = this.particles.filter(p => p.life > 0);// Powerup Timersfor (let key in this.powerupTimers) {if (this.powerupTimers[key] > 0) {this.powerupTimers[key]--;} else {this.playerPowerups[key] = false;delete this.powerupTimers[key];}}this.updatePowerupUI();this.checkCollisions();// Screen Shake Decayif (this.screenShake >
index.html+935-1160