Skip to content
TheChatArchiveThe Chat Archive
Claudeclaude-3-5-haiku-20241022· AnthropicHugging Face LMArena Human Preference 140K

web dev: create a 3d racing game in one file, no npm stuff. synthwave aesthetic

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with chatgpt-4o-latest-20250326’s answer.
  1. User

    web dev: create a 3d racing game in one file, no npm stuff. synthwave aesthetic

  2. Claude Assistant

    Here's a single HTML file with JavaScript that creates a 3D racing game with a synthwave aesthetic using Three.js and WebGL. This example provides a basic racing game framework with a retro synthwave visual style:

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Synthwave Racer</title>
        <style>
            body { 
                margin: 0; 
                background: linear-gradient(to bottom, #000033, #000011);
                overflow: hidden;
                font-family: 'Arial', sans-serif;
                color: #00ffff;
            }
            #overlay {
                position: absolute;
                top: 10px;
                left: 10px;
                color: #00ffff;
                text-shadow: 0 0 10px #00ffff;
            }
        </style>
    </head>
    <body>
        <div id="overlay">Speed: 0 km/h</div>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
    
        <script>
            // Synthwave Racing Game
            class SynthwaveRacer {
                constructor() {
                    // Scene setup
                    this.scene = new THREE.Scene();
                    this.camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
                    this.renderer = new THREE.WebGLRenderer({ antialias: true });
                    this.renderer.setSize(window.innerWidth, window.innerHeight);
                    document.body.appendChild(this.renderer.domElement);
    
                    // Synthwave color palette
                    this.colors = {
                        road: 0x000033,
                        roadLine: 0x00ffff,
                        background: 0x000011
                    };
    
                    // Game state
                    this.speed = 0;
                    this.maxSpeed = 50;
                    this.acceleration = 0.1;
                    this.deceleration = 0.05;
                    this.playerPosition = 0;
    
                    this.setupScene();
                    this.setupControls();
                    this.animate();
                }
    
                setupScene() {
                    // Background
                    this.scene.background = new THREE.Color(this.colors.background);
                    this.scene.fog = new THREE.Fog(this.colors.background, 1, 500);
    
                    // Road
                    const roadGeometry = new THREE.PlaneGeometry(100, 1000);
                    const roadMaterial = new THREE.MeshBasicMaterial({ color: this.colors.road });
                    this.road = new THREE.Mesh(roadGeometry, roadMaterial);
                    this.road.rotation.x = -Math.PI / 2;
                    this.road.position.z = -200;
                    this.scene.add(this.road);
    
                    // Road lines
                    const lineGeometry = new THREE.PlaneGeometry(2, 1000);
                    const lineMaterial = new THREE.MeshBasicMaterial({ 
                        color: this.colors.roadLine, 
                        transparent: true, 
                        opacity: 0.5 
                    });
                    
                    this.leftLine = new THREE.Mesh(lineGeometry, lineMaterial);
                    this.rightLine = new THREE.Mesh(lineGeometry, lineMaterial);
                    
                    this.leftLine.rotation.x = -Math.PI / 2;
                    this.rightLine.rotation.x = -Math.PI / 2;
                    
                    this.leftLine.position.set(-25, 0.1, -200);
                    this.rightLine.position.set(25, 0.1, -200);
                    
                    this.scene.add(this.leftLine);
                    this.scene.add(this.rightLine);
    
                    // Camera positioning
                    this.camera.position.y = 20;
                    this.camera.position.z = 50;
                    this.camera.lookAt(0, 0, 0);
                }
    
                setupControls() {
                    window.addEventListener('keydown', (e) => {
                        switch(e.key) {
                            case 'ArrowUp':
                                this.speed = Math.min(this.speed + this.acceleration, this.maxSpeed);
                                break;
                            case 'ArrowDown':
                                this.speed = Math.max(this.speed - this.acceleration, 0);
                                break;
                            case 'ArrowLeft':
                                this.playerPosition = Math.max(this.playerPosition - 25, -25);
                                break;
                            case 'ArrowRight':
                                this.playerPosition = Math.min(this.playerPosition + 25, 25);
                                break;
                        }
                    });
                }
    
                animate() {
                    requestAnimationFrame(() => this.animate());
    
                    // Simulate road movement
                    this.road.position.z += this.speed / 10;
                    this.leftLine.position.z += this.speed / 10;
                    this.rightLine.position.z += this.speed / 10;
    
                    // Player horizontal movement
                    this.camera.position.x = this.playerPosition;
    
                    // Natural deceleration
                    this.speed = Math.max(this.speed - this.deceleration, 0);
    
                    // Update overlay
                    document.getElementById('overlay').innerText = `Speed: ${Math.round(this.speed)} km/h`;
    
                    // Render
                    this.renderer.render(this.scene, this.camera);
                }
            }
    
            // Initialize game on load
            window.onload = () => new SynthwaveRacer();
        </script>
    </body>
    </html>
    

    This single-file game includes:

    🌈 Synthwave Aesthetic Features:

    • Neon blue/cyan color scheme
    • Retro gradient background
    • Glowing road lines
    • Fog effect for depth

    🎮 Game Mechanics:

    • Arrow key controls
    • Acceleration and deceleration
    • Horizontal player movement
    • Speed display

    🕹️ Controls:

    • Up Arrow: Accelerate
    • Down Arrow: Brake
    • Left/Right Arrows: Move horizontally

    To play, simply open the HTML file in a modern browser. The game uses Three.js from a CDN, so no npm or build process is required.

    Potential Improvements:

    • Add obstacles
    • Implement scoring
    • Create more complex road generation
    • Add sound effects

    Enjoy your synthwave racing experience! 🚗✨

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.