27:18Gemini 4 Hydrogen: Cheaper Tokens, More Expensive Answers?
Nov 13, 2026 · YouTube
18:40ERNIE 5.5 Flash Preview vs GLM 5.3 Flash: Baidu's new model is very impressive!
Nov 11, 2026 · YouTube
36:22Fable 5.2 robbing me blind, plus: Nex AGI's N2.6 vs GLM 5.3 Flash
Nov 11, 2026 · YouTube
14:03Gemini 4 Carbon: Can it handle my challenges? (First look with one-shot coding tests)
Nov 10, 2026 · YouTube
47:51Ranking major U.S. Open-Weights Models. (Where does Ripple 65B fit in?)
Nov 6, 2026 · YouTube
10:57"Crouton Alpha": the latest super-efficient coding model by Meta?
Nov 3, 2026 · YouTube
38:58Testing Particle-1: a post-trained DeepSeek V4.1 Flash specializing in coding and efficiency
Oct 28, 2026 · YouTube
22:14GPT-6.1 Terra Pro vs Terra: How Much Better Is Pro?
Oct 27, 2026 · YouTube
29:55Kimi K3.1 Pro Looked Incredible. Then I Kept Testing.
Oct 26, 2026 · YouTube
31:28Is this company reselling GPT Sol 6.1 at a loss (for non-agentic/text-only)?🤔 Is this sustainable?
Oct 20, 2026 · YouTube
17:58Nemotron 3.5 Super VL vs Opus 5.5: Testing NVIDIA’s new coding juggernaut
Oct 15, 2026 · YouTube
16:04Testing a *massive* new open-weights model 🤯: Muse Spark Open (vs. Nemotron, Opus 5.5, and more)
Oct 15, 2026 · YouTube
16:43Gemini 4 Argon: Great 🐈 Animation, but a broken escalator. (Coding challenge vs Opus 5.5, Sol 6.1)
Oct 13, 2026 · YouTube
16:37Meta's new "Muse Wonder" AI is impressive... but can it compete with Anthropic's models?
Oct 12, 2026 · YouTube
11:12WOW... Haiku 5.5 is very impressive. RIP OpenAI?
Oct 7, 2026 · YouTube
22:47Mistral Large 4 Is Cheap. But Is It Good Enough to Compete?
Oct 6, 2026 · YouTube
22:02Is Pareto 26.10 Preview Just Routing to GPT Sol? I Tested It Against Sol 6.1 Pro
Oct 1, 2026 · YouTube
11:22I Tested Sonnet 5.5 Against Opus 5.5. Is It Actually Cheaper?
Sep 28, 2026 · YouTube
30:00Did Elon Musk's team "train the gay away"... and make Grok 4.7 worse?
Sep 26, 2026 · YouTube
10:58So... how much better is Claude Opus 5.5 vs. GPT-6 Sol, really?
Sep 23, 2026 · YouTube
9:38Claude Opus 5.5... the BEST new model for coding!! 🤩
Sep 22, 2026 · YouTube
29:00Grok 4.7: improved, but GLM 5.3 FlashX beat it anyway (benchmark against Gemini, Sol, etc.)
Sep 22, 2026 · YouTube
16:54Stealth Union Alpha: Is this another cheap GPT model? (better than Luna, cheaper than Terra?)
Sep 16, 2026 · YouTube
16:45DeepSeek V4.1 Flash Is Shockingly Good for the Price
Sep 10, 2026 · YouTube
17:14How much better is GPT-6 Astra over Claude Opus 5? Real Website and Coding Tests
Sep 5, 2026 · YouTube
29:13Implementing a multiplayer game with GPT-6 Astra (+ Gemini 3.8, Opus 5, Sol Pro)
Sep 5, 2026 · YouTube
19:42Meta Muse Spark 1.3 Review: A Huge Leap Forward
Sep 2, 2026 · YouTube
17:31Testing Gemini 3.8 Flash on Real Coding Challenges (vs. other models)
Sep 2, 2026 · YouTube
19:45Fable 5.1 writes an animated novel using Ren'Py... did it do better than Sol Pro 5.6?
Sep 1, 2026 · YouTube
14:09Testing IBM Granite-4.2-8B! Can it name 100 women?
Aug 31, 2026 · YouTube
17:37Tencent Hy4 Preview Tested: Is It Really Better Than Kimi K3 and GLM 5.3?
Aug 28, 2026 · YouTube
23:58Qwen 3.8 Flash Tested: UI, Coding, Physics & more - compared to Opus 5, Sol Pro, Grok
Aug 27, 2026 · YouTube
You are a game developer who ships browser demos that have to work on the first click, in front of an audience, on someone else's laptop.
Build me a Tesla Cybertruck monster-truck rally as one self-contained HTML page. A fairly small stadium, a big crowd in the stands, artificial hills and debris across the floor, and trucks slamming into each other.
Then make it match the spec below exactly. The spec is the challenge; a great-looking rally that ignores it is a miss.
.html page. No build step. Saved to disk and double-clicked, it runs.localStorage, sessionStorage, cookies or indexedDB. It runs in a sandboxed frame where touching them throws.Both are checkable in ten seconds, which is why they are here.
#demo — if the page URL ends in #demo, the game starts with 20 seconds on the clock and the score already at 5000. This must run through the real game state, not a cosmetic overlay. Everything else behaves normally.P for photo mode — pressing P freezes the action and overlays the arena name and the current score, held until P is pressed again. The simulation stops; it does not keep playing behind the card.One sentence: the name of your rally and what it looks like.
Exactly one fenced html block containing the whole page and nothing else.
Exactly four bullets.
#demo sets, and why it is not an overlay.P is pressed — the render loop, the physics step, or both.Cyber Slam Colosseum is a packed, neon-lit arena where angular Cybertrucks tear across dirt mounds, tire piles, and boulders while four AI rivals hunt for the same slam score.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" href="data:,">
<title>Cyber Slam Colosseum</title>
<style>
html, body {
margin: 0;
height: 100%;
overflow: hidden;
background: #000;
font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
#hud {
position: fixed;
top: 0;
left: 0;
right: 0;
padding: 12px 18px;
display: flex;
justify-content: space-between;
align-items: flex-start;
pointer-events: none;
color: white;
background: linear-gradient(rgba(0,0,0,0.7), transparent);
z-index: 10;
}
#arenaName {
font-size: 18px;
font-weight: 900;
letter-spacing: 0.14em;
}
#status {
margin-top: 6px;
font-size: 16px;
font-weight: 700;
color: #ffd966;
min-height: 1.2em;
}
.hud-right {
text-align: right;
}
#score {
font-size: 30px;
font-weight: 900;
letter-spacing: 0.04em;
color: #fff;
}
#clock {
font-size: 22px;
font-weight: 700;
color: #cfd8ff;
}
#controls {
position: fixed;
bottom: 10px;
left: 50%;
transform: translateX(-50%);
color: #eee;
background: rgba(0,0,0,0.55);
padding: 6px 14px;
border-radius: 20px;
font-size: 13px;
letter-spacing: 0.03em;
z-index: 10;
white-space: nowrap;
}
#photo {
position: fixed;
inset: 0;
display: none;
align-items: center;
justify-content: center;
background: rgba(0,0,0,0.78);
color: white;
text-align: center;
z-index: 20;
}
#photo.show {
display: flex;
}
#photo .title {
font-size: 54px;
font-weight: 900;
letter-spacing: 0.18em;
color: #ffd966;
}
#photo .score {
font-size: 32px;
margin-top: 18px;
font-weight: 700;
}
#photo .hint {
margin-top: 12px;
font-size: 14px;
opacity: 0.6;
}
</style>
</head>
<body>
<div id="hud">
<div class="hud-left">
<div id="arenaName">CYBER SLAM COLOSSEUM</div>
<div id="status"></div>
</div>
<div class="hud-right">
<div id="score">0</div>
<div id="clock">TIME 01:30</div>
</div>
</div>
<div id="controls">WASD / ARROW KEYS — DRIVE P — PHOTO</div>
<div id="photo">
<div>
<div class="title">CYBER SLAM COLOSSEUM</div>
<div class="score" id="photoScore">SCORE 0</div>
<div class="hint">PHOTO MODE — PRESS P TO RESUME</div>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
<script>
(function () {
"use strict";
function clamp(v, a, b) { return v < a ? a : (v > b ? b : v); }
function normAngle(a) {
while (a > Math.PI) a -= Math.PI * 2;
while (a < -Math.PI) a += Math.PI * 2;
return a;
}
function fmtTime(t) {
if (t < 0) t = 0;
const m = Math.floor(t / 60);
const s = Math.floor(t % 60);
return (m < 10 ? "0" : "") + m + ":" + (s < 10 ? "0" : "") + s;
}
const hudScore = document.getElementById("score");
const hudTime = document.getElementById("clock");
const hudStatus = document.getElementById("status");
const photoEl = document.getElementById("photo");
const photoScore = document.getElementById("photoScore");
const DEMO = location.hash === "#demo";
let score = DEMO ? 5000 : 0;
let timeLeft = DEMO ? 20 : 90;
let gameOver = false;
let photoMode = false;
let shake = 0;
let statusMessage = "";
let statusTimer = 0;
const keys = {};
// ---- floor texture ----------------------------------------------------
const floorCanvas = document.createElement("canvas");
floorCanvas.width = 512;
floorCanvas.height = 512;
const fctx = floorCanvas.getContext("2d");
fctx.fillStyle = "#3b2e1c";
fctx.fillRect(0, 0, 512, 512);
for (let i = 0; i < 1600; i++) {
fctx.fillStyle = "rgba(" +
(25 + Math.random() * 70) + "," +
(18 + Math.random() * 50) + "," +
(8 + Math.random() * 30) + ",0.55)";
fctx.fillRect(Math.random() * 512, Math.random() * 512, 1 + Math.random() * 5, 1 + Math.random() * 4);
}
fctx.strokeStyle = "rgba(255,255,255,0.05)";
fctx.lineWidth = 18;
for (let y = -6; y <= 6; y++) {
fctx.beginPath();
fctx.moveTo(0, y * 85 + 256);
fctx.lineTo(512, y * 85 + 256);
fctx.stroke();
}
const floorTex = new THREE.CanvasTexture(floorCanvas);
floorTex.wrapS = floorTex.wrapT = THREE.RepeatWrapping;
floorTex.repeat.set(6, 4);
// ---- renderer / scene -------------------------------------------------
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x0c1422);
scene.fog = new THREE.Fog(0x0c1422, 90, 180);
const camera = new THREE.PerspectiveCamera(65, window.innerWidth / window.innerHeight, 0.1, 250);
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
document.body.appendChild(renderer.domElement);
scene.add(new THREE.HemisphereLight(0xcfe0ff, 0x3a2a1a, 0.9));
const sun = new THREE.DirectionalLight(0xffeedd, 1.15);
sun.position.set(25, 45, 18);
sun.castShadow = true;
sun.shadow.mapSize.set(1024, 1024);
sun.shadow.camera.left = -55;
sun.shadow.camera.right = 55;
sun.shadow.camera.top = 55;
sun.shadow.camera.bottom = -55;
sun.shadow.camera.far = 130;
scene.add(sun);
scene.add(new THREE.AmbientLight(0x404080, 0.35));
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(120, 80),
new THREE.MeshLambertMaterial({ map: floorTex })
);
ground.rotation.x = -Math.PI / 2;
ground.receiveShadow = true;
scene.add(ground);
// ---- stadium shell ----------------------------------------------------
const standMat = new THREE.MeshLambertMaterial({ color: 0x202638 });
const wallMat = new THREE.MeshLambertMaterial({ color: 0x617a8a });
function addBox(w, h, d, x, y, z, ry, mat) {
const m = new THREE.Mesh(new THREE.BoxGeometry(w, h, d), mat || standMat);
m.position.set(x, y, z);
m.rotation.y = ry || 0;
m.castShadow = true;
m.receiveShadow = true;
scene.add(m);
return m;
}
// inner barriers
addBox(64, 1.6, 1, 0, 0.8, 20, wallMat);
addBox(64, 1.6, 1, 0, 0.8, -20, wallMat);
addBox(1, 1.6, 44, 30, 0.8, 0, wallMat);
addBox(1, 1.6, 44, -30, 0.8, 0, wallMat);
// stands
addBox(96, 5, 10, 0, 2.5, 30);
addBox(96, 5, 10, 0, 2.5, -30);
addBox(10, 5, 72, 34, 2.5, 0);
addBox(10, 5, 72, -34, 2.5, 0);
addBox(96, 8, 1, 0, 4, 36);
addBox(96, 8, 1, 0, 4, -36);
addBox(1, 8, 76, 40, 4, 0);
addBox(1, 8, 76, -40, 4, 0);
// ---- crowd ------------------------------------------------------------
function addCrowd() {
const COUNT = 1600;
const bodyGeo = new THREE.BoxGeometry(0.55, 1.1, 0.4);
const headGeo = new THREE.SphereGeometry(0.22, 6, 5);
const bodyMat = new THREE.MeshLambertMaterial({ color: 0xffffff });
const headMat = new THREE.MeshLambertMaterial({ color: 0xffffff });
const bodies = new THREE.InstancedMesh(bodyGeo, bodyMat, COUNT);
const heads = new THREE.InstancedMesh(headGeo, headMat, COUNT);
const dummy = new THREE.Object3D();
const col = new THREE.Color();
let i = 0;
function place(x, y, z) {
dummy.position.set(x, y, z);
dummy.rotation.set(0, Math.random() * Math.PI * 2, 0);
dummy.scale.set(1, 0.9 + Math.random() * 0.3, 1);
dummy.updateMatrix();
bodies.setMatrixAt(i, dummy.matrix);
if (bodies.setColorAt) {
bodies.setColorAt(i, col.setHSL(Math.random(), 0.55, 0.35 + Math.random() * 0.35));
}
dummy.position.y += 1.0;
dummy.updateMatrix();
heads.setMatrixAt(i, dummy.matrix);
if (heads.setColorAt) {
heads.setColorAt(i, col.setHSL(0.05, 0.6, 0.55 + Math.random() * 0.25));
}
i++;
}
for (let j = 0; j < 400; j++) place((Math.random() - 0.5) * 90, 5.1 + Math.random() * 0.4, 26 + Math.random() * 8);
for (let j = 0; j < 400; j++) place((Math.random() - 0.5) * 90, 5.1 + Math.random() * 0.4, -34 + Math.random() * 8);
for (let j = 0; j < 400; j++) place(30 + Math.random() * 8, 5.1 + Math.random() * 0.4, (Math.random() - 0.5) * 72);
for (let j = 0; j < 400; j++) place(-38 + Math.random() * 8, 5.1 + Math.random() * 0.4, (Math.random() - 0.5) * 72);
bodies.instanceMatrix.needsUpdate = true;
heads.instanceMatrix.needsUpdate = true;
if (bodies.instanceColor) bodies.instanceColor.needsUpdate = true;
if (heads.instanceColor) heads.instanceColor.needsUpdate = true;
scene.add(bodies);
scene.add(heads);
}
addCrowd();
// path guide line
const trackPts = [];
for (let i = 0; i < 72; i++) {
const a = i / 72 * Math.PI * 2;
trackPts.push(new THREE.Vector3(20 * Math.cos(a), 0.05, 12 * Math.sin(a)));
}
const trackLine = new THREE.LineLoop(
new THREE.BufferGeometry().setFromPoints(trackPts),
new THREE.LineBasicMaterial({ color: 0x334455, transparent: true, opacity: 0.35 })
);
scene.add(trackLine);
// ---- obstacles --------------------------------------------------------
const obstacles = [];
function addObstacle(type, x, z) {
const g = new THREE.Group();
let radius = 2;
if (type === "mound") {
const mound = new THREE.Mesh(
new THREE.SphereGeometry(2.6, 10, 8),
new THREE.MeshLambertMaterial({ color: 0x68482a })
);
mound.scale.y = 0.55;
mound.position.y = 1.2;
mound.castShadow = true;
mound.receiveShadow = true;
g.add(mound);
const base = new THREE.Mesh(
new THREE.CircleGeometry(2.9, 12),
new THREE.MeshLambertMaterial({ color: 0x374d2a })
);
base.rotation.x = -Math.PI / 2;
base.position.y = 0.05;
g.add(base);
radius = 2.9;
} else if (type === "tires") {
const tireMat = new THREE.MeshLambertMaterial({ color: 0x181818 });
const rimMat = new THREE.MeshLambertMaterial({ color: 0x555555 });
for (let i = 0; i < 4; i++) {
const tire = new THREE.Mesh(new THREE.TorusGeometry(1.0, 0.35, 8, 16), tireMat);
tire.rotation.x = Math.PI / 2;
tire.position.y = 0.5 + i * 0.8;
tire.castShadow = true;
g.add(tire);
const rim = new THREE.Mesh(new THREE.TorusGeometry(0.45, 0.08, 6, 12), rimMat);
rim.rotation.x = Math.PI / 2;
rim.position.y = 0.5 + i * 0.8;
g.add(rim);
}
radius = 2.0;
} else if (type === "rock") {
const rock = new THREE.Mesh(
new THREE.DodecahedronGeometry(1.7, 0),
new THREE.MeshLambertMaterial({ color: 0x777f85 })
);
rock.position.y = 1.0;
rock.rotation.set(Math.random(), Math.random(), Math.random());
rock.castShadow = rock.receiveShadow = true;
g.add(rock);
const rock2 = new THREE.Mesh(
new THREE.DodecahedronGeometry(1.0, 0),
new THREE.MeshLambertMaterial({ color: 0x666d73 })
);
rock2.position.set(1.2, 0.6, -0.8);
rock2.rotation.set(Math.random(), Math.random(), Math.random());
rock2.castShadow = true;
g.add(rock2);
radius = 2.1;
} else if (type === "barrier") {
const concrete = new THREE.Mesh(
new THREE.BoxGeometry(2.2, 1.2, 1.2),
new THREE.MeshLambertMaterial({ color: 0x9aa0a8 })
);
concrete.position.y = 0.6;
concrete.castShadow = concrete.receiveShadow = true;
g.add(concrete);
const stripeMat = new THREE.MeshLambertMaterial({ color: 0xe8a020 });
for (let i = 0; i < 4; i++) {
const stripe = new THREE.Mesh(new THREE.BoxGeometry(0.35, 0.5, 1.22), stripeMat);
stripe.position.set(-1.1 + i * 0.73, 0.9, 0);
g.add(stripe);
}
radius = 1.9;
}
g.position.set(x, 0, z);
scene.add(g);
obstacles.push({ type: type, x: x, z: z, radius: radius, group: g });
}
addObstacle("mound", 0, 0);
addObstacle("rock", -6, 0);
addObstacle("tires", 6, 0);
addObstacle("barrier", 0, 6);
addObstacle("rock", 0, -6);
addObstacle("mound", -5, 5);
addObstacle("tires", 5, -5);
addObstacle("barrier", -5, -5);
addObstacle("rock", -22, 12);
addObstacle("tires", 22, 12);
addObstacle("mound", -22, -12);
addObstacle("barrier", 22, -12);
// ---- trucks -----------------------------------------------------------
let trucks = [];
function makeTruck(isPlayer, bodyHex, accentHex) {
const group = new THREE.Group();
const bodyMat = new THREE.MeshLambertMaterial({ color: bodyHex });
const accentMat = new THREE.MeshLambertMaterial({ color: accentHex });
const glassMat = new THREE.MeshLambertMaterial({ color: 0x8ab8d8 });
const wheelMat = new THREE.MeshLambertMaterial({ color: 0x141414 });
const paintMats = [bodyMat, accentMat];
const add = (w, h, d, x, y, z, rx, ry, rz, mat) => {
const m = new THREE.Mesh(new THREE.BoxGeometry(w, h, d), mat || bodyMat);
m.position.set(x, y, z);
m.rotation.set(rx || 0, ry || 0, rz || 0);
m.castShadow = true;
m.receiveShadow = true;
group.add(m);
return m;
};
// Cybertruck-ish angular body
add(2.6, 0.55, 5.0, 0, 0.95, 0);
add(2.4, 0.35, 1.5, 0, 1.25, 1.7);
add(2.6, 0.30, 0.5, 0, 1.30, 2.5);
add(2.3, 0.90, 1.9, 0, 1.75, -0.35);
add(2.0, 0.30, 1.6, 0, 2.20, -0.45);
add(2.2, 0.70, 0.15, 0, 1.70, 0.55, 0.7, 0, 0, glassMat);
add(2.6, 0.25, 2.6, 0, 1.45, -1.6);
add(2.6, 0.60, 0.2, 0, 1.25, -2.5);
add(2.0, 0.50, 0.4, 0, 2.20, -0.55, 0, 0, 0, accentMat);
const wheelGeo = new THREE.CylinderGeometry(0.55, 0.55, 0.5, 16);
const frontPivots = [];
function addWheel(x, z, isFront) {
const pivot = new THREE.Group();
pivot.position.set(x, 0.55, z);
const wheel = new THREE.Mesh(wheelGeo, wheelMat);
wheel.rotation.z = Math.PI / 2;
pivot.add(wheel);
group.add(pivot);
if (isFront) frontPivots.push(pivot);
}
addWheel(-1.35, 1.8, true);
addWheel(1.35, 1.8, true);
addWheel(-1.35, -1.8, false);
addWheel(1.35, -1.8, false);
const truck = {
isPlayer: isPlayer,
group: group,
pos: new THREE.Vector3(),
velocity: new THREE.Vector3(),
yaw: 0,
steer: 0,
throttle: 0,
radius: 2.15,
maxSpeed: isPlayer ? 26 : 16 + Math.random() * 4,
accel: isPlayer ? 22 : 17,
drag: 1.8,
turnRate: isPlayer ? 2.1 : 1.7,
hitCooldown: 0,
wreckTimer: 0,
paintMats: paintMats,
frontPivots: frontPivots,
aiPhase: 0,
lane: 0,
lead: 0.6
};
scene.add(group);
return truck;
}
const playerTruck = makeTruck(true, 0xc0c6cc, 0x55c8ff);
playerTruck.pos.set(-22, 0, -4);
playerTruck.yaw = 0;
trucks.push(playerTruck);
const aiColors = [0xdd4455, 0x4488dd, 0xe8b820, 0x44aa66];
const aiLanes = [-4, -1.5, 1.5, 4];
const aiAngles = [0.4, Math.PI / 2 + 0.4, Math.PI + 0.4, Math.PI * 1.5 + 0.4];
for (let i = 0; i < 4; i++) {
const t = makeTruck(false, aiColors[i], 0xcccccc);
const lane = aiLanes[i];
const a = 20 + lane;
const b = 12 + lane;
const angle = aiAngles[i];
t.pos.set(a * Math.cos(angle), 0, b * Math.sin(angle));
t.yaw = Math.atan2(-a * Math.sin(angle), b * Math.cos(angle));
t.lane = lane;
t.aiPhase = angle;
t.lead = 0.5 + Math.random() * 0.5;
t.maxSpeed = 16 + Math.random() * 4;
trucks.push(t);
}
// ---- particles --------------------------------------------------------
const sparks = [];
const smokes = [];
function makePools() {
for (let i = 0; i < 40; i++) {
const m = new THREE.Mesh(
new THREE.OctahedronGeometry(0.18),
new THREE.MeshBasicMaterial({ color: 0xffcc33, transparent: true, opacity: 1 })
);
m.visible = false;
scene.add(m);
sparks.push({ mesh: m, life: 0, vel: new THREE.Vector3() });
}
for (let i = 0; i < 40; i++) {
const m = new THREE.Mesh(
new THREE.SphereGeometry(0.4, 6, 5),
new THREE.MeshBasicMaterial({ color: 0x555555, transparent: true, opacity: 0.55 })
);
m.visible = false;
scene.add(m);
smokes.push({ mesh: m, life: 0, vel: new THREE.Vector3() });
}
}
function spawnSparks(pos) {
const p = sparks.find(function (q) { return !q.mesh.visible; });
if (!p) return;
p.mesh.visible = true;
p.life = 0.5;
p.mesh.position.copy(pos);
p.mesh.position.y += 0.8;
p.vel.set((Math.random() - 0.5) * 10, Math.random() * 4 + 2, (Math.random() - 0.5) * 10);
}
function spawnSmoke(pos) {
const p = smokes.find(function (q) { return !q.mesh.visible; });
if (!p) return;
p.mesh.visible = true;
p.life = 1.0;
p.mesh.position.copy(pos);
p.mesh.position.y += 0.6;
p.mesh.scale.set(0.6, 0.6, 0.6);
p.mesh.material.opacity = 0.55;
p.vel.set((Math.random() - 0.5) * 1.5, 1.5 + Math.random() * 1.5, (Math.random() - 0.5) * 1.5);
}
function updateParticles(dt) {
for (let i = 0; i < sparks.length; i++) {
const p = sparks[i];
if (!p.mesh.visible) continue;
p.life -= dt;
if (p.life <= 0) {
p.mesh.visible = false;
continue;
}
p.mesh.position.addScaledVector(p.vel, dt);
p.vel.y -= 14 * dt;
p.mesh.material.opacity = p.life / 0.5;
}
for (let i = 0; i < smokes.length; i++) {
const p = smokes[i];
if (!p.mesh.visible) continue;
p.life -= dt;
if (p.life <= 0) {
p.mesh.visible = false;
continue;
}
p.mesh.position.addScaledVector(p.vel, dt);
const s = 0.6 + (1 - p.life) * 1.8;
p.mesh.scale.set(s, s, s);
p.mesh.material.opacity = Math.max(0, p.life * 0.45);
}
}
makePools();
// ---- physics / update -------------------------------------------------
function updateVehicle(truck, dt) {
const forward = new THREE.Vector3(Math.sin(truck.yaw), 0, Math.cos(truck.yaw));
const speedAlong = truck.velocity.dot(forward);
const reverse = speedAlong < -0.1 ? -1 : 1;
truck.yaw += truck.steer * truck.turnRate * dt * reverse;
truck.velocity.addScaledVector(forward, truck.throttle * truck.accel * dt);
let speed = truck.velocity.length();
if (speed > 0.01) {
const drag = Math.max(0, 1 - truck.drag * dt);
truck.velocity.multiplyScalar(drag);
if (speed > truck.maxSpeed) truck.velocity.setLength(truck.maxSpeed);
}
if (speed < 0.05 && truck.throttle === 0) {
truck.velocity.set(0, 0, 0);
}
truck.position.addScaledVector(truck.velocity, dt);
}
function handleWall(truck) {
const LX = 28;
const LZ = 18;
if (truck.position.x > LX) {
truck.position.x = LX;
if (truck.velocity.x > 0) truck.velocity.x *= -0.4;
} else if (truck.position.x < -LX) {
truck.position.x = -LX;
if (truck.velocity.x < 0) truck.velocity.x *= -0.4;
}
if (truck.position.z > LZ) {
truck.position.z = LZ;
if (truck.velocity.z > 0) truck.velocity.z *= -0.4;
} else if (truck.position.z < -LZ) {
truck.position.z = -LZ;
if (truck.velocity.z < 0) truck.velocity.z *= -0.4;
}
}
function collideWithObstacles(truck) {
for (let i = 0; i < obstacles.length; i++) {
const ob = obstacles[i];
const dx = truck.position.x - ob.x;
const dz = truck.position.z - ob.z;
const dist = Math.hypot(dx, dz);
const minDist = ob.radius + truck.radius;
if (dist >= minDist) continue;
let nx = 1, nz = 0;
if (dist > 0.0001) {
nx = dx / dist;
nz = dz / dist;
} else if (Math.abs(truck.velocity.x) + Math.abs(truck.velocity.z) > 0.0001) {
const len = truck.velocity.length();
nx = truck.velocity.x / len;
nz = truck.velocity.z / len;
}
truck.position.x = ob.x + nx * minDist;
truck.position.z = ob.z + nz * minDist;
const vn = truck.velocity.x * nx + truck.velocity.z * nz;
if (vn < 0) {
truck.velocity.x -= (1 + 0.4) * vn * nx;
truck.velocity.z -= (1 + 0.4) * vn * nz;
spawnSmoke(truck.position);
}
}
}
function collideTrucks() {
for (let i = 0; i < trucks.length; i++) {
for (let j = i + 1; j < trucks.length; j++) {
const A = trucks[i];
const B = trucks[j];
const dx = B.pos.x - A.pos.x;
const dz = B.pos.z - A.pos.z;
const dist = Math.hypot(dx, dz);
const minDist = A.radius + B.radius;
if (dist >= minDist) continue;
let nx = 1, nz = 0;
if (dist > 0.0001) {
nx = dx / dist;
nz = dz / dist;
} else {
const totalSpeed = Math.abs(A.velocity.x) + Math.abs(A.velocity.z) + Math.abs(B.velocity.x) + Math.abs(B.velocity.z);
if (totalSpeed > 0.0001) {
nx = (A.velocity.x - B.velocity.x) / totalSpeed;
nz = (A.velocity.z - B.velocity.z) / totalSpeed;
const len = Math.hypot(nx, nz);
if (len > 0.0001) {
nx /= len;
nz /= len;
} else {
nx = 1;
nz = 0;
}
}
}
const overlap = (minDist - dist) / 2;
A.pos.x -= nx * overlap;
A.pos.z -= nz * overlap;
B.pos.x += nx * overlap;
B.pos.z += nz * overlap;
const relv = (B.velocity.x - A.velocity.x) * nx + (B.velocity.z - A.velocity.z) * nz;
const impact = Math.abs(relv);
if (relv < 0) {
const impulse = -(1 + 0.35) * relv / 2;
A.velocity.x -= impulse * nx;
A.velocity.z -= impulse * nz;
B.velocity.x += impulse * nx;
B.velocity.z += impulse * nz;
}
if (impact > 4) {
spawnSparks(new THREE.Vector3((A.pos.x + B.pos.x) / 2, 1, (A.pos.z + B.pos.z) / 2));
}
if ((A.isPlayer || B.isPlayer) && impact > 5) {
const attacker = A.isPlayer ? A : B;
const rival = A.isPlayer ? B : A;
if (attacker.hitCooldown <= 0 && rival.hitCooldown <= 0) {
const pts = Math.round(clamp(impact * 5, 10, 250));
score += pts;
statusMessage = "SLAM +" + pts + "!";
statusTimer = 1.6;
rival.wreckTimer = 2.0;
attacker.hitCooldown = 1.0;
rival.hitCooldown = 1.0;
shake = Math.min(0.9, 0.25 + impact * 0.02);
spawnSparks(rival.pos);
}
}
}
}
}
function updateVisuals(truck) {
truck.group.position.copy(truck.pos);
truck.group.rotation.y = truck.yaw;
for (let i = 0; i < truck.frontPivots.length; i++) {
truck.frontPivots[i].rotation.y = truck.steer * 0.4;
}
}
function updateWreck(truck, dt) {
if (truck.wreckTimer > 0) {
truck.wreckTimer -= dt;
const k = Math.max(0, truck.wreckTimer);
const hex = k > 0 ? 0x883322 : 0x000000;
for (let i = 0; i < truck.paintMats.length; i++) {
truck.paintMats[i].emissive.setHex(hex);
}
if (k > 0 && Math.random() < 0.3) spawnSmoke(truck.pos);
} else {
for (let i = 0; i < truck.paintMats.length; i++) {
truck.paintMats[i].emissive.setHex(0x000000);
}
}
}
function updateAI(truck, dt) {
const a = 20 + truck.lane;
const b = 12 + truck.lane;
const raw = Math.atan2(truck.pos.z / b, truck.pos.x / a);
let ph = raw;
while (ph - truck.aiPhase > Math.PI) ph -= Math.PI * 2;
while (ph - truck.aiPhase < -Math.PI) ph += Math.PI * 2;
truck.aiPhase = ph;
const th = truck.aiPhase + truck.lead;
let tx = a * Math.cos(th);
let tz = b * Math.sin(th);
// separation from other trucks
for (let i = 0; i < trucks.length; i++) {
const other = trucks[i];
if (other === truck) continue;
const dx = truck.pos.x - other.pos.x;
const dz = truck.pos.z - other.pos.z;
const d = Math.hypot(dx, dz);
if (d < 5.5 && d > 0.001) {
const f = (5.5 - d) / 5.5;
tx += (dx / d) * f * 5;
tz += (dz / d) * f * 5;
}
}
// obstacle avoidance
for (let i = 0; i < obstacles.length; i++) {
const ob = obstacles[i];
const dx = truck.pos.x - ob.x;
const dz = truck.pos.z - ob.z;
const d = Math.hypot(dx, dz);
const min = ob.radius + 3.5;
if (d < min && d > 0.001) {
const f = (min - d) / min;
tx += (dx / d) * f * 6;
tz += (dz / d) * f * 6;
}
}
const desired = Math.atan2(tx - truck.pos.x, tz - truck.pos.z);
const diff = normAngle(desired - truck.yaw);
truck.steer = clamp(diff * 2.2, -1, 1);
const ad = Math.abs(diff);
truck.throttle = ad > 1.5 ? 0.35 : (ad > 0.5 ? 0.75 : 1.0);
if (truck.wreckTimer > 0) {
truck.throttle = 0.25;
truck.steer *= 0.6;
}
}
function updatePlayer(truck, dt) {
const left = keys.ArrowLeft || keys.KeyA;
const right = keys.ArrowRight || keys.KeyD;
const up = keys.ArrowUp || keys.KeyW;
const down = keys.ArrowDown || keys.KeyS;
truck.steer = (left ? -1 : 0) + (right ? 1 : 0);
truck.throttle = (up ? 1 : 0) - (down ? 1 : 0);
if (truck.wreckTimer > 0) truck.throttle *= 0.5;
}
function updateCamera(dt) {
const t = trucks[0];
const forward = new THREE.Vector3(Math.sin(t.yaw), 0, Math.cos(t.yaw));
const targetCam = t.pos.clone().addScaledVector(forward, -12).add(new THREE.Vector3(0, 7.2, 0));
if (shake > 0) {
targetCam.x += (Math.random() - 0.5) * shake;
targetCam.y += (Math.random() - 0.5) * shake;
targetCam.z += (Math.random() - 0.5) * shake;
shake *= Math.max(0, 1 - dt * 6);
}
camera.position.lerp(targetCam, 1 - Math.pow(0.001, dt));
const look = t.pos.clone().addScaledVector(forward, 5).add(new THREE.Vector3(0, 1.6, 0));
camera.lookAt(look);
}
function updateHUD() {
hudScore.textContent = "SCORE " + score;
hudTime.textContent = "TIME " + fmtTime(timeLeft);
if (statusTimer > 0) {
hudStatus.textContent = statusMessage;
} else {
hudStatus.textContent = "";
}
}
function update(dt) {
timeLeft -= dt;
if (timeLeft <= 0) {
timeLeft = 0;
gameOver = true;
statusMessage = "TIME UP";
statusTimer = 999;
}
if (statusTimer > 0) statusTimer -= dt;
updatePlayer(trucks[0], dt);
for (let i = 1; i < trucks.length; i++) updateAI(trucks[i], dt);
for (let i = 0; i < trucks.length; i++) {
const t = trucks[i];
updateVehicle(t, dt);
updateWreck(t, dt);
if (t.hitCooldown > 0) t.hitCooldown -= dt;
}
for (let i = 0; i < trucks.length; i++) {
handleWall(trucks[i]);
}
for (let i = 0; i < trucks.length; i++) {
collideWithObstacles(trucks[i]);
}
for (let i = 0; i < trucks.length; i++) {
handleWall(trucks[i]);
}
collideTrucks();
for (let i = 0; i < trucks.length; i++) {
updateVisuals(trucks[i]);
}
updateParticles(dt);
updateCamera(dt);
updateHUD();
}
// ---- photo mode -------------------------------------------------------
function setPhoto(on) {
photoMode = on;
photoEl.classList.toggle("show", on);
if (on) {
photoScore.textContent = "SCORE " + score;
}
}
window.addEventListener("keydown", function (e) {
keys[e.code] = true;
if (e.code === "KeyP" && !e.repeat) {
e.preventDefault();
setPhoto(!photoMode);
}
if (["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", "Space"].indexOf(e.code) !== -1) {
e.preventDefault();
}
});
window.addEventListener("keyup", function (e) {
keys[e.code] = false;
});
window.addEventListener("blur", function () {
for (const k in keys) keys[k] = false;
});
window.addEventListener("resize", function () {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
});
// ---- loop -------------------------------------------------------------
updateHUD();
let lastTime = performance.now();
function animate() {
requestAnimationFrame(animate);
const now = performance.now();
const dt = Math.min((now - lastTime) / 1000, 0.033);
lastTime = now;
if (!photoMode && !gameOver) {
update(dt);
}
renderer.render(scene, camera);
}
animate();
})();
</script>
</body>
</html>
#demo sets real initial game state at startup: timeLeft = 20 and score = 5000. It is not an overlay — the HUD reads those values, the timer counts down through the normal update loop, and ramming rival trucks still changes the score.P stops the game update step — physics, AI, timer, particles, camera follow, and collision resolution all halt. The render loop stays alive only to redraw the same frozen frame behind the photo card, so nothing keeps playing behind it.