<!DOCTYPE html>
<html lang="ur">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="theme-color" content="#101820">
<title>Desi Streets 3D — Pakistan Open World</title>
<style>
*{box-sizing:border-box;margin:0;padding:0;user-select:none;-webkit-user-select:none}
html,body{width:100%;height:100%;overflow:hidden;background:#111;font-family:Arial,sans-serif;touch-action:none}
#game{position:fixed;inset:0;width:100%;height:100%;display:block}
#hud{position:fixed;inset:10px 10px auto;display:flex;justify-content:space-between;gap:8px;z-index:5;pointer-events:none;color:#fff}
.panel{background:#101820d9;border:1px solid #38b879;border-radius:12px;padding:9px 11px;min-width:130px}
.small{font-size:11px;color:#cbd5e1}
#healthbar{height:9px;background:#475569;border-radius:9px;overflow:hidden;margin:5px 0}
#healthfill{height:100%;width:100%;background:linear-gradient(90deg,#ef4444,#22c55e)}
.money{color:#facc15;font-weight:800;margin-top:5px}
#mission{max-width:48%;text-align:right;border-right:4px solid #facc15}
#mission strong{color:#facc15;font-size:12px}
#mission p{font-size:12px;line-height:1.4;margin-top:4px}
#toast{position:fixed;top:94px;left:50%;transform:translateX(-50%);z-index:9;background:#087f4f;color:white;padding:9px 16px;border-radius:30px;font-weight:bold;font-size:13px;opacity:0;pointer-events:none;white-space:nowrap}
#controls{position:fixed;inset:auto 0 14px;z-index:7;pointer-events:none}
#stick{position:absolute;left:18px;bottom:8px;width:132px;height:132px;border-radius:50%;background:#ffffff20;border:2px solid #ffffff55;pointer-events:auto;touch-action:none}
#knob{position:absolute;left:50%;top:50%;width:54px;height:54px;transform:translate(-50%,-50%);border-radius:50%;background:#16a36aeb;border:2px solid white;pointer-events:none}
#buttons{position:absolute;right:15px;bottom:8px;display:grid;grid-template-columns:64px 72px;grid-template-rows:64px 72px;gap:10px;pointer-events:auto}
.action{border:2px solid #ffffffa8;border-radius:50%;color:white;font-weight:800;background:#1d4ed8df;font-size:12px;touch-action:none}
#fire{grid-column:2;grid-row:2;background:#dc2626ed;width:72px;height:72px}
#jump{grid-column:2;grid-row:1}
#vehicle{grid-column:1;grid-row:2;background:#eab308ed;color:#111;display:none}
#hint{position:fixed;bottom:7px;left:50%;transform:translateX(-50%);z-index:6;color:#fff;background:#0008;padding:5px 9px;border-radius:8px;font-size:10px;pointer-events:none;white-space:nowrap}
#start{position:fixed;inset:0;z-index:20;background:radial-gradient(circle at 50% 35%,#1d563d,#08110e 72%);display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;color:white;padding:24px}
#start h1{font-size:clamp(27px,7vw,46px);color:#facc15;margin-bottom:10px}
#start p{max-width:520px;color:#e2e8f0;line-height:1.7;font-size:14px;margin:8px 0 18px}
#play{border:0;border-radius:28px;background:#0c9b5d;color:#fff;font-size:18px;font-weight:bold;padding:14px 34px}
#start .note{font-size:11px;color:#a7f3d0;margin-top:14px}
#pause{position:fixed;right:10px;top:105px;z-index:8;border:1px solid #fff8;border-radius:9px;background:#101820cc;color:#fff;padding:8px 11px}
#paused{display:none;position:fixed;inset:0;background:#000a;z-index:15;color:#fff;align-items:center;justify-content:center;text-align:center;flex-direction:column;gap:14px}
#paused button{padding:11px 25px;border:0;border-radius:20px;background:#0c9b5d;color:#fff;font-weight:bold}
@media(max-width:500px){.panel{min-width:110px;padding:7px}.small{font-size:9px}#mission p{font-size:10px}}
</style>
</head>
<body>
<canvas id="game"></canvas>
<div id="hud">
<div class="panel">
<div class="small">HEALTH / صحت</div>
<div id="healthbar"><div id="healthfill"></div></div>
<div class="money">PKR <span id="cash">5,000</span></div>
<div class="small">KILLS: <span id="kills">0</span> | LEVEL: <span id="level">1</span></div>
</div>
<div class="panel" id="mission">
<strong>موجودہ مشن</strong>
<p id="missionText">سرخ گینگ کے 5 افراد کو شکست دیں۔</p>
</div>
</div>
<div id="toast"></div>
<button id="pause">Ⅱ</button>
<div id="controls">
<div id="stick"><div id="knob"></div></div>
<div id="buttons">
<button class="action" id="jump">JUMP</button>
<button class="action" id="vehicle">DRIVE</button>
<button class="action" id="fire">FIRE</button>
</div>
</div>
<div id="hint">بائیں جوائے اسٹک: حرکت | دائیں طرف انگلی گھمائیں: کیمرہ | FIRE: فائرنگ</div>
<div id="start">
<h1>🇵🇰 DESI STREETS 3D</h1>
<p>پاکستانی شہر کی گلیوں، بازاروں اور سڑکوں میں ایک تھرڈ پرسن 3D ایڈونچر۔ پیدل چلیں، دشمنوں سے مقابلہ کریں اور رکشہ یا کار چلائیں۔</p>
<button id="play">گیم شروع کریں</button>
<div class="note">بہتر تجربے کے لیے Chrome میں کھولیں اور فون کو Landscape کریں۔</div>
</div>
<div id="paused">
<h2>گیم روک دی گئی</h2>
<p>دوبارہ کھیلنے کے لیے نیچے دبائیں۔</p>
<button id="resume">واپس کھیلیں</button>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
<script>
(()=>{
"use strict";
const $=id=>document.getElementById(id);
let scene,camera,renderer,clock,player,playerRoot,vehicleNow=null;
let enemies=[],bullets=[],vehicles=[],solids=[];
let health=100,cash=5000,kills=0,level=1,missionGoal=5,missionKills=0;
let input={x:0,y:0},cameraYaw=0,cameraPitch=.28,velocityY=0,grounded=true;
let running=false,paused=false,lastShot=0,damageCooldown=0;
const WORLD=170,mats={};
function mat(color){
if(!mats[color])mats[color]=new THREE.MeshStandardMaterial({color,roughness:1});
return mats[color];
}
function box(parent,w,h,d,color,x,y,z,cast=true){
const m=new THREE.Mesh(new THREE.BoxGeometry(w,h,d),mat(color));
m.position.set(x,y,z);m.castShadow=cast;m.receiveShadow=true;parent.add(m);return m;
}
function toast(s){
const t=$("toast");t.textContent=s;t.style.opacity=1;
clearTimeout(toast.timer);toast.timer=setTimeout(()=>t.style.opacity=0,1900);
}
function hud(){
$("healthfill").style.width=Math.max(0,health)+"%";
$("cash").textContent=cash.toLocaleString("en-US");
$("kills").textContent=kills;$("level").textContent=level;
}
function addSolid(x,z,w,d){
solids.push({minX:x-w/2,maxX:x+w/2,minZ:z-d/2,maxZ:z+d/2});
}
function createCity(){
scene.background=new THREE.Color(0x8bc5df);
scene.fog=new THREE.Fog(0x8bc5df,95,210);
const ground=new THREE.Mesh(new THREE.PlaneGeometry(400,400),mat(0x77756e));
ground.rotation.x=-Math.PI/2;ground.receiveShadow=true;scene.add(ground);
const roadMat=new THREE.MeshStandardMaterial({color:0x30343a,roughness:1});
function road(x,z,w,d){
let r=new THREE.Mesh(new THREE.PlaneGeometry(w,d),roadMat);
r.rotation.x=-Math.PI/2;r.position.set(x,.012,z);scene.add(r);
}
road(0,0,25,360);road(0,0,360,25);
const lineMat=new THREE.MeshBasicMaterial({color:0xe8dfbd});
for(let n=-170;n<=170;n+=13){
let a=new THREE.Mesh(new THREE.PlaneGeometry(.22,5),lineMat);
a.rotation.x=-Math.PI/2;a.position.set(0,.025,n);scene.add(a);
let b=new THREE.Mesh(new THREE.PlaneGeometry(5,.22),lineMat);
b.rotation.x=-Math.PI/2;b.position.set(n,.025,0);scene.add(b);
}
for(const s of [-1,1]){road(s*15.2,0,4,360);road(0,s*15.2,360,4)}
const shopNames=["لاہور بریانی","کوئٹہ چائے","الحمد جنرل اسٹور","مدینہ موبائل","کراچی نہاری","استاد پنکچر"];
const colors=[0xb45309,0xe5e7eb,0xfbbf24,0x64748b,0xf97316,0x0f766e];
for(let x=-140;x<=140;x+=35)for(let z=-140;z<=140;z+=35){
if(Math.abs(x)<27||Math.abs(z)<27)continue;
const w=17+Math.random()*3,d=17+Math.random()*3,h=9+Math.random()*13;
const c=colors[Math.floor(Math.random()*colors.length)];
box(scene,w,h,d,c,x,h/2,z);addSolid(x,z,w+1,d+1);
box(scene,w*.78,.45,1.2,0x166534,x,h*.25,z+d/2+.7);
const sign=box(scene,w*.8,1.35,.18,0x172554,x,h*.52,z+d/2+1.35,false);
const canvas=document.createElement("canvas");canvas.width=512;canvas.height=128;
const ctx=canvas.getContext("2d");
ctx.fillStyle="#172554";ctx.fillRect(0,0,512,128);
ctx.fillStyle="#facc15";ctx.font="bold 48px Arial";ctx.textAlign="center";
ctx.textBaseline="middle";
ctx.fillText(shopNames[Math.floor(Math.random()*shopNames.length)],256,65);
sign.material=new THREE.MeshBasicMaterial({map:new THREE.CanvasTexture(canvas)});
for(let k=-1;k<=1;k++)box(scene,3,2.4,.12,0x7dd3fc,x+k*4,2.2,z+d/2+1.02,false);
}
for(let n=-130;n<=130;n+=32)for(const s of [-1,1]){
const g=new THREE.Group();g.position.set(s*19,0,n);scene.add(g);
box(g,.18,5,.18,0x343a40,0,2.5,0,false);
box(g,1.4,.16,.2,0x343a40,s*.55,5,0,false);
const bulb=new THREE.Mesh(new THREE.SphereGeometry(.22,8,8),
new THREE.MeshBasicMaterial({color:0xffedaa}));
bulb.position.set(s*1.1,4.85,0);g.add(bulb);
}
for(let i=0;i<42;i++){
let x=(Math.random()-.5)*300,z=(Math.random()-.5)*300;
if(Math.abs(x)<24||Math.abs(z)<24)continue;
const g=new THREE.Group();g.position.set(x,0,z);scene.add(g);
box(g,.65,2,.65,0x754c24,0,1,0,false);
const crown=new THREE.Mesh(new THREE.SphereGeometry(1.8,8,7),mat(0x287447));
crown.position.y=3;g.add(crown);
}
}
function makePerson(color,enemy=false){
const g=new THREE.Group();
box(g,.82,1.25,.48,color,0,1.15,0);
box(g,.48,.5,.48,0xc98e63,0,2.05,0);
if(enemy)box(g,.62,.2,.62,0xdc2626,0,2.4,0);
box(g,.28,.72,.32,0x1f2937,-.22,.35,0);
box(g,.28,.72,.32,0x1f2937,.22,.35,0);
box(g,.2,.8,.22,color,-.53,1.25,0);
box(g,.2,.8,.22,color,.53,1.25,0);
return g;
}
function createPlayer(){
playerRoot=new THREE.Group();player=makePerson(0xf1f5f9);
playerRoot.add(player);playerRoot.position.set(0,0,9);scene.add(playerRoot);
}
function makeVehicle(type,x,z,color,speed){
const g=new THREE.Group();
if(type==="Rickshaw"){
box(g,1.9,1.2,2.8,0x079455,0,.85,0);
box(g,1.95,.22,2.9,0xfacc15,0,1.55,-.05);
box(g,1.55,.75,.12,0x9bd7e8,0,1.25,1.42);
box(g,1.5,.65,.12,0x9bd7e8,0,1.2,-1.42);
for(const xw of [-1,1]){
let wh=new THREE.Mesh(new THREE.CylinderGeometry(.38,.38,.18,16),mat(0x171717));
wh.rotation.z=Math.PI/2;wh.position.set(xw,.38,.85);g.add(wh);
let wh2=wh.clone();wh2.position.z=-.9;g.add(wh2);
}
}else{
box(g,2.05,.72,4,color,0,.65,0);
box(g,1.72,.75,2.1,0x334155,0,1.35,-.2);
for(const xw of [-1,1])for(const zw of [-1.25,1.25]){
let wh=new THREE.Mesh(new THREE.CylinderGeometry(.34,.34,.2,16),mat(0x111111));
wh.rotation.z=Math.PI/2;wh.position.set(xw,.38,zw);g.add(wh);
}
for(const xw of [-.65,.65])box(g,.35,.2,.08,0xfff4c2,xw,.72,2.02,false);
}
g.position.set(x,0,z);scene.add(g);vehicles.push({mesh:g,type,speed});return g;
}
function spawnEnemy(){
const e=makePerson(0x7f1d1d,true);
let a=Math.random()*Math.PI*2,d=35+Math.random()*42;
e.position.set(Math.cos(a)*d,0,Math.sin(a)*d);
scene.add(e);enemies.push({mesh:e,hp:3});
}
function init(){
if(!window.THREE){toast("Three.js لوڈ نہیں ہوئی؛ انٹرنیٹ چیک کریں");return}
scene=new THREE.Scene();
camera=new THREE.PerspectiveCamera(62,innerWidth/innerHeight,.1,500);
renderer=new THREE.WebGLRenderer({canvas:$("game"),antialias:true,powerPreference:"high-performance"});
renderer.setPixelRatio(Math.min(devicePixelRatio,1.6));
renderer.setSize(innerWidth,innerHeight);
renderer.shadowMap.enabled=true;
renderer.shadowMap.type=THREE.PCFSoftShadowMap;
renderer.outputEncoding=THREE.sRGBEncoding;
scene.add(new THREE.HemisphereLight(0xe8f6ff,0x51412d,1.15));
const sun=new THREE.DirectionalLight(0xffedcf,1.35);
sun.position.set(-45,85,35);sun.castShadow=true;
sun.shadow.mapSize.set(1024,1024);
sun.shadow.camera.left=-90;sun.shadow.camera.right=90;
sun.shadow.camera.top=90;sun.shadow.camera.bottom=-90;scene.add(sun);
createCity();createPlayer();
makeVehicle("Rickshaw",6,5,0x079455,.34);
makeVehicle("Car",-8,-10,0xffffff,.48);
for(let i=0;i<6;i++)spawnEnemy();
clock=new THREE.Clock();window.addEventListener("resize",resize);
running=true;animate();
}
function resize(){
if(!camera||!renderer)return;
camera.aspect=innerWidth/innerHeight;camera.updateProjectionMatrix();
renderer.setSize(innerWidth,innerHeight);
renderer.setPixelRatio(Math.min(devicePixelRatio,1.6));
}
function blocked(pos,r=.65){
for(const c of solids)
if(pos.x+r>c.minX&&pos.x-r<c.maxX&&pos.z+r>c.minZ&&pos.z-r<c.maxZ)return true;
return Math.abs(pos.x)>WORLD||Math.abs(pos.z)>WORLD;
}
function shoot(){
if(!running||paused||vehicleNow)return;
const now=performance.now();if(now-lastShot<260)return;lastShot=now;
const dir=new THREE.Vector3(Math.sin(playerRoot.rotation.y),0,Math.cos(playerRoot.rotation.y));
const mesh=new THREE.Mesh(new THREE.SphereGeometry(.12,8,8),
new THREE.MeshBasicMaterial({color:0xffd54a}));
mesh.position.copy(playerRoot.position);mesh.position.y+=1.45;
scene.add(mesh);bullets.push({mesh,dir,life:75});
}
function jump(){if(grounded&&!vehicleNow){velocityY=.27;grounded=false}}
function toggleVehicle(){
if(vehicleNow){
playerRoot.position.copy(vehicleNow.mesh.position);
playerRoot.position.x+=2.6;playerRoot.visible=true;vehicleNow=null;
$("vehicle").textContent="DRIVE";toast("آپ گاڑی سے باہر آ گئے");return;
}
let nearest=null,dist=5;
for(const v of vehicles){
const d=playerRoot.position.distanceTo(v.mesh.position);
if(d<dist){nearest=v;dist=d}
}
if(nearest){
vehicleNow=nearest;playerRoot.visible=false;
$("vehicle").textContent="EXIT";
toast(nearest.type==="Rickshaw"?"آپ رکشے میں سوار ہو گئے":"آپ کار میں سوار ہو گئے");
}
}
function damage(amount){
health=Math.max(0,health-amount);
if(health===0){
health=100;cash=Math.max(0,cash-1000);
playerRoot.position.set(0,0,9);vehicleNow=null;playerRoot.visible=true;
toast("آپ اسپتال پہنچ گئے؛ PKR 1,000 کٹ گئے");
}
hud();
}
function completeMission(){
missionKills=0;level++;missionGoal+=2;
$("missionText").textContent=`لیول ${level}: دشمن گینگ کے ${missionGoal} افراد کو شکست دیں۔`;
cash+=2500;hud();toast("مشن مکمل! بونس PKR 2,500");
}
function update(dt){
const active=vehicleNow?vehicleNow.mesh:playerRoot;
const speed=vehicleNow?vehicleNow.speed:5.2;
const mag=Math.hypot(input.x,input.y);
if(mag>.08){
const angle=Math.atan2(input.x,-input.y)+cameraYaw;
active.rotation.y=angle;
const step=Math.min(1,mag)*speed*dt;
const next=active.position.clone();
next.x+=Math.sin(angle)*step;next.z+=Math.cos(angle)*step;
if(!blocked(next,vehicleNow?1.1:.55))active.position.copy(next);
}
if(!vehicleNow){
playerRoot.position.y+=velocityY;velocityY-=.8*dt;
if(playerRoot.position.y<=0){playerRoot.position.y=0;velocityY=0;grounded=true}
}
const near=vehicleNow||vehicles.some(v=>playerRoot.position.distanceTo(v.mesh.position)<5);
$("vehicle").style.display=near?"block":"none";
for(let i=bullets.length-1;i>=0;i--){
const b=bullets[i];b.mesh.position.addScaledVector(b.dir,24*dt);b.life--;
for(let j=enemies.length-1;j>=0;j--){
const e=enemies[j],target=e.mesh.position.clone();target.y+=1.35;
if(b.mesh.position.distanceTo(target)<1.15){
e.hp--;b.life=0;
if(e.hp<=0){
scene.remove(e.mesh);enemies.splice(j,1);
kills++;missionKills++;cash+=1500;hud();
toast("دشمن شکست کھا گیا! +PKR 1,500");
if(missionKills>=missionGoal)completeMission();
spawnEnemy();
}
break;
}
}
if(b.life<=0){scene.remove(b.mesh);bullets.splice(i,1)}
}
damageCooldown=Math.max(0,damageCooldown-dt);
for(const e of enemies){
const d=e.mesh.position.distanceTo(active.position);
if(d<36&&d>1.7){
const dir=new THREE.Vector3().subVectors(active.position,e.mesh.position).normalize();
const p=e.mesh.position.clone().addScaledVector(dir,1.15*dt);
if(!blocked(p,.5))e.mesh.position.copy(p);
e.mesh.lookAt(active.position);
}else if(d<=2.1&&!vehicleNow&&damageCooldown<=0){
damage(5);damageCooldown=.55;
}
}
const dist=vehicleNow?12:8.5,height=vehicleNow?5.5:4.5;
const target=active.position;
camera.position.set(
target.x-Math.sin(cameraYaw)*dist,
target.y+height+cameraPitch*5,
target.z-Math.cos(cameraYaw)*dist
);
camera.lookAt(target.x,target.y+1.5,target.z);
}
function animate(){
if(!running)return;
requestAnimationFrame(animate);
if(paused)return;
const dt=Math.min(clock.getDelta(),.04);
update(dt);renderer.render(scene,camera);
}
function pauseGame(){if(!running)return;paused=true;$("paused").style.display="flex"}
function resumeGame(){paused=false;$("paused").style.display="none";clock.getDelta()}
function bindControls(){
const zone=$("stick"),knob=$("knob");let pointer=null;
function setStick(e){
const r=zone.getBoundingClientRect(),cx=r.left+r.width/2,cy=r.top+r.height/2;
let dx=e.clientX-cx,dy=e.clientY-cy;
const max=r.width/2-28,d=Math.hypot(dx,dy);
if(d>max){dx=dx/d*max;dy=dy/d*max}
knob.style.transform=`translate(calc(-50% + ${dx}px),calc(-50% + ${dy}px))`;
input.x=dx/max;input.y=dy/max;
}
zone.addEventListener("pointerdown",e=>{pointer=e.pointerId;zone.setPointerCapture(pointer);setStick(e)});
zone.addEventListener("pointermove",e=>{if(pointer===e.pointerId)setStick(e)});
function reset(e){
if(pointer===e.pointerId){pointer=null;input={x:0,y:0};knob.style.transform="translate(-50%,-50%)"}
}
zone.addEventListener("pointerup",reset);zone.addEventListener("pointercancel",reset);
$("fire").addEventListener("pointerdown",e=>{e.preventDefault();shoot()});
$("jump").addEventListener("pointerdown",e=>{e.preventDefault();jump()});
$("vehicle").addEventListener("pointerdown",e=>{e.preventDefault();toggleVehicle()});
let lookPointer=null,lastX=0,lastY=0;
$("game").addEventListener("pointerdown",e=>{
if(e.pointerType==="mouse"||e.clientX>innerWidth*.35){
lookPointer=e.pointerId;lastX=e.clientX;lastY=e.clientY;
$("game").setPointerCapture(e.pointerId);
}
});
$("game").addEventListener("pointermove",e=>{
if(lookPointer===e.pointerId){
cameraYaw-=(e.clientX-lastX)*.006;
cameraPitch=Math.max(-.2,Math.min(.8,cameraPitch+(e.clientY-lastY)*.002));
lastX=e.clientX;lastY=e.clientY;
}
});
const end=e=>{if(lookPointer===e.pointerId)lookPointer=null};
$("game").addEventListener("pointerup",end);
$("game").addEventListener("pointercancel",end);
const keys={};
window.addEventListener("keydown",e=>{
keys[e.key.toLowerCase()]=true;
if(e.key===" "){e.preventDefault();jump()}
if(e.key.toLowerCase()==="f")shoot();
if(e.key.toLowerCase()==="e")toggleVehicle();
});
window.addEventListener("keyup",e=>keys[e.key.toLowerCase()]=false);
const originalUpdate=update;
update=function(dt){
const kx=(keys.d||keys.arrowright?1:0)-(keys.a||keys.arrowleft?1:0);
const ky=(keys.s||keys.arrowdown?1:0)-(keys.w||keys.arrowup?1:0);
const saved={...input};
input.x=Math.max(-1,Math.min(1,saved.x+kx));
input.y=Math.max(-1,Math.min(1,saved.y+ky));
originalUpdate(dt);input=saved;
};
$("pause").addEventListener("click",pauseGame);
$("resume").addEventListener("click",resumeGame);
}
$("play").addEventListener("click",()=>{
$("start").style.display="none";init();if(running)bindControls();
});
})();
</script>
</body>
</html>