Skip to content

gitflarePublicPartly agent-ready40

neon-drift

Real-time multiplayer arcade racer on Cloudflare Workers and Durable Objects.

main
Add the Apache-2.0 licence3efe3da
JavaScript29 lines1.0 KB
import test from 'node:test';import assert from 'node:assert/strict';import { cameraTarget, createFx } from '../public/fx.js';import { createAudio } from '../public/audio.js'; test('camera look-ahead and zoom', () => {  const o = {};  cameraTarget({ x: 0, y: 0, heading: 0, boost: 0 }, { warn: 0 }, 'playing', 1, o);  assert.equal(Math.round(o.x), 120);  const z0 = o.zoom;  cameraTarget({ x: 0, y: 0, heading: 0, boost: 1 }, { warn: 1 }, 'playing', 1, o);  assert.ok(o.zoom >= z0 * 0.85 - 1e-9 && o.zoom < z0);  cameraTarget({ x: 0, y: 0, heading: 0, boost: 0 }, { warn: 0 }, 'countdown', 1, o);  assert.ok(o.zoom > z0);});test('fx pool and rings', () => {  const f = createFx();  assert.ok(f.count >= 800);  f.burst(0, 0, 10, 80, 300); f.ring(0, 0, 10, 100, 0.5);  f.update(0.1);  assert.ok(f.rl[0] > 0);  f.update(1); assert.ok(f.rl[0] <= 0);});test('audio mute without context is safe', () => {  const a = createAudio();  a.setMuted(true); assert.equal(a.muted, true);  a.play('crash'); a.engine(1);});