Meta Description" name="description" />
!doctype html><html><head><meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no"><title>Turbo Road</title>
<style>html,body{margin:0;height:100%;overflow:hidden;background:#111;font-family:Arial}canvas{display:block;margin:auto;background:#287d35}.ui{position:fixed;top:10px;left:0;right:0;display:flex;justify-content:space-between;color:#fff;font-weight:bold;font-size:20px;padding:0 15px;text-shadow:2px 2px #000;pointer-events:none}.menu{position:fixed;inset:0;display:flex;align-items:center;justify-content:center;flex-direction:column;background:#0009;color:#fff;text-align:center}.menu button{padding:15px 30px;border:0;border-radius:12px;background:#ffd400;font-size:20px;font-weight:bold}.buttons{position:fixed;bottom:20px;left:0;right:0;display:flex;justify-content:space-between;padding:0 22px}.buttons button{width:90px;height:65px;border:2px solid #fff8;border-radius:18px;background:#ffffff44;color:#fff;font-size:32px}</style></head>
<body><canvas id="c" width="420" height="760"></canvas><div class="ui"><span>🏎️ TURBO ROAD</span><span>🏆 <b id="s">0</b></span></div>
<div class="menu" id="m"><h1>🏎️ TURBO ROAD</h1><p>◀ ▶ दबाकर कार बचाओ!</p><button id="go">START RACE</button></div>
<div class="buttons"><button id="l">◀</button><button id="r">▶</button></div>
<script>
const c=document.getElementById('c'),x=c.getContext('2d'),m=document.getElementById('m'),s=document.getElementById('s');let run=0,score=0,last=0,line=0,spawn=0,traffic=[],L=0,R=0;
const me={x:185,y:635,w:50,h:90};
function fit(){let z=Math.min(innerWidth/420,innerHeight/760);c.style.width=420*z+'px';c.style.height=760*z+'px'}fit();onresize=fit;
function car(a,b,w,h,col){x.fillStyle=col;x.fillRect(a,b,w,h);x.fillStyle='#bdefff';x.fillRect(a+10,b+12,w-20,25);x.fillStyle='#222';x.fillRect(a-5,b+18,7,23);x.fillRect(a+w-2,b+18,7,23);x.fillRect(a+5,b+58,w-10,22);x.fillStyle='#fff';x.fillRect(a+5,b+5,8,14);x.fillRect(a+w-13,b+5,8,14)}
function road(){x.fillStyle='#287d35';x.fillRect(0,0,420,760);x.fillStyle='#3c3c3c';x.fillRect(55,0,310,760);x.fillStyle='#fff';x.fillRect(55,0,6,760);x.fillRect(359,0,6,760);line=(line+6)%80;for(let y=-80+line;y<760;y+=80)x.fillRect(151,y,8,45),x.fillRect(261,y,8,45)}
function over(a,b){return a.x<b.x+b.w&&a.x+a.w>b.x&&a.y<b.y+b.h&&a.y+a.h>b.y}
function start(){run=1;score=0;traffic=[];me.x=185;spawn=0;m.style.display='none';last=performance.now();requestAnimationFrame(loop)}
function gameover(){run=0;m.innerHTML='<h1>💥 CRASH!</h1><p>Score: '+Math.floor(score)+'</p><button id="again">RESTART</button>';m.style.display='flex';document.getElementById('again').onclick=start}
function loop(t){if(!run)return;let d=Math.min((t-last)/16.67,2);last=t;road();score+=.15*d;s.textContent=Math.floor(score);let sp=Math.min(13,6+score/180);spawn-=d;if(spawn<=0){let lanes=[88,185,282];traffic.push({x:lanes[Math.floor(Math.random()*3)],y:-100,w:50,h:90,col:['#f33','#29f','#ff9f1c','#a84cff'][Math.floor(Math.random()*4)]});spawn=Math.max(25,65-score/18)}traffic.forEach(v=>v.y+=sp*d);traffic=traffic.filter(v=>v.y<800);if(L)me.x-=8;if(R)me.x+=8;me.x=Math.max(65,Math.min(305,me.x));for(const v of traffic)if(over(me,v))return gameover();car(me.x,me.y,50,90,'#00d9ff');traffic.forEach(v=>car(v.x,v.y,50,90,v.col));requestAnimationFrame(loop)}
function hold(el,set){el.onpointerdown=()=>window[set]=1;el.onpointerup=el.onpointercancel=el.onpointerleave=()=>window[set]=0}hold(document.getElementById('l'),'L');hold(document.getElementById('r'),'R');onkeydown=e=>{if(e.key==='ArrowLeft')L=1;if(e.key==='ArrowRight')R=1};onkeyup=e=>{if(e.key==='ArrowLeft')L=0;if(e.key==='ArrowRight')R=0};document.getElementById('go').onclick=start;
</script></body></html>1
1
4KB
4KB
121.0ms
160.0ms
121.0ms