Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ Desktop:

On touch devices, the game displays a wide steering surface on the left and large throttle/brake controls on the right, plus **AUTO** and **RESET** buttons. Landscape orientation is recommended but portrait remains usable.

Standard-mapped Xbox and PlayStation-style gamepads are supported. The left stick steers, RT/R2 accelerates, LT/L2 brakes, A/Cross applies the handbrake channel, Y/Triangle changes camera, B/Circle resets the car, the D-pad adjusts cruise speed or changes music, Start/Options opens settings, and the right stick orbits the camera. Deadzones, vibration, and connection status are available under **CONTROLS** in the settings panel.

Steering takes over from autopilot immediately, while braking disengages both autopilot and cruise control. The accelerator remains available as a temporary speed override.

The instrument-style cruise panel sets a shared target from 5 to 375 km/h for both manual driving and autopilot. In manual mode cruise controls the pedals while the player steers. Holding the accelerator temporarily overrides the target for a smooth boost; releasing it returns to the selected speed. Braking disengages both cruise control and autopilot. Steering takes over from autopilot without dropping the active cruise target.
Expand Down Expand Up @@ -85,7 +87,7 @@ Landscape detail is split into near (88 m), mid (280 m), and far (820 m) zones.
- `src/game` — main loop, renderer, scene, resize handling, damped cameras
- `src/world` — deterministic road function, chunk pool, terrain, procedural vegetation factory, instancing, shader wind, and LOD
- `src/vehicle` — original lofted muscle-coupe model, lightweight vehicle dynamics, autopilot
- `src/input` — keyboard and Pointer Events input
- `src/input` — unified keyboard, Pointer Events, and standard Gamepad API input
- `src/audio` — synthesized engine and band-limited tire rumble, plus a very low-level oscillator airflow layer without looping white-noise wind
- `src/ui` — start screen and responsive HUD
- `src/config` — centralized tuning values
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"prebuild": "npm run music:manifest",
"build": "tsc -b && vite build",
"typecheck": "tsc -b --pretty false",
"test:regions": "node scripts/run-region-probes.mjs",
"preview": "vite preview"
},
"dependencies": {
Expand Down
56 changes: 56 additions & 0 deletions scripts/run-region-probes.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { build } from 'esbuild';

globalThis.matchMedia ??= () => ({ matches: false });
globalThis.navigator ??= { maxTouchPoints: 0, userAgent: 'region-probe' };
globalThis.requestIdleCallback ??= () => 1;
globalThis.cancelIdleCallback ??= () => undefined;
globalThis.window ??= globalThis;

const source = `
import { CONFIG } from './src/config/gameConfig.ts';
import { InfiniteWorld } from './src/world/InfiniteWorld.ts';
import { RoadGenerator } from './src/world/RoadGenerator.ts';
import { runRegionScheduleProbe } from './src/world/WorldRegionDirector.ts';
export function run() {
const road = new RoadGenerator(CONFIG.seed);
const world = new InfiniteWorld();
const schedule = runRegionScheduleProbe(CONFIG.seed, 1_000_000);
const continuity = road.runRegionContinuityProbe(1_000_000);
const bridgeSurface = road.runBridgeSurfaceProbe();
const riverCorridor = road.runRiverCorridorProbe();
const fieldParcels = road.fieldParcels.runProbe();
const firstFields = world.road.regions.nextSpecial(0, 'fields');
world.update(firstFields.startDistance + firstFields.transitionDistance + 500, true);
const fieldRender = world.getDebugStats();
const lifecycle = world.runRegionLifecycleProbe(500_000);
const fieldPerformance = fieldRender.chunks === fieldRender.expectedActiveChunks && fieldRender.sceneObjects < 3500;
return { schedule, continuity, bridgeSurface, riverCorridor, fieldParcels,
fieldRender: { chunks: fieldRender.chunks, sceneObjects: fieldRender.sceneObjects,
vegetationInstances: fieldRender.vegetationInstances, trees: fieldRender.treesNear + fieldRender.treesMid + fieldRender.treesFar,
shrubs: fieldRender.shrubs, grassPlants: fieldRender.grassPlants }, lifecycle,
passed: schedule.passed && continuity && bridgeSurface && riverCorridor && fieldParcels.passed && fieldPerformance && lifecycle.passed };
}
`;

const bundle = await build({
stdin: { contents: source, resolveDir: process.cwd(), loader: 'ts' },
bundle: true,
platform: 'node',
format: 'esm',
write: false,
logLevel: 'silent',
define: {
'import.meta.env.DEV': 'false',
'import.meta.env.PROD': 'true'
}
});
const encoded = Buffer.from(bundle.outputFiles[0].text).toString('base64');
try {
const module = await import(`data:text/javascript;base64,${encoded}`);
const result = module.run();
console.log(JSON.stringify(result, null, 2));
if (!result.passed) process.exitCode = 1;
} catch (error) {
console.error(error instanceof Error ? `${error.name}: ${error.message}` : String(error));
process.exitCode = 1;
}
3 changes: 3 additions & 0 deletions src/audio/MusicPlayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,9 @@ export class MusicPlayer {
if (play) void this.play().catch(() => this.renderPlayback());
}

previousTrack(): void { this.previous(); }
nextTrack(): void { this.next(true); }

private async togglePlay(): Promise<void> {
if (this.tracks.length === 0) return;
if (this.audio.paused) await this.play().catch(() => undefined);
Expand Down
8 changes: 7 additions & 1 deletion src/config/GraphicsSettings.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { DEFAULT_VEHICLE_COLOR, isVehicleColor } from './VehicleColors';

export type TimeMode = 'day' | 'night' | 'auto';
export type CloudQuality = 'low' | 'medium' | 'high';

export interface GraphicsSettings {
vehicleColor: string;
renderScale: number; drawDistance: number; terrainDistance: number;
treeNearDistance: number; treeMidDistance: number; treeFarDistance: number; bushDistance: number; grassDistance: number;
vegetationDensity: number; grassDensity: number; bushDensity: number; treeDensity: number; objectDensity: number;
Expand All @@ -15,6 +18,7 @@ export interface GraphicsSettings {
}

export const DEFAULT_GRAPHICS_SETTINGS: Readonly<GraphicsSettings> = {
vehicleColor: DEFAULT_VEHICLE_COLOR,
renderScale: 1, drawDistance: 700, terrainDistance: 800,
treeNearDistance: 95, treeMidDistance: 260, treeFarDistance: 600, bushDistance: 200, grassDistance: 65,
vegetationDensity: 100, grassDensity: 100, bushDensity: 100, treeDensity: 100, objectDensity: 100,
Expand All @@ -32,7 +36,9 @@ const STORAGE_KEY = 'quiet-mile.graphics.v2';
export function loadGraphicsSettings(): GraphicsSettings {
try {
const parsed = JSON.parse(localStorage.getItem(STORAGE_KEY) ?? '{}') as Partial<GraphicsSettings>;
return { ...DEFAULT_GRAPHICS_SETTINGS, ...parsed };
const settings = { ...DEFAULT_GRAPHICS_SETTINGS, ...parsed };
settings.vehicleColor = isVehicleColor(parsed.vehicleColor) ? parsed.vehicleColor.toLowerCase() : DEFAULT_VEHICLE_COLOR;
return settings;
} catch { return { ...DEFAULT_GRAPHICS_SETTINGS }; }
}

Expand Down
29 changes: 29 additions & 0 deletions src/config/VehicleColors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
export interface VehicleColorOption {
readonly name: string;
readonly value: string;
}

export const VEHICLE_COLORS: readonly VehicleColorOption[] = [
{ name: 'Black', value: '#101315' },
{ name: 'Graphite', value: '#343a3d' },
{ name: 'Silver', value: '#a5aaad' },
{ name: 'White', value: '#d7d6d0' },
{ name: 'Dark Red', value: '#8e1f17' },
{ name: 'Classic Red', value: '#b52a20' },
{ name: 'Burgundy', value: '#5d1720' },
{ name: 'Orange', value: '#b8511e' },
{ name: 'Yellow', value: '#c3a52f' },
{ name: 'British Green', value: '#193f2f' },
{ name: 'Dark Green', value: '#173027' },
{ name: 'Teal', value: '#1d5a5b' },
{ name: 'Dark Blue', value: '#172b49' },
{ name: 'Classic Blue', value: '#245486' },
{ name: 'Purple', value: '#4b315f' },
{ name: 'Bronze / Copper', value: '#8a5639' }
];

export const DEFAULT_VEHICLE_COLOR = '#8e1f17';

export function isVehicleColor(value: unknown): value is string {
return typeof value === 'string' && VEHICLE_COLORS.some((option) => option.value === value.toLowerCase());
}
13 changes: 13 additions & 0 deletions src/game/CameraController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,19 @@ export class CameraController {

setEffects(settings: GraphicsSettings): void { this.settings = settings; }

applyGamepadOrbit(x: number, y: number, dt: number): void {
if (x === 0 && y === 0) {
if (this.orbitPointer === null) this.isUserOrbiting = false;
return;
}
if (this.mode === 2) return;
this.targetOrbitYaw = this.wrapAngle(this.targetOrbitYaw - x * 2.25 * dt);
this.targetOrbitPitch = MathUtils.clamp(this.targetOrbitPitch - y * 1.7 * dt,
CONFIG.camera.orbitMinPitch, CONFIG.camera.orbitMaxPitch);
this.lastUserCameraInputTime = performance.now() * .001;
this.isUserOrbiting = true;
}

update(dt: number, vehicle: Vehicle, bass?: BassAnalysis): void {
this.elapsed += dt;
// Remove last frame's presentation-only kick before calculating the
Expand Down
Loading
Loading