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.Iron Volt Rally packs five angular monster trucks into a neon-lit stadium full of fans, dirt mounds, and smashable-looking debris.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" href="data:,">
<title>Iron Volt Rally</title>
<style>
* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; }
body {
background: #0b111b;
color: #fff;
font-family: system-ui, sans-serif;
}
canvas { display: block; width: 100%; height: 100%; }
#hud {
position: fixed;
top: 16px;
left: 16px;
right: 16px;
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 12px;
pointer-events: none;
text-shadow: 0 2px 8px #000;
}
.panel {
background: rgba(8, 15, 25, .83);
border: 1px solid rgba(164, 229, 255, .35);
border-radius: 8px;
padding: 10px 14px;
box-shadow: 0 4px 20px #0007;
}
.name { font-weight: 900; letter-spacing: .08em; font-size: 17px; }
.sub { color: #b8cbd6; font-size: 12px; margin-top: 4px; }
.numbers { display: flex; gap: 22px; text-align: right; }
.label { color: #9eb4c2; font-size: 10px; letter-spacing: .13em; }
.value { font-size: 24px; font-weight: 900; font-variant-numeric: tabular-nums; }
#score { color: #ffe47a; }
#hit {
position: fixed;
top: 90px;
left: 50%;
transform: translateX(-50%);
color: #ffe47a;
font-weight: 900;
font-size: 25px;
text-shadow: 0 2px 8px #000;
pointer-events: none;
opacity: 0;
}
#overlay {
position: fixed;
inset: 0;
display: none;
place-items: center;
background: rgba(3, 8, 15, .66);
text-align: center;
pointer-events: none;
}
#overlay.visible { display: grid; }
#card {
border: 1px solid #8ddcff;
background: rgba(8, 16, 26, .92);
padding: 28px 45px;
border-radius: 10px;
box-shadow: 0 12px 60px #000a;
}
#card .eyebrow { color: #83dfff; font-size: 12px; letter-spacing: .25em; }
#card h1 { margin: 12px 0 5px; font-size: clamp(24px, 5vw, 44px); }
#card .big { color: #ffe47a; font-size: 30px; font-weight: 900; }
#card .hint { color: #bccbd3; margin-top: 16px; font-size: 13px; }
#error {
position: fixed;
inset: 0;
display: grid;
place-items: center;
padding: 24px;
text-align: center;
color: #d3e3ec;
}
@media (max-width: 550px) {
#hud { top: 8px; left: 8px; right: 8px; }
.panel { padding: 8px; }
.name { font-size: 13px; }
.sub { font-size: 10px; }
.numbers { gap: 10px; }
.value { font-size: 19px; }
}
</style>
</head>
<body>
<div id="error">Loading the arena…<br>Three.js requires a network connection.</div>
<div id="hud">
<div class="panel">
<div class="name">IRON VOLT ARENA</div>
<div class="sub">WASD / arrows: drive · P: photo</div>
</div>
<div class="panel numbers">
<div><div class="label">SCORE</div><div class="value" id="score">0</div></div>
<div><div class="label">TIME</div><div class="value" id="clock">1:30</div></div>
</div>
</div>
<div id="hit"></div>
<div id="overlay">
<div id="card">
<div class="eyebrow" id="cardType">PHOTO MODE</div>
<h1>IRON VOLT ARENA</h1>
<div class="big" id="cardScore">0 POINTS</div>
<div class="hint" id="cardHint">Press P to resume</div>
</div>
</div>
<!-- The page's only external request. -->
<script src="https://cdn.jsdelivr.net/npm/three@0.160.1/build/three.min.js"></script>
<script>
(() => {
"use strict";
if (!window.THREE) {
document.getElementById("error").textContent =
"The arena could not load. Please connect to the internet and reload.";
return;
}
document.getElementById("error").style.display = "none";
const arenaName = "IRON VOLT ARENA";
const demo = location.hash === "#demo";
let score = demo ? 5000 : 0;
let timeLeft = demo ? 20 : 90;
let photo = false;
let finished = false;
let accumulator = 0;
let lastFrame = 0;
let hitTimer = 0;
const step = 1 / 60;
const keys = Object.create(null);
const scoreEl = document.getElementById("score");
const clockEl = document.getElementById("clock");
const hitEl = document.getElementById("hit");
const overlay = document.getElementById("overlay");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x101a28);
scene.fog = new THREE.Fog(0x101a28, 125, 230);
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 1.5));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
document.body.insertBefore(renderer.domElement, document.body.firstChild);
const camera = new THREE.PerspectiveCamera(
48, window.innerWidth / window.innerHeight, 0.1, 300
);
camera.position.set(0, 77, 82);
camera.lookAt(0, 0, 0);
scene.add(new THREE.HemisphereLight(0xbfe6ff, 0x59432f, 2.0));
const sun = new THREE.DirectionalLight(0xffe7c3, 2.3);
sun.position.set(-30, 70, 25);
scene.add(sun);
const mat = (color, extra = {}) =>
new THREE.MeshStandardMaterial({ color, roughness: 0.8, ...extra });
const dirtMat = mat(0x795843);
const wallMat = mat(0x344655);
const standMat = mat(0x26323d);
const yellowMat = mat(0xffc44d, { emissive: 0x4c2500 });
const darkMat = mat(0x121921);
const tireMat = mat(0x191b1d);
const hubMat = mat(0x8798a5, { metalness: 0.65, roughness: 0.35 });
const glassMat = mat(0x172e3e, { metalness: 0.5, roughness: 0.25 });
const lightMat = mat(0xb7f5ff, { emissive: 0x55dfff, emissiveIntensity: 1.7 });
const redLightMat = mat(0xff5043, { emissive: 0xc51c12, emissiveIntensity: 1.2 });
function box(w, h, d, material, x, y, z, parent = scene) {
const mesh = new THREE.Mesh(new THREE.BoxGeometry(w, h, d), material);
mesh.position.set(x, y, z);
parent.add(mesh);
return mesh;
}
// Arena floor and retaining walls.
box(100, 1, 70, dirtMat, 0, -0.6, 0);
box(102, 2.2, 1.2, wallMat, 0, 1, -35.5);
box(102, 2.2, 1.2, wallMat, 0, 1, 35.5);
box(1.2, 2.2, 70, wallMat, -50.5, 1, 0);
box(1.2, 2.2, 70, wallMat, 50.5, 1, 0);
box(102, 0.18, 0.2, yellowMat, 0, 2.15, -35.5);
box(102, 0.18, 0.2, yellowMat, 0, 2.15, 35.5);
box(0.2, 0.18, 70, yellowMat, -50.5, 2.15, 0);
box(0.2, 0.18, 70, yellowMat, 50.5, 2.15, 0);
// Tiered stands on all four sides.
for (let t = 0; t < 5; t++) {
const y = 0.35 + t * 0.9;
for (const s of [-1, 1]) {
box(120, 0.7 + t * 1.8, 2.7, standMat, 0, y, s * (37.5 + t * 2.5));
box(2.7, 0.7 + t * 1.8, 75, standMat, s * (52.5 + t * 2.5), y, 0);
}
}
// Deterministic procedural spectators: separate heads and colorful bodies.
let seed = 93847;
function random() {
seed = (seed * 1664525 + 1013904223) >>> 0;
return seed / 4294967296;
}
const fans = [];
for (let t = 0; t < 5; t++) {
const y = 1.15 + t * 1.8;
for (const s of [-1, 1]) {
for (let x = -57; x <= 57; x += 1.65) {
fans.push([x + (random() - .5) * .35, y, s * (37.5 + t * 2.5)]);
}
for (let z = -34; z <= 34; z += 1.65) {
fans.push([s * (52.5 + t * 2.5), y, z + (random() - .5) * .35]);
}
}
}
const bodyFans = new THREE.InstancedMesh(
new THREE.BoxGeometry(.68, .9, .45), mat(0xffffff), fans.length
);
const headFans = new THREE.InstancedMesh(
new THREE.SphereGeometry(.27, 6, 4), mat(0xffffff), fans.length
);
const dummy = new THREE.Object3D();
const fanColors = [0xf2b43c, 0xe55c4b, 0x4caec9, 0xe0e3d8, 0x637bd0, 0x76ae6b];
const skinColors = [0xf0c6a0, 0xc78e68, 0x8e5b43, 0xefd5bd];
fans.forEach((p, i) => {
dummy.position.set(p[0], p[1] + .45, p[2]);
dummy.rotation.y = random() * .5;
dummy.scale.setScalar(.85 + random() * .3);
dummy.updateMatrix();
bodyFans.setMatrixAt(i, dummy.matrix);
bodyFans.setColorAt(i, new THREE.Color(fanColors[Math.floor(random() * fanColors.length)]));
dummy.position.y = p[1] + 1.1;
dummy.updateMatrix();
headFans.setMatrixAt(i, dummy.matrix);
headFans.setColorAt(i, new THREE.Color(skinColors[Math.floor(random() * skinColors.length)]));
});
scene.add(bodyFans, headFans);
// Floodlights.
for (const x of [-58, 58]) {
for (const z of [-42, 42]) {
box(.5, 18, .5, wallMat, x, 9, z);
box(5, 1, 1, darkMat, x, 18, z);
for (let j = -1; j <= 1; j++) {
box(1, .55, .3, lightMat, x + j * 1.45, 18, z - Math.sign(z) * .6);
}
}
}
// Dirt hills use the same surface equation for drawing and truck height.
const hills = [
{ x: -25, z: -14, r: 9, h: 3.1 },
{ x: 23, z: 12, r: 8, h: 2.7 },
{ x: 1, z: -23, r: 6, h: 2.0 }
];
const hillGeo = new THREE.SphereGeometry(1, 24, 14);
hills.forEach(h => {
const mesh = new THREE.Mesh(hillGeo, mat(0x8b6549));
mesh.position.set(h.x, -h.h * .45, h.z);
mesh.scale.set(h.r, h.h * 1.45, h.r);
scene.add(mesh);
});
function groundHeight(x, z) {
let height = 0;
for (const h of hills) {
const d2 = ((x - h.x) ** 2 + (z - h.z) ** 2) / (h.r * h.r);
if (d2 < 1) {
height = Math.max(height, -h.h * .45 + h.h * 1.45 * Math.sqrt(1 - d2));
}
}
return height;
}
// Three physical obstacle types: tire stacks, concrete barriers, barrels.
const obstacles = [];
function addObstacle(x, z, r, type) {
obstacles.push({ x, z, r });
const y = groundHeight(x, z);
if (type === "tires") {
for (let i = 0; i < 3; i++) {
const tire = new THREE.Mesh(new THREE.CylinderGeometry(1.25, 1.25, .55, 12), tireMat);
tire.position.set(x + (i === 2 ? .18 : 0), y + .3 + i * .55, z);
scene.add(tire);
const hole = new THREE.Mesh(new THREE.CylinderGeometry(.5, .5, .57, 12), darkMat);
hole.position.copy(tire.position);
scene.add(hole);
}
} else if (type === "barrier") {
box(3.5, 1.4, 1.5, mat(0x93958d), x, y + .7, z);
box(3.4, .18, .08, yellowMat, x, y + .95, z + .78);
} else {
const barrel = new THREE.Mesh(new THREE.CylinderGeometry(.8, .8, 1.8, 12), mat(0xd75b2b));
barrel.position.set(x, y + .9, z);
scene.add(barrel);
for (const dy of [.4, 1.4]) {
const band = new THREE.Mesh(new THREE.CylinderGeometry(.83, .83, .12, 12), hubMat);
band.position.set(x, y + dy, z);
scene.add(band);
}
}
}
addObstacle(-37, 8, 1.35, "tires");
addObstacle(-11, -6, 1.35, "tires");
addObstacle(35, -19, 1.35, "tires");
addObstacle(12, -8, 1.9, "barrier");
addObstacle(-27, 23, 1.9, "barrier");
addObstacle(36, 22, 1.9, "barrier");
addObstacle(2, 6, .9, "barrel");
addObstacle(-40, -23, .9, "barrel");
addObstacle(29, -3, .9, "barrel");
// Faceted Cybertruck-inspired body, with its nose pointing along local +Z.
function bodyGeometry() {
const p = [
[-1.65, 1.45, -2.5], [1.65, 1.45, -2.5],
[-1.65, 1.45, 2.5], [1.65, 1.45, 2.5],
[-1.55, 2.25, -2.3], [1.55, 2.25, -2.3],
[-1.42, 3.15, -.35], [1.42, 3.15, -.35],
[-1.55, 2.12, 2.25], [1.55, 2.12, 2.25]
];
const faces = [
0,2,1, 1,2,3, 0,4,2, 2,4,6, 2,6,8,
1,3,5, 3,9,7, 3,7,5, 4,5,6, 5,7,6,
6,7,8, 7,9,8, 2,8,3, 3,8,9, 0,1,4, 1,5,4
];
const positions = [];
for (const index of faces) positions.push(...p[index]);
const geometry = new THREE.BufferGeometry();
geometry.setAttribute("position", new THREE.Float32BufferAttribute(positions, 3));
geometry.computeVertexNormals();
return geometry;
}
const truckBodyGeo = bodyGeometry();
const wheelGeo = new THREE.CylinderGeometry(1.08, 1.08, .85, 14);
const hubGeo = new THREE.CylinderGeometry(.5, .5, .88, 12);
const trucks = [];
const colors = [0xc8d7df, 0xeb5949, 0x54b9d0, 0xe5b849, 0x9b7bd2];
const starts = [
[0, 20, Math.PI],
[-32, -4, 1.1],
[30, -17, -1.1],
[-17, 15, 2.3],
[25, 20, -2.2]
];
function makeTruck(i) {
const group = new THREE.Group();
scene.add(group);
const paint = mat(colors[i], { metalness: .65, roughness: .35 });
const body = new THREE.Mesh(truckBodyGeo, paint);
group.add(body);
box(3.05, .15, 1.45, glassMat, 0, 2.67, .93, group).rotation.x = -.45;
box(3.05, .1, 1.25, glassMat, 0, 2.73, -1.3, group).rotation.x = .43;
box(3.15, .13, .12, lightMat, 0, 2.02, 2.53, group);
box(3.15, .12, .12, redLightMat, 0, 2.03, -2.53, group);
box(3.7, .35, .35, darkMat, 0, 1.1, 2.65, group);
box(3.7, .35, .35, darkMat, 0, 1.1, -2.65, group);
const wheels = [];
for (const x of [-1.85, 1.85]) {
for (const z of [-1.7, 1.7]) {
const wheel = new THREE.Mesh(wheelGeo, tireMat);
wheel.rotation.z = Math.PI / 2;
wheel.position.set(x, 1.05, z);
group.add(wheel);
const hub = new THREE.Mesh(hubGeo, hubMat);
hub.rotation.z = Math.PI / 2;
wheel.add(hub);
// Child geometry uses the wheel's unrotated local axis.
hub.rotation.z = 0;
wheels.push(wheel);
}
}
if (i === 0) {
const ring = new THREE.Mesh(
new THREE.RingGeometry(3.1, 3.3, 32),
new THREE.MeshBasicMaterial({ color: 0x75e8ff, side: THREE.DoubleSide })
);
ring.rotation.x = -Math.PI / 2;
ring.position.y = .08;
group.add(ring);
}
const [x, z, angle] = starts[i];
const truck = {
i, group, paint, wheels, x, z, angle, vx: 0, vz: 0,
radius: 2.45, cooldown: 0, flash: 0,
targetX: x, targetZ: z, targetTimer: .2 + i * .7
};
trucks.push(truck);
return truck;
}
for (let i = 0; i < 5; i++) makeTruck(i);
const player = trucks[0];
const clamp = (n, a, b) => Math.max(a, Math.min(b, n));
function angleDiff(a, b) {
return Math.atan2(Math.sin(a - b), Math.cos(a - b));
}
function aiControls(t, dt) {
t.targetTimer -= dt;
if (t.targetTimer <= 0) {
t.targetTimer = 2.5 + random() * 2.5;
if (random() < .48) {
// Offset approach points keep simultaneous attackers in separate lanes.
const side = (t.i - 2.5) * 5;
t.targetX = clamp(player.x + Math.cos(player.angle) * side, -43, 43);
t.targetZ = clamp(player.z - Math.sin(player.angle) * side, -28, 28);
} else {
t.targetX = -40 + random() * 80;
t.targetZ = -26 + random() * 52;
}
}
let dx = t.targetX - t.x;
let dz = t.targetZ - t.z;
const targetLength = Math.hypot(dx, dz) || 1;
dx /= targetLength;
dz /= targetLength;
for (const other of trucks) {
if (other === t) continue;
const ox = t.x - other.x, oz = t.z - other.z;
const d = Math.hypot(ox, oz) || .01;
if (d < 10) {
const weight = (10 - d) / 10 * 1.5;
dx += ox / d * weight;
dz += oz / d * weight;
}
}
for (const o of obstacles) {
const ox = t.x - o.x, oz = t.z - o.z;
const d = Math.hypot(ox, oz) || .01;
if (d < o.r + 7) {
const weight = (o.r + 7 - d) / 7 * 1.3;
dx += ox / d * weight;
dz += oz / d * weight;
}
}
const desired = Math.atan2(dx, dz);
const turn = clamp(angleDiff(desired, t.angle) * 1.4, -1, 1);
return { throttle: 1, turn };
}
function simulate(dt) {
timeLeft = Math.max(0, timeLeft - dt);
if (timeLeft === 0) {
finished = true;
showCard();
return;
}
if (hitTimer > 0) {
hitTimer -= dt;
hitEl.style.opacity = Math.min(1, hitTimer * 2);
}
for (const t of trucks) {
t.cooldown = Math.max(0, t.cooldown - dt);
t.flash = Math.max(0, t.flash - dt);
t.paint.emissive.setHex(t.flash > 0 ? 0x773000 : 0x000000);
let controls;
if (t === player) {
controls = {
throttle: (keys.KeyW || keys.ArrowUp ? 1 : 0) -
(keys.KeyS || keys.ArrowDown ? 1 : 0),
turn: (keys.KeyD || keys.ArrowRight ? 1 : 0) -
(keys.KeyA || keys.ArrowLeft ? 1 : 0)
};
} else {
controls = aiControls(t, dt);
}
let fx = Math.sin(t.angle), fz = Math.cos(t.angle);
let forward = t.vx * fx + t.vz * fz;
const steerStrength = clamp(Math.abs(forward) / 4, .2, 1);
const reverse = forward < -1 ? -1 : 1;
t.angle += controls.turn * 1.65 * steerStrength * reverse * dt;
fx = Math.sin(t.angle);
fz = Math.cos(t.angle);
t.vx += fx * controls.throttle * 18 * dt;
t.vz += fz * controls.throttle * 18 * dt;
// Tire grip damps sideways velocity while preserving collision impulses.
forward = t.vx * fx + t.vz * fz;
const lateralX = t.vx - forward * fx;
const lateralZ = t.vz - forward * fz;
t.vx -= lateralX * Math.min(1, 3.3 * dt);
t.vz -= lateralZ * Math.min(1, 3.3 * dt);
const drag = Math.max(0, 1 - (controls.throttle ? .35 : 1.0) * dt);
t.vx *= drag;
t.vz *= drag;
const speed = Math.hypot(t.vx, t.vz);
const maxSpeed = t === player ? 20 : 16;
if (speed > maxSpeed) {
t.vx *= maxSpeed / speed;
t.vz *= maxSpeed / speed;
}
t.x += t.vx * dt;
t.z += t.vz * dt;
// Circular obstacles: depenetrate and reflect the inward normal velocity.
for (const o of obstacles) {
let dx = t.x - o.x, dz = t.z - o.z;
let d = Math.hypot(dx, dz);
const minD = t.radius + o.r;
if (d < minD) {
if (d < .001) { dx = 1; dz = 0; d = 1; }
const nx = dx / d, nz = dz / d;
t.x += nx * (minD - d);
t.z += nz * (minD - d);
const vn = t.vx * nx + t.vz * nz;
if (vn < 0) {
t.vx -= 1.5 * vn * nx;
t.vz -= 1.5 * vn * nz;
t.flash = .18;
}
}
}
// Stadium boundary.
const limitX = 49 - t.radius, limitZ = 34 - t.radius;
if (t.x < -limitX || t.x > limitX) {
t.x = clamp(t.x, -limitX, limitX);
t.vx *= -.5;
t.flash = .12;
}
if (t.z < -limitZ || t.z > limitZ) {
t.z = clamp(t.z, -limitZ, limitZ);
t.vz *= -.5;
t.flash = .12;
}
}
// Equal-mass truck circles exchange a restitution impulse.
for (let i = 0; i < trucks.length; i++) {
for (let j = i + 1; j < trucks.length; j++) {
const a = trucks[i], b = trucks[j];
let dx = b.x - a.x, dz = b.z - a.z;
let d = Math.hypot(dx, dz);
const minD = a.radius + b.radius;
if (d >= minD) continue;
if (d < .001) { dx = 1; dz = 0; d = 1; }
const nx = dx / d, nz = dz / d;
const overlap = (minD - d) * .5;
a.x -= nx * overlap; a.z -= nz * overlap;
b.x += nx * overlap; b.z += nz * overlap;
const relative = (b.vx - a.vx) * nx + (b.vz - a.vz) * nz;
if (relative < 0) {
const impulse = -(1 + .65) * relative / 2;
a.vx -= impulse * nx; a.vz -= impulse * nz;
b.vx += impulse * nx; b.vz += impulse * nz;
a.flash = b.flash = .25;
if (a === player && -relative > 2 && b.cooldown <= 0) {
const points = 250 + Math.round(Math.min(750, -relative * 40) / 50) * 50;
score += points;
b.cooldown = .8;
hitEl.textContent = "RAM! +" + points;
hitTimer = 1.1;
hitEl.style.opacity = "1";
}
}
}
}
for (const t of trucks) {
t.group.position.set(t.x, groundHeight(t.x, t.z), t.z);
t.group.rotation.y = t.angle;
const wheelSpin = Math.hypot(t.vx, t.vz) * dt;
for (const wheel of t.wheels) wheel.rotation.x += wheelSpin;
}
}
function updateHud() {
scoreEl.textContent = score.toLocaleString("en-US");
const seconds = Math.ceil(timeLeft);
clockEl.textContent = Math.floor(seconds / 60) + ":" +
String(seconds % 60).padStart(2, "0");
}
function showCard() {
const visible = photo || finished;
overlay.classList.toggle("visible", visible);
if (!visible) return;
document.querySelector("#card h1").textContent = arenaName;
document.getElementById("cardType").textContent = photo ? "PHOTO MODE" : "RALLY COMPLETE";
document.getElementById("cardScore").textContent = score.toLocaleString("en-US") + " POINTS";
document.getElementById("cardHint").textContent = photo ?
"Press P to resume" : "Press R to race again · P for photo";
}
// Initial placement is applied before the first rendered frame.
for (const t of trucks) {
t.group.position.set(t.x, groundHeight(t.x, t.z), t.z);
t.group.rotation.y = t.angle;
}
updateHud();
window.addEventListener("keydown", e => {
if (["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", "Space"].includes(e.code)) {
e.preventDefault();
}
if (e.code === "KeyP" && !e.repeat) {
photo = !photo;
accumulator = 0;
showCard();
} else if (e.code === "KeyR" && finished && !photo && !e.repeat) {
location.reload();
} else {
keys[e.code] = true;
}
});
window.addEventListener("keyup", e => { keys[e.code] = false; });
window.addEventListener("blur", () => {
for (const key in keys) keys[key] = false;
accumulator = 0;
lastFrame = 0;
});
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
});
function frame(now) {
requestAnimationFrame(frame);
const elapsed = lastFrame ? Math.min((now - lastFrame) / 1000, .1) : 0;
lastFrame = now;
if (!photo && !finished) {
accumulator += elapsed;
while (accumulator >= step && !finished) {
simulate(step);
accumulator -= step;
}
} else {
accumulator = 0;
}
updateHud();
// The camera and rendering remain still in photo mode.
if (!photo) {
const targetX = player.x * .22;
const targetZ = player.z * .22;
camera.position.x += (targetX - camera.position.x) * .025;
camera.position.z += ((82 + targetZ) - camera.position.z) * .025;
camera.lookAt(targetX, 0, targetZ);
}
renderer.render(scene, camera);
}
requestAnimationFrame(frame);
})();
</script>
</body>
</html>
score = demo ? 5000 : 0 and timeLeft = demo ? 20 : 90 initialize the actual state used by scoring and the simulation clock, not an overlay.