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.GigaCrush at The Stainless Coliseum is a five-truck dirt-bowl brawl of angular Cybertrucks slamming over hills, boulders and barricades while a packed crowd rings the stands.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>GigaCrush — The Stainless Coliseum</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #0b1018; font-family: ui-sans-serif, system-ui, Segoe UI, sans-serif; }
canvas { display: block; }
#hud {
position: fixed; left: 0; right: 0; top: 0; padding: 14px 18px 10px;
color: #f3f6fa; pointer-events: none; text-shadow: 0 1px 2px #000, 0 0 12px #000;
display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
z-index: 5;
}
#arenaName { font-size: 18px; letter-spacing: 0.22em; font-weight: 700; }
#arenaName span { display: block; font-size: 11px; letter-spacing: 0.28em; opacity: 0.7; font-weight: 600; margin-top: 3px; }
#stats { text-align: right; font-variant-numeric: tabular-nums; }
#stats .score { font-size: 28px; font-weight: 800; letter-spacing: 0.06em; }
#stats .clock { font-size: 18px; letter-spacing: 0.12em; opacity: 0.9; margin-top: 2px; }
#hint { position: fixed; left: 18px; bottom: 14px; color: #d7dde6; font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; pointer-events: none; text-shadow: 0 1px 2px #000; z-index: 5; opacity: 0.85; }
#photo {
display: none; position: fixed; inset: 0; z-index: 8;
background: rgba(6, 8, 14, 0.62); color: #fff;
align-items: center; justify-content: center; flex-direction: column;
text-align: center; letter-spacing: 0.18em;
}
#photo.on { display: flex; }
#photo .kicker { font-size: 12px; opacity: 0.7; margin-bottom: 10px; }
#photo .nm { font-size: 34px; font-weight: 800; }
#photo .sc { font-size: 22px; margin-top: 14px; font-variant-numeric: tabular-nums; }
#photo .sub { font-size: 11px; opacity: 0.65; margin-top: 28px; }
</style>
</head>
<body>
<div id="hud">
<div id="arenaName">THE STAINLESS COLISEUM<span>GIGACRUSH RALLY</span></div>
<div id="stats">
<div class="score" id="scoreEl">SCORE 0</div>
<div class="clock" id="clockEl">TIME 1:00</div>
</div>
</div>
<div id="hint">WASD or Arrow keys to drive · P photo mode · ram rivals to score</div>
<div id="photo">
<div class="kicker">PHOTO MODE</div>
<div class="nm" id="photoName">THE STAINLESS COLISEUM</div>
<div class="sc" id="photoScore">SCORE 0</div>
<div class="sub">PRESS P TO RESUME</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/three@0.160.0/build/three.min.js"></script>
<script>
(function () {
const ARENA = 36;
const ARENA_NAME = "THE STAINLESS COLISEUM";
const demo = location.hash === "#demo";
let score = demo ? 5000 : 0;
let timeLeft = demo ? 20 : 60;
let photoMode = false;
let audioCtx = null;
const keys = Object.create(null);
const codeOn = (c) => !!keys[c];
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x151c28);
scene.fog = new THREE.Fog(0x151c28, 55, 130);
const camera = new THREE.PerspectiveCamera(55, innerWidth / innerHeight, 0.1, 200);
camera.position.set(0, 18, 28);
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
document.body.appendChild(renderer.domElement);
scene.add(new THREE.HemisphereLight(0xb9c6d6, 0x3a2a18, 0.7));
const sun = new THREE.DirectionalLight(0xffe6c8, 1.15);
sun.position.set(-30, 42, 18);
sun.castShadow = true;
sun.shadow.mapSize.set(1024, 1024);
sun.shadow.camera.near = 10;
sun.shadow.camera.far = 110;
sun.shadow.camera.left = -50;
sun.shadow.camera.right = 50;
sun.shadow.camera.top = 50;
sun.shadow.camera.bottom = -50;
scene.add(sun);
const fill = new THREE.DirectionalLight(0x88a0c0, 0.25);
fill.position.set(20, 10, -30);
scene.add(fill);
const hills = [
{ x: 12, z: -10, r: 9, h: 3.2 },
{ x: -14, z: 8, r: 8, h: 2.6 },
{ x: 6, z: 14, r: 7, h: 2.2 },
{ x: -8, z: -14, r: 10, h: 3.6 },
{ x: 0, z: 0, r: 5.5, h: 1.4 }
];
function terrainHeight(x, z) {
let h = 0;
for (let i = 0; i < hills.length; i++) {
const hill = hills[i];
const d = Math.hypot(x - hill.x, z - hill.z);
if (d < hill.r) {
const t = 1 - d / hill.r;
h += hill.h * t * t * (3 - 2 * t);
}
}
return h;
}
const dirtMat = new THREE.MeshStandardMaterial({ color: 0x6a5438, roughness: 0.95, metalness: 0.02 });
const floorGeo = new THREE.CircleGeometry(ARENA + 5, 80);
const pos = floorGeo.attributes.position;
for (let i = 0; i < pos.count; i++) {
const x = pos.getX(i), y = pos.getY(i);
pos.setZ(i, terrainHeight(x, y));
}
floorGeo.computeVertexNormals();
const floor = new THREE.Mesh(floorGeo, dirtMat);
floor.rotation.x = -Math.PI / 2;
floor.receiveShadow = true;
scene.add(floor);
for (let i = 0; i < hills.length; i++) {
const hill = hills[i];
const bump = new THREE.Mesh(
new THREE.SphereGeometry(hill.r, 18, 12),
dirtMat
);
bump.scale.y = (hill.h / hill.r) * 0.95;
bump.position.set(hill.x, 0.02, hill.z);
bump.receiveShadow = true;
bump.castShadow = true;
scene.add(bump);
}
const wallMat = new THREE.MeshStandardMaterial({ color: 0x3a3f48, roughness: 0.8, metalness: 0.2 });
const wall = new THREE.Mesh(new THREE.CylinderGeometry(ARENA + 0.6, ARENA + 0.6, 1.6, 64, 1, true), wallMat);
wall.position.y = 0.8;
wall.receiveShadow = true;
scene.add(wall);
const standMat = new THREE.MeshStandardMaterial({ color: 0x2a3038, roughness: 0.9 });
for (let s = 0; s < 7; s++) {
const inner = ARENA + 2.2 + s * 1.55;
const ring = new THREE.Mesh(new THREE.RingGeometry(inner, inner + 1.65, 72), standMat);
ring.rotation.x = -Math.PI / 2;
ring.position.y = 1.4 + s * 0.92;
ring.receiveShadow = true;
scene.add(ring);
}
const fascia = new THREE.Mesh(
new THREE.CylinderGeometry(ARENA + 13.2, ARENA + 13.2, 8, 64, 1, true),
new THREE.MeshStandardMaterial({ color: 0x1c222b, roughness: 0.85, side: THREE.DoubleSide })
);
fascia.position.y = 5.2;
scene.add(fascia);
(function crowd() {
const bodyGeo = new THREE.BoxGeometry(0.32, 1.05, 0.28);
const headGeo = new THREE.BoxGeometry(0.22, 0.22, 0.22);
const bodyMat = new THREE.MeshLambertMaterial({ color: 0xffffff });
const headMat = new THREE.MeshLambertMaterial({ color: 0xffffff });
const N = 2200;
const bodies = new THREE.InstancedMesh(bodyGeo, bodyMat, N);
const heads = new THREE.InstancedMesh(headGeo, headMat, N);
const dummy = new THREE.Object3D();
const col = new THREE.Color();
let n = 0;
for (let row = 0; row < 7; row++) {
const r = ARENA + 2.9 + row * 1.55;
const count = Math.floor(14 + r * 3.15);
for (let k = 0; k < count && n < N; k++) {
const a = (k / count) * Math.PI * 2 + row * 0.07;
const y = 1.95 + row * 0.92 + (Math.random() * 0.12);
dummy.position.set(Math.cos(a) * r, y, Math.sin(a) * r);
dummy.rotation.set(0, a + Math.PI, (Math.random() - 0.5) * 0.15);
dummy.scale.set(0.9 + Math.random() * 0.25, 0.75 + Math.random() * 0.55, 0.9);
dummy.updateMatrix();
bodies.setMatrixAt(n, dummy.matrix);
col.setHSL((Math.random() * 0.15 + [0.0, 0.08, 0.55, 0.62, 0.95][n % 5]) % 1, 0.55, 0.42 + Math.random() * 0.18);
bodies.setColorAt(n, col);
dummy.position.y += 0.62 * dummy.scale.y;
dummy.scale.set(1, 1, 1);
dummy.updateMatrix();
heads.setMatrixAt(n, dummy.matrix);
col.setHSL(0.08, 0.35, 0.38 + Math.random() * 0.35);
heads.setColorAt(n, col);
n++;
}
}
bodies.count = n;
heads.count = n;
scene.add(bodies);
scene.add(heads);
})();
const obstacles = [];
function addStatic(mesh, x, z, radius, kind) {
mesh.position.set(x, terrainHeight(x, z) + (mesh.userData.lift || 0), z);
mesh.castShadow = true;
mesh.receiveShadow = true;
scene.add(mesh);
obstacles.push({ x: x, z: z, r: radius, kind: kind, mesh: mesh });
}
const rockMat = new THREE.MeshStandardMaterial({ color: 0x5c5852, roughness: 0.92, metalness: 0.05 });
const rockSpots = [[-22, -6], [-18, 16], [20, 9], [16, -18], [-6, 22], [22, -4], [-10, -22], [8, -24]];
for (let i = 0; i < rockSpots.length; i++) {
const g = new THREE.DodecahedronGeometry(1.1 + Math.random() * 0.7, 0);
const m = new THREE.Mesh(g, rockMat);
m.rotation.set(Math.random(), Math.random(), Math.random());
m.userData.lift = 0.7;
addStatic(m, rockSpots[i][0], rockSpots[i][1], 1.6, "boulder");
}
const barMat = new THREE.MeshStandardMaterial({ color: 0x8a9180, roughness: 0.7, metalness: 0.15 });
const bars = [
[10, 4, 1.2], [-16, -2, 0.4], [4, -16, 2.1], [-4, 12, 0.9], [18, 18, 3.6]
];
for (let i = 0; i < bars.length; i++) {
const m = new THREE.Mesh(new THREE.BoxGeometry(3.4, 1.1, 0.55), barMat);
m.rotation.y = bars[i][2];
m.userData.lift = 0.55;
addStatic(m, bars[i][0], bars[i][1], 1.7, "barrier");
}
const scrapMat = new THREE.MeshStandardMaterial({ color: 0x6d4a2a, roughness: 0.55, metalness: 0.45 });
const scraps = [[-24, 8], [14, 22], [24, -14], [-20, 22], [0, -20], [8, 8]];
for (let i = 0; i < scraps.length; i++) {
const grp = new THREE.Group();
for (let k = 0; k < 4; k++) {
const box = new THREE.Mesh(new THREE.BoxGeometry(0.7 + Math.random(), 0.35 + Math.random() * 0.5, 0.5 + Math.random()), scrapMat);
box.position.set((Math.random() - 0.5) * 1.4, k * 0.28, (Math.random() - 0.5) * 1.4);
box.rotation.set(Math.random() * 0.6, Math.random() * 2, Math.random() * 0.6);
box.castShadow = true;
grp.add(box);
}
grp.userData.lift = 0.4;
addStatic(grp, scraps[i][0], scraps[i][1], 1.5, "scrap");
}
function makeTruck(tint, accent) {
const g = new THREE.Group();
const bodyMat = new THREE.MeshStandardMaterial({ color: tint, metalness: 0.88, roughness: 0.28 });
const darkMat = new THREE.MeshStandardMaterial({ color: 0x111111, metalness: 0.7, roughness: 0.15 });
const body = new THREE.Mesh(new THREE.BoxGeometry(2.15, 0.62, 4.5), bodyMat);
body.position.y = 1.42;
body.castShadow = true;
g.add(body);
const skirt = new THREE.Mesh(new THREE.BoxGeometry(2.25, 0.22, 4.55), bodyMat);
skirt.position.y = 1.12;
g.add(skirt);
const cabin = new THREE.Mesh(new THREE.BoxGeometry(2.05, 0.62, 2.05), bodyMat);
cabin.position.set(0, 1.88, -0.55);
cabin.castShadow = true;
g.add(cabin);
const glass = new THREE.Mesh(new THREE.BoxGeometry(1.95, 0.42, 1.7), darkMat);
glass.position.set(0, 1.95, -0.62);
g.add(glass);
const nose = new THREE.Mesh(new THREE.BoxGeometry(2.12, 0.12, 2.3), bodyMat);
nose.position.set(0, 1.62, 1.55);
nose.rotation.x = -0.48;
g.add(nose);
const bar = new THREE.Mesh(new THREE.BoxGeometry(1.7, 0.08, 0.08), new THREE.MeshStandardMaterial({ color: accent, emissive: accent, emissiveIntensity: 0.8 }));
bar.position.set(0, 1.38, 2.28);
g.add(bar);
const wheelGeo = new THREE.CylinderGeometry(0.72, 0.72, 0.42, 10);
const wheelMat = new THREE.MeshStandardMaterial({ color: 0x171717, roughness: 0.9 });
const wheels = [];
const wp = [[-1.12, 0.72, 1.45], [1.12, 0.72, 1.45], [-1.12, 0.72, -1.45], [1.12, 0.72, -1.45]];
for (let i = 0; i < 4; i++) {
const w = new THREE.Mesh(wheelGeo, wheelMat);
w.rotation.z = Math.PI / 2;
w.position.set(wp[i][0], wp[i][1], wp[i][2]);
w.castShadow = true;
g.add(w);
wheels.push(w);
}
scene.add(g);
return { group: g, body: body, bodyMat: bodyMat, wheels: wheels };
}
const truckDefs = [
{ tint: 0xdfe6ee, accent: 0xff6a00, player: true },
{ tint: 0x1c1e22, accent: 0xff3344, player: false },
{ tint: 0xb08a2a, accent: 0xffee88, player: false },
{ tint: 0x8a949e, accent: 0x44ddff, player: false },
{ tint: 0x3a4650, accent: 0x88ff66, player: false }
];
const spawn = [
[0, 8],
[14, -6],
[-12, -8],
[10, 16],
[-16, 10]
];
const trucks = [];
for (let i = 0; i < 5; i++) {
const vis = makeTruck(truckDefs[i].tint, truckDefs[i].accent);
const t = {
vis: vis,
x: spawn[i][0],
z: spawn[i][1],
y: 0,
yaw: Math.random() * Math.PI * 2,
vx: 0, vz: 0, vy: 0,
speed: 0,
spin: 0,
radius: 2.15,
wrecked: 0,
flash: 0,
player: i === 0,
aiTimer: Math.random(),
aiTx: spawn[i][0],
aiTz: spawn[i][1],
orbitR: 12 + i * 4.5,
orbitW: (i % 2 === 0 ? 1 : -1) * (0.22 + i * 0.05),
phase: i * 1.4,
chase: i === 1 || i === 3,
sepBias: 1.1 + i * 0.35
};
trucks.push(t);
}
const scoreEl = document.getElementById("scoreEl");
const clockEl = document.getElementById("clockEl");
const photoEl = document.getElementById("photo");
const photoScore = document.getElementById("photoScore");
function fmtTime(t) {
const s = Math.max(0, Math.ceil(t));
const m = Math.floor(s / 60);
const r = s % 60;
return (m > 0 ? m + ":" : "0:") + (r < 10 ? "0" : "") + r;
}
function paintHud() {
scoreEl.textContent = "SCORE " + score;
clockEl.textContent = "TIME " + fmtTime(timeLeft);
}
paintHud();
function boom(impact) {
if (!audioCtx) return;
const o = audioCtx.createOscillator();
const g = audioCtx.createGain();
o.type = "square";
o.frequency.value = 60 + impact * 8;
g.gain.setValueAtTime(Math.min(0.12, impact * 0.012), audioCtx.currentTime);
g.gain.exponentialRampToValueAtTime(0.001, audioCtx.currentTime + 0.18);
o.connect(g);
g.connect(audioCtx.destination);
o.start();
o.stop(audioCtx.currentTime + 0.2);
}
function ensureAudio() {
if (!audioCtx) {
const AC = window.AudioContext || window.webkitAudioContext;
if (AC) audioCtx = new AC();
}
if (audioCtx && audioCtx.state === "suspended") audioCtx.resume();
}
window.addEventListener("keydown", function (e) {
keys[e.code] = true;
if (["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", "KeyW", "KeyA", "KeyS", "KeyD", "KeyP", "Space"].indexOf(e.code) >= 0) {
e.preventDefault();
}
if (e.code === "KeyP" && !e.repeat) {
photoMode = !photoMode;
photoEl.classList.toggle("on", photoMode);
photoScore.textContent = "SCORE " + score;
document.getElementById("photoName").textContent = ARENA_NAME;
}
ensureAudio();
});
window.addEventListener("keyup", function (e) { keys[e.code] = false; });
function driveToward(t, tx, tz, dt, maxSpd) {
const dx = tx - t.x, dz = tz - t.z;
const want = Math.atan2(dx, dz);
let diff = want - t.yaw;
while (diff > Math.PI) diff -= Math.PI * 2;
while (diff < -Math.PI) diff += Math.PI * 2;
t.yaw += Math.max(-2.4 * dt, Math.min(2.4 * dt, diff));
t.speed += (maxSpd - t.speed) * Math.min(1, dt * 2.2);
}
function updateAI(dt, now) {
for (let i = 1; i < 5; i++) {
const t = trucks[i];
if (t.wrecked > 0) {
t.speed *= 0.96;
continue;
}
t.aiTimer -= dt;
if (t.aiTimer <= 0) {
t.aiTimer = 0.8 + (i * 0.35) + Math.random() * 1.4;
const ang = now * t.orbitW + t.phase;
if (t.chase && Math.random() < 0.55) {
t.aiTx = trucks[0].x + Math.cos(ang) * 6;
t.aiTz = trucks[0].z + Math.sin(ang) * 6;
} else {
t.aiTx = Math.cos(ang) * t.orbitR;
t.aiTz = Math.sin(ang) * t.orbitR;
}
}
let sx = 0, sz = 0;
for (let j = 0; j < 5; j++) {
if (j === i) continue;
const o = trucks[j];
const dx = t.x - o.x, dz = t.z - o.z;
const d = Math.hypot(dx, dz) || 0.0001;
const infl = 12 * t.sepBias;
if (d < infl) {
const f = (infl - d) / infl;
sx += (dx / d) * f;
sz += (dz / d) * f;
}
}
const tx = t.aiTx + sx * 10;
const tz = t.aiTz + sz * 10;
driveToward(t, tx, tz, dt, 11 + i * 0.6);
}
}
function collidePair(a, b, movableB) {
const dx = b.x - a.x, dz = b.z - a.z;
const dist = Math.hypot(dx, dz);
const minD = a.radius + b.radius;
if (dist >= minD || dist < 1e-4) return 0;
const nx = dx / dist, nz = dz / dist;
const overlap = minD - dist;
if (movableB) {
a.x -= nx * overlap * 0.5;
a.z -= nz * overlap * 0.5;
b.x += nx * overlap * 0.5;
b.z += nz * overlap * 0.5;
} else {
a.x -= nx * overlap;
a.z -= nz * overlap;
}
const bvx = movableB ? b.vx : 0;
const bvz = movableB ? b.vz : 0;
const relN = (a.vx - bvx) * nx + (a.vz - bvz) * nz;
if (relN >= 0) return 0;
const massB = movableB ? 1 : 1e9;
const inv = 1 / 1 + 1 / massB;
const e = movableB ? 0.48 : 0.35;
const j = -(1 + e) * relN / inv;
a.vx += j * nx;
a.vz += j * nz;
if (movableB) {
b.vx -= j * nx;
b.vz -= j * nz;
a.spin += nz * j * 0.08;
b.spin -= nz * j * 0.08;
} else {
a.spin += (Math.random() - 0.5) * 0.6;
}
return Math.abs(j);
}
function collisions() {
for (let i = 0; i < 5; i++) {
for (let j = i + 1; j < 5; j++) {
const impact = collidePair(trucks[i], trucks[j], true);
if (impact > 3.2) {
trucks[i].flash = trucks[j].flash = 0.18;
boom(impact);
if (trucks[i].player || trucks[j].player) {
const gain = Math.floor(impact * 18);
if (timeLeft > 0) score += gain;
const other = trucks[i].player ? trucks[j] : trucks[i];
if (impact > 11) other.wrecked = Math.max(other.wrecked, 1.6);
} else if (impact > 14) {
trucks[j].wrecked = Math.max(trucks[j].wrecked, 1.1);
}
}
}
}
for (let i = 0; i < 5; i++) {
const t = trucks[i];
for (let k = 0; k < obstacles.length; k++) {
const o = obstacles[k];
const dummy = { x: o.x, z: o.z, vx: 0, vz: 0, radius: o.r, spin: 0 };
const impact = collidePair(t, dummy, false);
if (impact > 6) {
t.flash = 0.12;
if (t.player && timeLeft > 0) score += 5;
}
}
}
}
function integrate(t, dt, isPlayer) {
if (isPlayer && t.wrecked <= 0) {
const up = codeOn("KeyW") || codeOn("ArrowUp");
const dn = codeOn("KeyS") || codeOn("ArrowDown");
const lf = codeOn("KeyA") || codeOn("ArrowLeft");
const rt = codeOn("KeyD") || codeOn("ArrowRight");
if (up) t.speed += 22 * dt;
if (dn) t.speed -= 16 * dt;
t.speed = Math.max(-8, Math.min(16.5, t.speed));
const steer = (lf ? 1 : 0) - (rt ? 1 : 0);
t.yaw += steer * dt * 2.3 * (t.speed >= 0 ? 1 : -1) * Math.min(1, Math.abs(t.speed) / 4 + 0.2);
}
t.speed *= Math.pow(0.985, dt * 60);
const fx = Math.sin(t.yaw), fz = Math.cos(t.yaw);
t.vx += (fx * t.speed - t.vx) * Math.min(1, dt * 8);
t.vz += (fz * t.speed - t.vz) * Math.min(1, dt * 8);
t.vx *= Math.pow(0.92, dt * 60);
t.vz *= Math.pow(0.92, dt * 60);
t.x += t.vx * dt;
t.z += t.vz * dt;
t.yaw += t.spin * dt;
t.spin *= Math.pow(0.9, dt * 60);
const d = Math.hypot(t.x, t.z);
const lim = ARENA - 2.4;
if (d > lim) {
const nx = t.x / d, nz = t.z / d;
t.x = nx * lim;
t.z = nz * lim;
const push = t.vx * nx + t.vz * nz;
if (push > 0) {
t.vx -= 1.4 * push * nx;
t.vz -= 1.4 * push * nz;
}
t.speed *= 0.7;
}
const ground = terrainHeight(t.x, t.z);
const targetY = ground;
if (t.y > targetY + 0.05) {
t.vy -= 22 * dt;
t.y += t.vy * dt;
if (t.y < targetY) { t.y = targetY; t.vy *= -0.25; }
} else {
t.y = t.y + (targetY - t.y) * Math.min(1, dt * 12);
const ghx = terrainHeight(t.x + fx, t.z + fz) - ground;
if (ghx > 0.35 && t.speed > 6) t.vy = 5 + ghx * 2;
t.y = Math.max(t.y, targetY);
}
if (t.wrecked > 0) t.wrecked -= dt;
if (t.flash > 0) t.flash -= dt;
}
function syncMesh(t, dt) {
const g = t.vis.group;
g.position.set(t.x, t.y, t.z);
const tilt = t.wrecked > 0 ? 0.45 * Math.min(1, t.wrecked) : 0;
g.rotation.set(tilt * 0.15, t.yaw, tilt);
const spin = t.speed * dt * 2.2;
for (let i = 0; i < 4; i++) t.vis.wheels[i].rotation.x += spin;
t.vis.bodyMat.emissive.setHex(t.flash > 0 ? 0xffffff : 0x000000);
t.vis.bodyMat.emissiveIntensity = t.flash > 0 ? 0.55 : 0;
}
const look = new THREE.Vector3();
const camGoal = new THREE.Vector3();
let last = performance.now();
function tick(now) {
requestAnimationFrame(tick);
const dt = Math.min(0.05, (now - last) / 1000);
last = now;
if (!photoMode) {
const t0 = trucks[0];
updateAI(dt, now * 0.001);
integrate(t0, dt, true);
for (let i = 1; i < 5; i++) integrate(trucks[i], dt, false);
collisions();
if (timeLeft > 0) {
timeLeft -= dt;
if (timeLeft < 0) timeLeft = 0;
}
paintHud();
for (let i = 0; i < 5; i++) syncMesh(trucks[i], dt);
const fx = Math.sin(t0.yaw), fz = Math.cos(t0.yaw);
camGoal.set(t0.x - fx * 13, t0.y + 7.2, t0.z - fz * 13);
camera.position.lerp(camGoal, 1 - Math.pow(0.001, dt));
look.set(t0.x + fx * 4, t0.y + 1.4, t0.z + fz * 4);
camera.lookAt(look);
}
renderer.render(scene, camera);
}
requestAnimationFrame(tick);
window.addEventListener("resize", function () {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(innerWidth, innerHeight);
});
})();
</script>
</body>
</html>
location.hash === "#demo", the live timeLeft and score variables (the same ones the HUD, scoring, and clock tick use) start at 20 and 5000 — not a cosmetic overlay.