NEON OVERDRIVE — Open World
by GlitchPanther20624 lines24.3 KB🛠️ Three.js (3D graphics)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>NEON OVERDRIVE — Open World</title>
<style>
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@500;700;900&family=Rajdhani:wght@500;700&display=swap');
*{box-sizing:border-box}
body{margin:0;overflow:hidden;background:#070912;color:white;font-family:Rajdhani,sans-serif}
canvas{display:block}
#hud{position:fixed;inset:0;pointer-events:none}
#brand{position:absolute;top:20px;left:25px;font-family:Orbitron;font-weight:900;font-size:29px;letter-spacing:3px;text-shadow:0 0 15px #00cfff}
#brand span{color:#ff287e}
#district{font-size:12px;letter-spacing:4px;color:#00eaff}
#topright{position:absolute;right:25px;top:25px;text-align:right;font-family:Orbitron}
#cash{font-size:23px;color:#00ff9d}
#mission{color:#ffe35a;font-size:12px;margin-top:6px;letter-spacing:2px}
#stars{font-size:22px;color:#ffe04d;margin-top:5px}
#bottom{position:absolute;bottom:22px;left:25px;display:flex;gap:12px;align-items:end}
.panel{background:rgba(4,10,20,.8);border:1px solid rgba(0,225,255,.35);padding:11px 14px;backdrop-filter:blur(8px)}
#healthbar{width:170px;height:6px;background:#28293b;margin-top:7px}
#healthfill{height:100%;width:100%;background:linear-gradient(90deg,#ff207b,#ff6045)}
#speed{font-family:Orbitron;font-size:30px}
#speed small{font-size:11px;color:#00eaff}
#controls{position:absolute;right:24px;bottom:24px;text-align:right;font-size:15px;letter-spacing:1px;text-shadow:0 2px 6px black}
#prompt{position:absolute;left:50%;top:65%;transform:translate(-50%,-50%);padding:10px 20px;border:1px solid #00eaff;background:#06101a;display:none;color:#00eaff;font-family:Orbitron}
#toast{position:absolute;top:42%;left:50%;transform:translate(-50%,-50%);color:#b56bff;font-family:Orbitron;font-size:20px;text-shadow:0 0 20px #a04bff;opacity:0;transition:.3s}
#routehud{position:absolute;left:50%;top:22px;transform:translateX(-50%);text-align:center;font-family:Orbitron;display:none}
#routehud strong{color:#c276ff;font-size:17px;text-shadow:0 0 10px #9a48ff}
#routehud small{display:block;font-size:11px;color:#ddd;margin-top:4px}
#mapUI{position:fixed;inset:0;background:rgba(3,5,12,.96);display:none;z-index:20}
#mapheader{padding:20px 26px;display:flex;justify-content:space-between;align-items:center;font-family:Orbitron}
#mapheader h2{margin:0;font-size:25px;letter-spacing:4px}
#mapheader span{color:#c175ff}
#mapbody{height:calc(100% - 85px);display:flex;padding:0 20px 20px;gap:15px}
#mapcanvas{flex:1;min-width:0;background:#0a1018;border:1px solid #303c50;cursor:crosshair}
#mapside{width:260px;padding:18px;background:#0b101a;border:1px solid #28344a}
#mapside h3{font-family:Orbitron;color:#b56bff;font-size:15px}
#mapside p{font-size:16px;color:#c7d0df}
#places{display:flex;flex-direction:column;gap:7px}
.placebtn{background:#111a29;color:#cbd5e4;border:1px solid #28394d;padding:9px;text-align:left;cursor:pointer;font-family:Rajdhani;font-size:16px}
.placebtn:hover{border-color:#a65bff;color:white}
#go{width:100%;padding:12px;margin-top:16px;background:#9c43ff;color:white;border:0;font-family:Orbitron;font-weight:bold;cursor:pointer}
#closemap{cursor:pointer;color:#bbb}
#start{position:fixed;inset:0;z-index:30;background:radial-gradient(ellipse,#101c35,#020308 75%);display:flex;align-items:center;justify-content:center;flex-direction:column;text-align:center;cursor:pointer}
#start h1{font-family:Orbitron;font-size:clamp(36px,7vw,80px);line-height:1.05;margin:0;text-shadow:0 0 30px #e52b88}
#start h1 span{color:#00eaff}
#start p{color:#00eaff;letter-spacing:5px;margin-top:24px;font-size:20px}
#start small{margin-top:40px;color:#888;letter-spacing:2px}
</style>
</head>
<body>
<div id="hud">
<div id="brand">GTA <span>7</span><div id="district">NEON OVERDRIVE // VICE METRO</div></div>
<div id="topright"><div id="cash">$ 250,000</div><div id="mission">FREE ROAM</div><div id="stars">☆ ☆ ☆ ☆ ☆</div></div>
<div id="routehud"><strong id="routeName">GPS ACTIVE</strong><small id="routeDistance">ROUTE SET</small></div>
<div id="bottom">
<div class="panel">JASON // HEALTH<div id="healthbar"><div id="healthfill"></div></div></div>
<div class="panel"><div id="speed">000 <small>KM/H</small></div></div>
</div>
<div id="controls">WASD MOVE / DRIVE · SHIFT SPRINT · SPACE JUMP<br>E ENTER / EXIT CAR · L CITY MAP</div>
<div id="prompt">PRESS E — ENTER VEHICLE</div>
<div id="toast"></div>
</div>
<div id="mapUI">
<div id="mapheader"><h2>VICE METRO <span>GPS</span></h2><div id="closemap">[ L / ESC — CLOSE ]</div></div>
<div id="mapbody">
<canvas id="mapcanvas"></canvas>
<div id="mapside">
<h3>DESTINATION</h3>
<p id="selectedName">Click a place on the map.</p>
<p id="selectedInfo">Purple marker = destination.</p>
<div id="places"></div>
<button id="go">SET GPS ROUTE</button>
<p style="font-size:12px;color:#8794a8">Click anywhere on the map to set a custom waypoint.</p>
</div>
</div>
</div>
<div id="start">
<h1>GTA <span>7</span><br>NEON OVERDRIVE</h1>
<p>ENTER THE MEGA CITY</p>
<small>CLICK TO PLAY · PRESS L FOR GPS MAP</small>
</div>
<script type="module">
import * as THREE from 'https://cdn.jsdelivr.net/npm/three@0.160.0/build/three.module.js';
// --------------------------------------------------
// WORLD / RENDERER
// --------------------------------------------------
const scene=new THREE.Scene();
scene.background=new THREE.Color(0x080b15);
scene.fog=new THREE.FogExp2(0x080b15,.00115);
const camera=new THREE.PerspectiveCamera(70,innerWidth/innerHeight,.1,2500);
const renderer=new THREE.WebGLRenderer({antialias:true});
renderer.setSize(innerWidth,innerHeight);
renderer.setPixelRatio(Math.min(devicePixelRatio,2));
renderer.shadowMap.enabled=true;
renderer.shadowMap.type=THREE.PCFSoftShadowMap;
renderer.toneMapping=THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure=1.2;
document.body.appendChild(renderer.domElement);
scene.add(new THREE.HemisphereLight(0x8eaeff,0x10101a,2.1));
const sun=new THREE.DirectionalLight(0xb5d3ff,2.3);
sun.position.set(180,250,120);sun.castShadow=true;
sun.shadow.mapSize.set(2048,2048);scene.add(sun);
const glowLight=new THREE.PointLight(0x00cfff,80,180);
glowLight.position.set(0,20,0);scene.add(glowLight);
const material=(c,r=.7,m=0)=>new THREE.MeshStandardMaterial({color:c,roughness:r,metalness:m});
const asphalt=material(0x181c24);
const grass=material(0x15201e);
const pavement=material(0x424652);
const buildingMats=[0x151f31,0x222639,0x29213a,0x17303a,0x34313e,0x172838,0x222b35].map(c=>material(c,.6,.3));
const neonMats=[0x00d9ff,0xff278c,0x9b55ff,0xffbf4a].map(c=>new THREE.MeshBasicMaterial({color:c}));
function box(parent,w,h,d,mat,x,y,z){
const o=new THREE.Mesh(new THREE.BoxGeometry(w,h,d),mat);
o.position.set(x,y,z);o.castShadow=true;o.receiveShadow=true;parent.add(o);return o;
}
function plane(w,d,mat,x,y,z){
const o=new THREE.Mesh(new THREE.PlaneGeometry(w,d),mat);
o.rotation.x=-Math.PI/2;o.position.set(x,y,z);scene.add(o);return o;
}
// Ground
plane(2200,2200,grass,0,-.08,0);
// Road network (expanded mega-city)
const citySize=1000,block=100,roadWidth=22;
for(let i=-10;i<=10;i++){
const p=i*block;
plane(citySize,roadWidth,asphalt,0,.01,p);
plane(roadWidth,citySize,asphalt,p,.012,0);
// dashed center lines
for(let n=-9;n<=9;n++){
const x=n*block+30;
box(scene,5,.025,.18,material(0xb4b8c0),x,.03,p);
}
}
// --------------------------------------------------
// BUILDINGS + WINDOWS + STREET DETAIL
// --------------------------------------------------
function addBuilding(x,z,w,d,h){
const m=buildingMats[Math.floor(Math.random()*buildingMats.length)];
const b=box(scene,w,h,d,m,x,h/2,z);
// Rooftop lip
box(scene,w+.5,.3,d+.5,material(0x333c4d),x,h+.12,z);
// facade window grid
const winColors=[0xffbd59,0x40cfff,0x324b68,0xff65ad];
const cols=Math.floor(w/5),rows=Math.floor(h/6);
for(let face=0;face<2;face++){
for(let yy=0;yy<rows;yy++){
for(let xx=0;xx<cols;xx++){
if(Math.random()<.18)continue;
const wm=new THREE.MeshBasicMaterial({color:winColors[Math.floor(Math.random()*winColors.length)]});
const win=new THREE.Mesh(new THREE.BoxGeometry(2.2,2.5,.12),wm);
win.position.set(x-w/2+3+xx*5,4+yy*6,z+d/2+.1);
scene.add(win);
if(face===1){
const win2=win.clone();
win2.position.set(x+w/2+.1,4+yy*6,z-d/2+3+xx*5);
win2.rotation.y=Math.PI/2;scene.add(win2);
}
}
}
}
// Random rooftop equipment
if(h>35){
box(scene,Math.max(3,w*.2),2,Math.max(3,d*.2),material(0x555b66),x+3,h+1,z+4);
}
}
// Generate districts
for(let gx=-9;gx<=9;gx++){
for(let gz=-9;gz<=9;gz++){
const centerX=gx*block+50,centerZ=gz*block+50;
if(Math.abs(centerX)<30&&Math.abs(centerZ)<30)continue;
// NBA arena blocks will be reserved later
if(Math.abs(centerX-250)<70&&Math.abs(centerZ+100)<70)continue;
const n=1+Math.floor(Math.random()*3);
for(let k=0;k<n;k++){
const x=centerX+(Math.random()-.5)*42,z=centerZ+(Math.random()-.5)*42;
const w=20+Math.random()*28,d=20+Math.random()*28;
let h;
const dist=Math.hypot(x,z);
if(dist<230)h=70+Math.random()*190;
else if(dist<480)h=25+Math.random()*100;
else h=12+Math.random()*45;
addBuilding(x,z,w,d,h);
}
}
}
// Landmark skyscraper / towers
for(let i=0;i<12;i++){
const x=(Math.random()-.5)*350,z=(Math.random()-.5)*350;
const h=190+Math.random()*160,w=28+Math.random()*30;
addBuilding(x,z,w,w,h);
}
// Neon signs
function neonSign(x,y,z,textColor){
const light=new THREE.PointLight(textColor,35,70);
light.position.set(x,y,z);scene.add(light);
box(scene,4,.4,.2,material(textColor,.3,.1),x,y,z);
}
for(let i=0;i<100;i++){
neonSign((Math.random()-.5)*900,5+Math.random()*20,(Math.random()-.5)*900,
[0x00ddff,0xff2d8b,0xa64bff,0xffbb44][Math.floor(Math.random()*4)]);
}
// Streetlights
for(let x=-900;x<=900;x+=100){
for(let z=-900;z<=900;z+=100){
box(scene,.25,7,.25,material(0x555a65),x+13,3.5,z+13);
box(scene,2,.18,.18,material(0x555a65),x+14,6.9,z+13);
const lamp=new THREE.PointLight(0x80bfff,7,18);
lamp.position.set(x+14,6.8,z+13);scene.add(lamp);
}
}
// --------------------------------------------------
// NBA ARENA + BASKETBALL COURT
// --------------------------------------------------
function makeBasketballCourt(cx,cz){
// court surface
box(scene,52,.18,28,material(0x9a643d),cx,.15,cz);
// paint area
box(scene,18,.2,28,material(0xc88c59),cx,.25,cz);
// boundaries + center line
const white=material(0xf7f4e8);
box(scene,52,.06,.25,white,cx,.28,cz-14);
box(scene,52,.06,.25,white,cx,.28,cz+14);
box(scene,.25,.06,28,white,cx-26,.28,cz);
box(scene,.25,.06,28,white,cx+26,.28,cz);
box(scene,.2,.06,28,white,cx,.28,cz);
// hoop supports
for(const side of [-1,1]){
const x=cx+side*23;
box(scene,.4,5,.4,material(0x444444),x,2.6,cz);
box(scene,2,.15,.2,material(0xeeeeee),x-side*1,4.7,cz);
box(scene,.12,1.5,.1,material(0xffffff),x-side*2,4.2,cz);
const rim=new THREE.Mesh(new THREE.TorusGeometry(.65,.06,8,20),material(0xff5b21));
rim.rotation.x=Math.PI/2;rim.position.set(x-side*2,3.65,cz);scene.add(rim);
}
// court lighting
const l=new THREE.PointLight(0xffffff,30,100);
l.position.set(cx,22,cz);scene.add(l);
}
function makeArena(cx,cz){
const arena=box(scene,100,28,90,material(0x252b39),cx,14,cz);
// roof
box(scene,110,4,100,material(0x3b4050),cx,30,cz);
// glowing entrance
box(scene,26,8,1,material(0x00aaff),cx,5,cz+45);
// lettering-like neon bars
box(scene,45,1,.5,material(0xff2a88),cx,33,cz+20);
// basketball court outside
makeBasketballCourt(cx+135,cz+50);
makeBasketballCourt(cx-135,cz-50);
// Arena park / lot
for(let i=-3;i<=3;i++){
box(scene,8,.08,1,material(0xffffff),cx+i*12,0.1,cz+65);
}
}
makeArena(250,-100);
// --------------------------------------------------
// LANDMARKS
// --------------------------------------------------
const locations=[
{name:'NBA ARENA',x:250,z:-100,desc:'Vice Metro Basketball Arena'},
{name:'BEACHFRONT',x:-650,z:350,desc:'Ocean promenade & beach'},
{name:'AIRPORT',x:750,z:650,desc:'International Airport'},
{name:'CASINO',x:-300,z:-300,desc:'Neon Palace Casino'},
{name:'CAR DEALERSHIP',x:400,z:300,desc:'Luxury Motors'},
{name:'POLICE HQ',x:-250,z:150,desc:'Vice Metro Police'},
{name:'HOSPITAL',x:100,z:450,desc:'Central Medical'},
{name:'DOWNTOWN',x:0,z:0,desc:'Central skyscraper district'},
{name:'GARAGE',x:450,z:-450,desc:'Jason’s vehicle garage'},
{name:'OUTDOOR COURTS',x:250,z:80,desc:'Street basketball courts'}
];
function landmark(l,color=0xff33a6){
const base=new THREE.Mesh(new THREE.CylinderGeometry(8,10,1,16),material(0x272c37));
base.position.set(l.x,.5,l.z);scene.add(base);
const pin=new THREE.Mesh(new THREE.ConeGeometry(3,8,12),material(color));
pin.position.set(l.x,5,l.z);scene.add(pin);
}
locations.forEach((l,i)=>landmark(l,i===0?0x00eaff:0xff33a6));
// Beaches + waterfront
const water=new THREE.Mesh(new THREE.PlaneGeometry(600,900),new THREE.MeshStandardMaterial({
color:0x06334e,metalness:.5,roughness:.22
}));
water.rotation.x=-Math.PI/2;water.position.set(-850,0,-100);scene.add(water);
for(let i=0;i<80;i++){
const x=-650+Math.random()*350,z=-500+Math.random()*900;
box(scene,2,.15,2,material(0xe6d6a0),x,.12,z);
}
// --------------------------------------------------
// JASON CHARACTER
// --------------------------------------------------
const player=new THREE.Group();scene.add(player);
const skin=material(0xc78c67),jacket=material(0x222a38),pants=material(0x111725),shoes=material(0x090a0d);
box(player,.9,1.4,.5,jacket,0,1.65,0);
const head=new THREE.Mesh(new THREE.SphereGeometry(.31,16,16),skin);
head.position.y=2.55;player.add(head);
box(player,.35,.85,.38,pants,-.22,.65,0);
box(player,.35,.85,.38,pants,.22,.65,0);
box(player,.45,.2,.5,shoes,-.22,.12,.1);
box(player,.45,.2,.5,shoes,.22,.12,.1);
box(player,.24,.85,.25,jacket,-.6,1.6,0);
box(player,.24,.85,.25,jacket,.6,1.6,0);
// --------------------------------------------------
// CARS + TRAFFIC
// --------------------------------------------------
const carColors=[0xff174d,0x00baff,0xf1e6ce,0x20232c,0xff8a18,0x19ff9a,0x7d38ff,0xffffff];
function makeCar(color){
const g=new THREE.Group(),bodyMat=material(color,.3,.5);
box(g,2.2,.65,4.5,bodyMat,0,.65,0);
box(g,1.8,.65,2.1,material(0x132238,.2,.5),0,1.25,0);
box(g,2,.15,1.1,bodyMat,0,1.6,-1.2);
box(g,2,.15,1.1,bodyMat,0,1.6,1.2);
for(const x of [-1.15,1.15])for(const z of [-1.4,1.4]){
const w=new THREE.Mesh(new THREE.CylinderGeometry(.42,.42,.3,16),material(0x080808));
w.rotation.z=Math.PI/2;w.position.set(x,.45,z);g.add(w);
}
for(const x of [-.75,.75]){
box(g,.4,.18,.12,material(0xffffdc),x,.7,-2.25);
box(g,.4,.18,.12,material(0xff2020),x,.7,2.25);
}
return g;
}
const cars=[];
function spawnTraffic(){
const mesh=makeCar(carColors[Math.floor(Math.random()*carColors.length)]);
scene.add(mesh);
cars.push({mesh,traffic:true,t:Math.random()*500,route:Math.floor(Math.random()*10),speed:10+Math.random()*18});
}
for(let i=0;i<55;i++)spawnTraffic();
const playerCar=makeCar(0xff174d);playerCar.position.set(8,0,8);scene.add(playerCar);
const carObj={mesh:playerCar,traffic:false,speed:0};cars.push(carObj);
let driving=false,activeCar=null;
// Traffic paths: square loops around the blocks
function trafficPosition(t,route){
const size=120+route*55,loop=size*4;
t=((t%loop)+loop)%loop;
const side=Math.floor(t/size),f=(t%size)/size;
if(side===0)return[-size/2+f*size,-size/2];
if(side===1)return[size/2,-size/2+f*size];
if(side===2)return[size/2-f*size,size/2];
return[-size/2,size/2-f*size];
}
function updateTraffic(dt){
for(const c of cars){
if(!c.traffic)continue;
c.t+=c.speed*dt;
const [x,z]=trafficPosition(c.t,c.route);
const [nx,nz]=trafficPosition(c.t+1,c.route);
c.mesh.position.set(x,0,z);
c.mesh.rotation.y=Math.atan2(-(nx-x),-(nz-z));
}
}
// --------------------------------------------------
// MAP / GPS
// --------------------------------------------------
const mapUI=document.getElementById('mapUI');
const mapCanvas=document.getElementById('mapcanvas');
const ctx=mapCanvas.getContext('2d');
let mapOpen=false,selected=null,routeTarget=null;
let mapScale=1;
function worldToMap(x,z){
const W=mapCanvas.width,H=mapCanvas.height;
return {x:(x+1000)/2000*W,y:(z+1000)/2000*H};
}
function mapToWorld(px,py){
return {x:px/mapCanvas.width*2000-1000,z:py/mapCanvas.height*2000-1000};
}
function resizeMap(){
const r=mapCanvas.getBoundingClientRect();
mapCanvas.width=r.width*devicePixelRatio;
mapCanvas.height=r.height*devicePixelRatio;
ctx.setTransform(devicePixelRatio,0,0,devicePixelRatio,0,0);
drawMap();
}
function drawMap(){
if(!mapCanvas.width)return;
const W=mapCanvas.width/devicePixelRatio,H=mapCanvas.height/devicePixelRatio;
ctx.setTransform(devicePixelRatio,0,0,devicePixelRatio,0,0);
ctx.clearRect(0,0,W,H);
ctx.fillStyle='#0b121c';ctx.fillRect(0,0,W,H);
// Grid city blocks
const gridX=W/20,gridY=H/20;
for(let x=0;x<=W;x+=gridX){
for(let y=0;y<=H;y+=gridY){
ctx.fillStyle='#17212d';
ctx.fillRect(x+2,y+2,gridX-4,gridY-4);
}
}
// road lines
ctx.strokeStyle='#34404d';ctx.lineWidth=5;
for(let i=0;i<=20;i++){
let x=i*W/20,y=i*H/20;
ctx.beginPath();ctx.moveTo(x,0);ctx.lineTo(x,H);ctx.stroke();
ctx.beginPath();ctx.moveTo(0,y);ctx.lineTo(W,y);ctx.stroke();
}
// Waterfront
ctx.fillStyle='#06405d';ctx.fillRect(0,H*.25,W*.16,H*.5);
ctx.fillStyle='#0b6280';ctx.fillRect(0,H*.25,W*.02,H*.5);
// Landmark names and pins
for(const l of locations){
const p=worldToMap(l.x,l.z);
ctx.fillStyle=l.name==='NBA ARENA'?'#00eaff':'#ff3caa';
ctx.beginPath();ctx.arc(p.x,p.y,5,0,Math.PI*2);ctx.fill();
ctx.font='bold 11px Orbitron';
ctx.fillStyle='#d8e2ef';
ctx.fillText(l.name,p.x+8,p.y-8);
}
// Player marker
const pp=worldToMap(player.position.x,player.position.z);
ctx.fillStyle='#00ffbb';
ctx.beginPath();ctx.arc(pp.x,pp.y,7,0,Math.PI*2);ctx.fill();
ctx.strokeStyle='#00ffbb';ctx.lineWidth=2;ctx.stroke();
// route line
if(routeTarget){
const dest=worldToMap(routeTarget.x,routeTarget.z);
ctx.strokeStyle='#b04cff';ctx.lineWidth=5;
ctx.shadowColor='#a64bff';ctx.shadowBlur=12;
ctx.beginPath();ctx.moveTo(pp.x,pp.y);ctx.lineTo(dest.x,dest.y);ctx.stroke();
ctx.shadowBlur=0;
ctx.fillStyle='#bd73ff';
ctx.beginPath();ctx.arc(dest.x,dest.y,10,0,Math.PI*2);ctx.fill();
ctx.strokeStyle='#fff';ctx.lineWidth=2;ctx.stroke();
}
}
function setSelection(l){
selected=l;
document.getElementById('selectedName').textContent=l.name;
document.getElementById('selectedInfo').textContent=l.desc||'Custom waypoint';
drawMap();
}
function openMap(){
mapOpen=true;mapUI.style.display='block';
document.exitPointerLock?.();
resizeMap();
}
function closeMap(){
mapOpen=false;mapUI.style.display='none';
if(started)renderer.domElement.requestPointerLock?.();
}
function toggleMap(){
if(mapOpen)closeMap();else openMap();
}
document.getElementById('closemap').onclick=closeMap;
document.getElementById('go').onclick=()=>{
if(selected){
routeTarget={x:selected.x,z:selected.z,name:selected.name};
document.getElementById('routeName').textContent='GPS → '+selected.name;
document.getElementById('routehud').style.display='block';
showToast('GPS ROUTE SET');
drawMap();closeMap();
}
};
mapCanvas.addEventListener('click',e=>{
const r=mapCanvas.getBoundingClientRect();
const p=mapToWorld(e.clientX-r.left,e.clientY-r.top);
// snap click to nearest landmark if nearby
let closest=null,dist=45;
for(const l of locations){
const d=Math.hypot(l.x-p.x,l.z-p.z);
if(d<dist){closest=l;dist=d;}
}
setSelection(closest||{name:'CUSTOM WAYPOINT',x:p.x,z:p.z,desc:'Custom location'});
});
const placesDiv=document.getElementById('places');
for(const l of locations){
const b=document.createElement('button');
b.className='placebtn';b.textContent='⌖ '+l.name;
b.onclick=()=>setSelection(l);
placesDiv.appendChild(b);
}
// --------------------------------------------------
// CONTROLS
// --------------------------------------------------
const keys={};
let yaw=0,pitch=-.12,started=false;
addEventListener('keydown',e=>{
keys[e.key.toLowerCase()]=true;
if(e.code==='Space')e.preventDefault();
if(e.key.toLowerCase()==='l'&&started)toggleMap();
if(e.key==='Escape'&&mapOpen)closeMap();
});
addEventListener('keyup',e=>keys[e.key.toLowerCase()]=false);
document.addEventListener('mousemove',e=>{
if(document.pointerLockElement===renderer.domElement&&!mapOpen){
yaw-=e.movementX*.002;
pitch=Math.max(-.6,Math.min(.35,pitch-e.movementY*.002));
}
});
document.getElementById('start').onclick=()=>{
started=true;document.getElementById('start').style.display='none';
renderer.domElement.requestPointerLock?.();
showToast('WELCOME TO VICE METRO');
};
function nearestCar(){
let best=null,distance=999;
for(const c of cars){
if(c.traffic)continue;
const d=player.position.distanceTo(c.mesh.position);
if(d<distance){distance=d;best=c;}
}
return distance<9?best:null;
}
addEventListener('keydown',e=>{
if(e.key.toLowerCase()==='e'&&started&&!mapOpen){
if(!driving){
const c=nearestCar();
if(c){driving=true;activeCar=c;player.visible=false;showToast('VEHICLE ENTERED');}
}else{
driving=false;player.visible=true;
player.position.copy(activeCar.mesh.position);
player.position.x+=3;player.position.y=0;
showToast('EXITED VEHICLE');
}
}
});
let toastTimer;
function showToast(s){
const el=document.getElementById('toast');
el.textContent=s;el.style.opacity=1;
clearTimeout(toastTimer);toastTimer=setTimeout(()=>el.style.opacity=0,2000);
}
// --------------------------------------------------
// GAME UPDATE / CAMERA / GPS
// --------------------------------------------------
let speedDisplay=0,verticalVelocity=0,onGround=true;
const clock=new THREE.Clock();
const cameraTarget=new THREE.Vector3();
function updatePlayer(dt){
if(driving){
const c=activeCar.mesh;
const throttle=(keys.w?1:0)-(keys.s?1:0);
const steer=(keys.a?1:0)-(keys.d?1:0);
activeCar.speed+=throttle*28*dt;
activeCar.speed*=Math.pow(.987,dt*60);
activeCar.speed=Math.max(-15,Math.min(55,activeCar.speed));
c.rotation.y+=steer*dt*activeCar.speed*.035;
const f=new THREE.Vector3(0,0,-1).applyQuaternion(c.quaternion);
c.position.addScaledVector(f,activeCar.speed*dt);
speedDisplay=Math.abs(activeCar.speed)*3.6;
}else{
let f=(keys.w?1:0)-(keys.s?1:0);
let s=(keys.d?1:0)-(keys.a?1:0);
const forward=new THREE.Vector3(-Math.sin(yaw),0,-Math.cos(yaw));
const right=new THREE.Vector3(Math.cos(yaw),0,-Math.sin(yaw));
const move=new THREE.Vector3().addScaledVector(forward,f).addScaledVector(right,s);
if(move.length()>0)move.normalize();
const sp=keys.shift?13:7;
player.position.addScaledVector(move,sp*dt);
if(move.length()>0)player.rotation.y=Math.atan2(move.x,move.z);
if(keys.space&&onGround){verticalVelocity=8;onGround=false;}
verticalVelocity-=20*dt;player.position.y+=verticalVelocity*dt;
if(player.position.y<0){player.position.y=0;verticalVelocity=0;onGround=true;}
speedDisplay=move.length()*sp*3.6;
}
}
function updateCamera(dt){
const target=driving?activeCar.mesh.position:player.position;
const distance=driving?11:7.5,height=driving?5:3.4;
const off=new THREE.Vector3(Math.sin(yaw)*distance,height+pitch*4,Math.cos(yaw)*distance);
camera.position.lerp(new THREE.Vector3(target.x+off.x,target.y+off.y,target.z+off.z),1-Math.pow(.001,dt));
cameraTarget.set(target.x,target.y+(driving?1.5:1.8),target.z);
camera.lookAt(cameraTarget);
}
function updateGPS(){
if(!routeTarget)return;
const pos=driving?activeCar.mesh.position:player.position;
const dist=Math.hypot(routeTarget.x-pos.x,routeTarget.z-pos.z);
document.getElementById('routeDistance').textContent=Math.round(dist)+' METERS TO DESTINATION';
if(dist<15){showToast('DESTINATION REACHED');routeTarget=null;document.getElementById('routehud').style.display='none';}
}
function updateHUD(){
document.getElementById('speed').innerHTML=`${String(Math.round(speedDisplay)).padStart(3,'0')} <small>KM/H</small>`;
document.getElementById('prompt').style.display=(!driving&&nearestCar()&&!mapOpen)?'block':'none';
document.getElementById('controls').innerHTML=driving?
'W ACCELERATE · S BRAKE · A/D STEER · E EXIT · L MAP':
'WASD MOVE · SHIFT SPRINT · SPACE JUMP · E CAR · L MAP';
}
function animate(){
requestAnimationFrame(animate);
const dt=Math.min(clock.getDelta(),.04);
if(started&&!mapOpen){
updatePlayer(dt);updateTraffic(dt);updateCamera(dt);updateHUD();updateGPS();
}
if(mapOpen)drawMap();
renderer.render(scene,camera);
}
animate();
addEventListener('resize',()=>{
camera.aspect=innerWidth/innerHeight;camera.updateProjectionMatrix();
renderer.setSize(innerWidth,innerHeight);
if(mapOpen)resizeMap();
});
</script>
</body>
</html>
Game Source: NEON OVERDRIVE — Open World
Creator: GlitchPanther20
Libraries: three
Complexity: complex (624 lines, 24.3 KB)
The full source code is displayed above on this page.
Remix Instructions
To remix this game, copy the source code above and modify it. Add a ARCADELAB header at the top with "remix_of: neon-overdrive-open-world-glitchpanther20" to link back to the original. Then publish at arcadelab.ai/publish.