Skip to content
TheChatArchiveThe Chat Archive
grok-3-mini-high· xAIHugging Face LMArena Human Preference 140K

Write me a game like geometry dash in html5 and javascript, make everything in one html…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Claudeclaude-opus-4-20250514-thinking-16k’s answer.
  1. User

    Write me a game like geometry dash in html5 and javascript, make everything in one html file, desgin assets by creating svgs.

  2. Assistant
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Geometry Dash Clone</title>
        <style>
            body {
                margin: 0;
                overflow: hidden;
            }
            svg {
                width: 100vw;
                height: 100vh;
                background-color: black;
            }
        </style>
    </head>
    <body>
        <svg id="game" viewBox="0 0 800 600">
            <!-- Player group with a simple square -->
            <g id="playerGroup" transform="translate(100, 500)">
                <rect width="50" height="50" fill="white" />
            </g>
            <!-- Ground rectangle -->
            <rect x="0" y="550" width="800" height="50" fill="gray" />
            <!-- Score text -->
            <text id="scoreText" x="10" y="30" font-size="20" fill="white">Score: 0</text>
        </svg>
        <script>
            // Constants
            const gravity = 0.5; // Gravity strength per frame
            const jumpStrength = -12; // Jump velocity (negative for upward)
            const obstacleSpeed = -5; // Obstacle speed per frame (negative for leftward)
            const obstacleInterval = 2000; // Time in ms between obstacle spawns
            const groundY = 550; // Top y-position of the ground
            const playerWidth = 50; // Player width
            const playerHeight = 50; // Player height
            const obstacleWidth = 50; // Obstacle width
            const obstacleHeight = 50; // Obstacle height
    
            // Variables
            let playerX = 100; // Player x-position (fixed for now)
            let playerY = 500; // Player y-position
            let playerVY = 0; // Player vertical velocity
            let score = 0; // Score
            let lastObstacleTime = performance.now(); // Last time an obstacle was spawned
            let obstacles = []; // Array to hold obstacle objects
    
            // Get SVG elements
            const svg = document.getElementById('game');
            const playerGroup = document.getElementById('playerGroup');
            const scoreText = document.getElementById('scoreText');
    
            // Handle keyboard input for jumping
            document.addEventListener('keydown', (e) => {
                if (e.code === 'Space') {
                    if (playerY + playerHeight >= groundY) { // Only jump if on ground
                        playerVY = jumpStrength;
                    }
                }
            });
    
            // Function to create a new obstacle (spike shape using SVG polygon)
            function createObstacle() {
                const g = document.createElementNS("http://www.w3.org/2000/svg", "g");
                const poly = document.createElementNS("http://www.w3.org/2000/svg", "polygon");
                // Define a triangular spike shape (points relative to group origin)
                poly.setAttribute('points', '0,50 25,0 50,50');
                poly.setAttribute('fill', 'red');
                g.appendChild(poly);
                // Set initial transform to place it on the ground at the right edge
                g.setAttribute('transform', `translate(800, ${groundY - obstacleHeight})`);
                svg.appendChild(g);
                // Store obstacle data
                obstacles.push({ elem: g, x: 800, y: groundY - obstacleHeight });
            }
    
            // Function to reset the game
            function reset() {
                playerY = 500; // Reset player position
                playerVY = 0; // Reset velocity
                score = 0; // Reset score
                scoreText.textContent = `Score: 0`; // Update score display
                // Remove all obstacles
                obstacles.forEach(ob => svg.removeChild(ob.elem));
                obstacles = [];
                lastObstacleTime = performance.now(); // Reset obstacle timer
                // Reset player transform immediately
                playerGroup.setAttribute('transform', `translate(${playerX}, ${playerY})`);
            }
    
            // Game update loop
            function update() {
                const now = performance.now();
    
                // Update player position
                playerVY += gravity; // Apply gravity
                playerY += playerVY; // Update position based on velocity
                // Check for ground collision
                if (playerY + playerHeight > groundY) {
                    playerY = groundY - playerHeight; // Clamp to ground
                    playerVY = 0; // Stop falling
                }
                // Update player transform
                playerGroup.setAttribute('transform', `translate(${playerX}, ${playerY})`);
    
                // Update obstacles
                obstacles.forEach(ob => {
                    ob.x += obstacleSpeed; // Move obstacle left
                    ob.elem.setAttribute('transform', `translate(${ob.x}, ${ob.y})`);
                });
    
                // Remove off-screen obstacles and increase score
                obstacles = obstacles.filter(ob => {
                    if (ob.x < -obstacleWidth) {
                        svg.removeChild(ob.elem); // Remove from SVG
                        score += 10; // Increase score when obstacle passes
                        return false; // Remove from array
                    }
                    return true; // Keep in array
                });
    
                // Spawn new obstacle if interval passed
                if (now - lastObstacleTime > obstacleInterval) {
                    createObstacle();
                    lastObstacleTime = now;
                }
    
                // Update score display
                scoreText.textContent = `Score: ${Math.floor(score)}`;
    
                // Check for collisions with obstacles
                obstacles.forEach(ob => {
                    const obLeft = ob.x;
                    const obRight = ob.x + obstacleWidth;
                    const obTop = ob.y;
                    const obBottom = ob.y + obstacleHeight;
                    const playerLeft = playerX;
                    const playerRight = playerX + playerWidth;
                    const playerTop = playerY;
                    const playerBottom = playerY + playerHeight;
    
                    // Simple AABB collision detection
                    if (playerLeft < obRight && playerRight > obLeft && playerTop < obBottom && playerBottom > obTop) {
                        reset(); // Reset game on collision
                    }
                });
    
                // Request next frame
                requestAnimationFrame(update);
            }
    
            // Start the game loop
            update();
        </script>
    </body>
    </html>
    

    Explanation:

    • Game Mechanics: This is a simple clone of Geometry Dash with a square player that can jump using the spacebar. Obstacles (spikes) move from right to left, and the game ends (resets) on collision. Score increases when obstacles are passed off-screen.
    • SVG Assets: All visual elements are created using SVG:
      • Player: A white square defined as a <rect> inside a <g> group for easy transformation.
      • Obstacles: Spikes are created as <polygon> elements with points defining a triangular shape, grouped in <g> for translation.
      • Ground: A gray rectangle at the bottom.
      • Score: Displayed using an SVG <text> element.
    • JavaScript Logic: Handles game loop with requestAnimationFrame, player movement with gravity and jumping, obstacle spawning and movement, collision detection, and scoring.
    • Single HTML File: Everything is contained in one file, with CSS in a <style> tag and JavaScript in a <script> tag. No external resources are used.
    • Performance and Simplicity: Uses SVG for rendering and animation by updating transform attributes. Collision is based on axis-aligned bounding boxes (AABB) for simplicity.
    • Customization: You can tweak constants like gravity, jumpStrength, obstacleSpeed, and obstacleInterval to adjust difficulty. The game resets on collision for ease of play.

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