⭐ Built in the Agent OS — get it inside the AI Profit BoardroomJoin AIPB →0;for(var q=0;q=3)banner('KILL STREAK x'+S.streak,'#ffd martial'.slice(0,7)==='#ffd ma'?'#ffd23f':'#ffd23f');
pulseScore();
S.hitFlash=1;
scene.remove(en.g);scene.remove(en.disc);
}
/* ============================ HERO UPDATE ============================ */
function updateHero(dt){
var boosting=(keys.ShiftLeft||keys.ShiftRight)&&S.boost>1;
var target=56;
if(keys.KeyW||keys.ArrowUp)target=82;
if(keys.KeyS||keys.ArrowDown)target=34;
if(boosting){target+=32;S.boost=Math.max(0,S.boost-32*dt);}
else S.boost=Math.min(100,S.boost+13*dt);
S.speed+=(target-S.speed)*Math.min(1,2.2*dt);
var sx=0;
if(keys.KeyA||keys.ArrowLeft)sx-=1;
if(keys.KeyD||keys.ArrowRight)sx+=1;
S.strafe+=(sx-S.strafe)*Math.min(1,7*dt);
hero.position.x+=S.strafe*30*dt;
hero.position.z+=S.speed*dt;
// wall grind
var lim=TRACK_HALF-3.2;
if(Math.abs(hero.position.x)>lim){
hero.position.x=Math.sign(hero.position.x)*lim;
S.hp-=14*dt;S.shake=Math.min(S.shake+0.5*dt,0.5);
if(S.hp<=0)damagePlayer(0.1,0xff2f9e);
emit(hero.position.x,hero.position.y,hero.position.z,-Math.sign(hero.position.x)*8,(Math.random())*6,-10,
0xff6ad0,0.5,2.2,0.4);
}
var t=performance.now()*0.001;
hero.position.y=2.4+Math.sin(t*2.1)*0.16;
S.lean+=((-S.strafe*0.42)-S.lean)*Math.min(1,6*dt);
hero.rotation.z=S.lean;
hero.rotation.y=S.strafe*0.13;
hero.rotation.x=Math.sin(t*1.6)*0.02-(S.speed-56)*0.0016;
// engine flare scaling + vapor trails
var ef=0.9+(S.speed-34)/48*1.5+(boosting?0.9:0);
hero.userData.glow[0].scale.set(0.52*ef,0.34+0.3*ef,0.52*ef);
hero.userData.glow[1].scale.copy(hero.userData.glow[0].scale);
hero.userData.engineLight.intensity=1.2+ef*0.7;
hero.userData.ringL.rotation.z+=dt*5;hero.userData.ringR.rotation.z-=dt*5;
var n=boosting?3:2;
for(var j=0;j0.35){
var wx=-Math.sign(S.strafe)*4.9;
tmpA.set(wx,1.2,-0.7).applyQuaternion(hero.quaternion).add(hero.position);
emit(tmpA.x,tmpA.y,tmpA.z,0,0.4,-S.speed*0.2,0xbff6ff,0.4,3.0,0.45,0.4);
}
S.fireCd-=dt;
if((mouse.down||keys.Space)&&S.fireCd<=0){S.fireCd=0.11;playerFire();}
muzzle.intensity*=Math.pow(0.0006,dt);
S.score+=S.speed*dt*0.55;
var sector=Math.floor(hero.position.z/1200)+1;
if(sector>S.nextSector){S.nextSector=sector;banner('SECTOR '+sector+' — HOSTILES RISING','#2fff9a');}
if(S.streakT>0){S.streakT-=dt;if(S.streakT<=0)S.streak=0;}
heroShadow.position.set(hero.position.x,0.06,hero.position.z-0.6);
heroShadow.material.opacity=0.4-(hero.position.y-2.4)*0.05;
}
/* ============================ ENEMY UPDATE ============================ */
function updateEnemies(dt){
var difficulty=Math.min(1,hero.position.z/6000);
for(var i=enemies.length-1;i>=0;i--){
var en=enemies[i],g=en.g;
tmpA.copy(hero.position).sub(g.position);
var dist=tmpA.length();
tmpA.normalize();
var sp=en.t.spd*(1+difficulty*0.35)+S.speed*0.62;
if(g.position.z-hero.position.z>50)sp=S.speed*0.55;
tmpA.multiplyScalar(sp);
en.vel.lerp(tmpA,Math.min(1,en.t.turn*dt));
g.position.addScaledVector(en.vel,dt);
en.bob+=dt*2.4;
g.position.y=Math.max(1.9,g.position.y+Math.sin(en.bob)*dt*2.2);
g.lookAt(hero.position.x,hero.position.y,hero.position.z);
if(en.t.name==='SENTINEL'){
g.userData.spin.rotation.z+=dt*2.2;
g.userData.spin2.rotation.z-=dt*1.4;
g.rotation.z+=Math.sin(en.bob)*0.1;
}else{
g.rotation.z=Math.sin(en.bob*0.7)*0.28;
}
// engine vapor
if(Math.random()<0.7){
tmpB.copy(g.userData.jet).applyQuaternion(g.quaternion).add(g.position);
emit(tmpB.x,tmpB.y,tmpB.z,(Math.random()-.5)*2,(Math.random()-.5)*2,-8,
en.t.name==='SENTINEL'?0xff8a1e:(en.t.name==='RAM SLED'?0xff2fd0:0xff4a2a),
0.5,2.4,0.4,0.5);
}
// telegraph + fire
en.cd-=dt;
if(en.cd<0.45&&en.cd>0&&dist<130){
en.charge=1-(en.cd/0.45);
g.userData.core.emissiveIntensity=2.6+Math.sin(performance.now()*0.05)*2.2*en.charge;
g.scale.setScalar(en.t.scale*(1+en.charge*0.07));
}
if(en.cd<=0){
en.charge=0;g.scale.setScalar(en.t.scale);
g.userData.core.emissiveIntensity=2.6;
en.cd=en.t.fire*(1.4-difficulty*0.5)+Math.random()*0.6;
if(dist<135){
tmpB.copy(hero.position);
tmpB.z+=S.speed*(dist/95)*0.55;
tmpB.sub(g.position).normalize();
tmpC.copy(g.position).addScaledVector(tmpB,2.4);
fireBolt(tmpC,tmpB,86,0xff5a2a,true,9,1.2);
burst(tmpC.x,tmpC.y,tmpC.z,0xffa03a,4,6,0.4);
}
}
// hit flash decay
if(en.flash>0){
en.flash-=dt*4;
var f=Math.max(0,en.flash);
en.g.userData.body[0].emissive.setRGB(f,f*0.8,f*0.7);
en.g.userData.body[0].emissiveIntensity=0.35+f*3;
en.g.userData.core.emissiveIntensity=2.6+f*4;
}
// ram collision
if(disthero.position.z+340){
scene.remove(g);scene.remove(en.disc);enemies.splice(i,1);
}
}
var want=7+Math.floor(difficulty*4);
while(enemies.length=0;j--){
var en=enemies[j];
closestOnSeg(b.prev,b.m.position,en.g.position,segPt);
if(segPt.distanceTo(en.g.position)0.001){
camera.position.x+=(Math.random()-.5)*S.shake*1.5;
camera.position.y+=(Math.random()-.5)*S.shake*1.2;
S.shake*=Math.pow(0.02,dt);
}
lookGoal.set(
hero.position.x+(mouse.x-0.5)*26,
hero.position.y+2.2-(mouse.y-0.45)*16,
hero.position.z+30
);
lookAt.lerp(lookGoal,Math.min(1,6*dt));
camera.lookAt(lookAt);
camera.rotation.z+=S.lean*0.22;
var fovGoal=70+(S.speed-56)*0.22;
camera.fov+=(fovGoal-camera.fov)*Math.min(1,4*dt);
camera.updateProjectionMatrix();
}
/* ============================ HUD ============================ */
function pad(n,w){var s=String(Math.max(0,Math.round(n)));while(s.length1-(enemies[i].t.r*0.55/Math.max(12,d))){hot=true;break;}
}
if(hot)UI.cross.classList.add('hot');else UI.cross.classList.remove('hot');
if(S.dmgFlash>0){S.dmgFlash-=dt*2.4;UI.flash.style.opacity=Math.max(0,S.dmgFlash*0.85);}
else UI.flash.style.opacity=0;
if(S.hitFlash>0){S.hitFlash-=dt*3.5;UI.hitmark.style.opacity=Math.max(0,S.hitFlash*0.5);}
else{var o=parseFloat(UI.hitmark.style.opacity)||0;if(o>0)UI.hitmark.style.opacity=Math.max(0,o-dt*3);}
if(bannerT>0){bannerT-=dt;if(bannerT<=0)UI.banner.style.opacity=0;}
drawRadar();
}
function drawRadar(){
var w=UI.radar.width,h=UI.radar.height;
rctx.clearRect(0,0,w,h);
rctx.fillStyle='rgba(4,12,30,0.5)';rctx.fillRect(0,0,w,h);
var z0=hero.position.z-25,z1=hero.position.z+170;
function mx(x){return (x+34)/68*w;}
function mz(z){return h-((z-z0)/(z1-z0))*h;}
rctx.strokeStyle='rgba(90,235,255,0.35)';rctx.lineWidth=2;
rctx.beginPath();rctx.moveTo(mx(-TRACK_HALF),0);rctx.lineTo(mx(-TRACK_HALF),h);
rctx.moveTo(mx(TRACK_HALF),0);rctx.lineTo(mx(TRACK_HALF),h);rctx.stroke();
rctx.strokeStyle='rgba(140,90,255,0.28)';rctx.lineWidth=1;
for(var g2=0;g2<5;g2++){
var zz=Math.ceil(z0/40)*40+g2*40;
var y=mz(zz);rctx.beginPath();rctx.moveTo(0,y);rctx.lineTo(w,y);rctx.stroke();
}
for(var i=0;iz1)continue;
rctx.fillStyle='#ffd23f';rctx.beginPath();rctx.arc(mx(pp.x),mz(pp.z),4,0,6.283);rctx.fill();
}
for(var e=0;ez1)continue;
rctx.fillStyle=enemies[e].t.name==='SENTINEL'?'#ff9a2a':'#ff3b4a';
rctx.beginPath();rctx.arc(mx(ep.x),mz(ep.z),5,0,6.283);rctx.fill();
}
rctx.fillStyle='#7dfaff';
var px=mx(hero.position.x),py=mz(hero.position.z);
rctx.beginPath();rctx.moveTo(px,py-9);rctx.lineTo(px-6,py+6);rctx.lineTo(px+6,py+6);rctx.closePath();rctx.fill();
}
/* ============================ LOOP ============================ */
var clock=new T.Clock();
function animate(){
requestAnimationFrame(animate);
var dt=Math.min(clock.getDelta(),0.05);
if(!S.dead){
updateHero(dt);
updateEnemies(dt);
updateBolts(dt);
updatePickups(dt);
}else{
updateBolts(dt);
S.speed*=Math.pow(0.25,dt);
hero.position.z+=S.speed*dt;
hero.rotation.z+=dt*1.2;
hero.position.y=Math.max(0.6,hero.position.y-dt*3.2);
if(Math.random()<0.4)burst(hero.position.x,hero.position.y,hero.position.z,0xff6a2a,2,7,0.7);
}
updateWorld();
updateParts(dt);
updateCamera(dt);
updateHUD(dt);
renderer.render(scene,camera);
}
window.addEventListener('resize',function(){
camera.aspect=window.innerWidth/window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth,window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio,2));
},false);
UI.over.addEventListener('click',function(){reset();},false);
reset();
animate();
})();