Skip to content
TheChatArchiveThe Chat Archive
o3-2025-04-16· OpenAIHugging 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 Metallama-4-scout-17b-16e-instruct’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

    Below is a single-file Geometry-Dash–style mini-game.
    Everything (logic + graphics) lives in this one HTML document and every graphic is an inline SVG symbol, so there are zero external assets.

    Copy-paste the whole thing into a file (e.g. mini-dash.html) and open it in any modern browser.

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>Mini Geometry Dash – Single File Demo</title>
    <style>
        html,body{margin:0;height:100%;background:#111;display:flex;justify-content:center;align-items:center;font-family:Arial,Helvetica,sans-serif;color:#fff}
        #ui{position:absolute;top:10px;left:50%;transform:translateX(-50%);display:flex;gap:40px;font-size:18px;pointer-events:none}
        #game{
            box-shadow:0 0 20px #0ff;
            background:linear-gradient(#222 0%,#111 80%);
            border:2px solid #0ff;
            border-radius:6px;
            cursor:pointer
        }
        .flash{animation:flash .15s ease-in-out 3}
        @keyframes flash{50%{fill:#f00}}
    </style>
    </head>
    <body>
    <div id="ui">
        <div>Score: <span id="score">0</span></div>
        <div>Best: <span id="best">0</span></div>
        <div>(SPACE / CLICK to jump)</div>
    </div>
    
    <!-- =====================  GAME SVG  ========================== -->
    <svg id="game" width="800" height="400" viewBox="0 0 800 400" xmlns="http://www.w3.org/2000/svg">
        <!--  ----------  All reusable assets live in <defs>  -------- -->
        <defs>
            <!-- The cube -->
            <symbol id="cube" viewBox="0 0 40 40">
                <rect width="40" height="40" rx="6" ry="6" fill="#0cf" stroke="#0ff" stroke-width="4"/>
            </symbol>
    
            <!-- A spike (triangle) -->
            <symbol id="spike" viewBox="0 0 40 40">
                <polygon points="0,40 20,0 40,40" fill="#f33" stroke="#faa" stroke-width="3"/>
            </symbol>
    
            <!-- Ground tile – simple rectangle -->
            <symbol id="groundTile" viewBox="0 0 40 50">
                <rect y="10" width="40" height="40" fill="#070" />
                <rect y="0" width="40" height="10" fill="#090" />
            </symbol>
        </defs>
    
        <!-- -------- Static elements (background + ground line) -------- -->
        <!-- Ground line -->
        <rect class="groundLine"  y="350" width="800" height="2" fill="#0f0"/>
    
        <!-- Dynamic layers get appended here through JS -->
        <g id="groundLayer"></g>
        <g id="obstacleLayer"></g>
        <use id="player" href="#cube"/>
    </svg>
    
    <script>
    (() =>{
    /* ================= GAME CONSTANTS ================ */
    const svg      = document.getElementById('game');
    const player   = document.getElementById('player');
    const groundL  = 350;                // y coordinate of the ground
    const gravity  = 0.8;                // pixels / frame²
    const jumpVel  = -15;                // initial jump velocity
    const speed    = 6;                  // world scroll speed (px / frame)
    const spawnMin = 70;                 // min frames between obstacles
    const spawnMax = 140;                // max frames between obstacles
    const obstacleLayer = document.getElementById('obstacleLayer');
    const groundLayer   = document.getElementById('groundLayer');
    
    let frame    = 0;
    let nextSpawn= rand(spawnMin,spawnMax);
    let score    = 0;
    let best     = +localStorage.getItem('bestDash')||0;
    
    /* ========= PLAYER STATE ============ */
    const pl = {x:100, y: groundL-40, vy:0, size:40, alive:true};
    
    /* ==========  UI  ========== */
    const scoreEl = document.getElementById('score');
    const bestEl  = document.getElementById('best');
    bestEl.textContent = best;
    
    /* ========= HELPERS ========== */
    function rand(a,b){return Math.floor(Math.random()*(b-a+1))+a;}
    
    function setXY(el,x,y){
        el.setAttribute('transform',`translate(${x},${y})`);
    }
    
    /* ==========  GROUND (infinite tiling) ========== */
    const groundTiles = [];
    const tilesNeeded = Math.ceil(800/40)+2;
    for(let i=0;i<tilesNeeded;i++){
        const tile = document.createElementNS('http://www.w3.org/2000/svg','use');
        tile.setAttribute('href','#groundTile');
        groundLayer.appendChild(tile);
        groundTiles.push({el:tile,x:i*40});
        setXY(tile, i*40, groundL);
    }
    
    /* =========  GAME LOOP  ========== */
    function loop(){
        if(pl.alive){
            frame++;
            // --- Move ground tiles
            groundTiles.forEach(t=>{
                t.x -= speed;
                if(t.x <= -40){ t.x += tilesNeeded*40; }
                setXY(t.el, t.x, groundL);
            });
            // --- Spawn obstacles
            if(frame >= nextSpawn){
                spawnObstacle();
                frame=0;
                nextSpawn = rand(spawnMin,spawnMax);
            }
            // --- Move obstacles
            moveObstacles();
    
            // --- Apply physics to player
            pl.vy += gravity;
            pl.y  += pl.vy;
            if(pl.y >= groundL-40){ pl.y = groundL-40; pl.vy=0;}  // landed
            setXY(player, pl.x, pl.y);
    
            // --- Collision detection
            checkCollisions();
    
            // --- Scoring
            score += 1;
            scoreEl.textContent = score;
        }
        requestAnimationFrame(loop);
    }
    
    /* ========  Obstacles  =========== */
    const obstacles=[];
    function spawnObstacle(){
        const use = document.createElementNS('http://www.w3.org/2000/svg','use');
        use.setAttribute('href','#spike');
        obstacleLayer.appendChild(use);
        const obj = {el:use, x:800, y:groundL-40, w:40, h:40, passed:false};
        setXY(use, obj.x, obj.y);
        obstacles.push(obj);
    }
    function moveObstacles(){
        for(let i=obstacles.length-1;i>=0;i--){
            const o = obstacles[i];
            o.x -= speed;
            setXY(o.el, o.x, o.y);
            // remove off-screen
            if(o.x < -50){
                obstacleLayer.removeChild(o.el);
                obstacles.splice(i,1);
            }
        }
    }
    
    /* ======= COLLISION ======= */
    function checkCollisions(){
        obstacles.forEach(o=>{
            const colliding = !( pl.x+pl.size-8 < o.x || pl.x+8>o.x+o.w || pl.y+pl.size-8<o.y || pl.y+8>o.y+o.h );
            if(colliding){
                gameOver();
            }
        });
    }
    
    /* ======== INPUT (jump) ======== */
    window.addEventListener('keydown',e=>{
        if(e.code==='Space') jump();
    });
    svg.addEventListener('pointerdown',jump);
    
    function jump(){
        if(!pl.alive){
            resetGame();
            return;
        }
        if(pl.y>=groundL-40-1){ // on ground
            pl.vy = jumpVel;
        }
    }
    
    /* ======== GAME OVER / RESET ======== */
    function gameOver(){
        if(!pl.alive) return;
        pl.alive=false;
        player.classList.add('flash');
        if(score>best){best=score;localStorage.setItem('bestDash',best);bestEl.textContent=best;}
    }
    function resetGame(){
        // remove existing spikes
        obstacles.forEach(o=> obstacleLayer.removeChild(o.el));
        obstacles.length=0;
        score=0; scoreEl.textContent=0;
        pl.y=groundL-40; pl.vy=0; pl.alive=true;
        player.classList.remove('flash');
    }
    
    /* ============ KICK-OFF ============ */
    setXY(player, pl.x, pl.y);
    loop();
    })();
    </script>
    </body>
    </html>
    

    How to play • Press SPACE or click/tap the game area to jump.
    • Avoid the red spikes ― a collision ends the run.
    • Your current score (number of frames survived) is shown on the left; the best score is stored in localStorage, so it persists between page refreshes.

    Enjoy your mini-dash! 🚀

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