Skip to content
TheChatArchiveThe Chat Archive
Kimikimi-k2-0711-preview· Moonshot AIHugging Face LMArena Human Preference 140K

Create a single HTML file game project that combines mechanics from Brotato, Vampire…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Qwenqwen-max-2025-01-25’s answer.
  1. User

    Create a single HTML file game project that combines mechanics from Brotato, Vampire Survivors, and Snake. The game should be implemented entirely in JavaScript within one large HTML file.

    Core Mechanics:

    • Snake-like movement using W/A/S/D keys
    • Player controls a snake with a head and segments, each having independent health
    • Auto-combat system where segments automatically attack nearby enemies
    • Experience points and leveling system with upgrade choices

    Experience & Leveling System:

    • Gain 10% experience by collecting randomly spawning fruits
    • Different fruit types provide varying experience percentages
    • Upon leveling up, pause the game and present 4 upgrade options (or skip option)
    • Upgrades should include adding 1+ snake segments based on rarity quality

    Rarity System & Upgrades:

    • Common (White): 0-1 additional segments, basic rewards (healing, currency)
    • Rare (Blue): 0-2 additional segments, stat improvements (healing, max HP, stat boosts)
    • Epic (Purple): [specify rewards and segment count]
    • Legendary (Gold): [specify rewards and segment count]
    • Mythic (Red): [specify rewards and segment count]

    Combat & Segments:

    • Each snake segment can equip weapons (ranged or melee)
    • Segments influence nearby segments with buffs/effects
    • Head and segments have separate health pools
    • Lost segments regenerate only when advancing to the next stage

    Stage System:

    • Each stage lasts exactly 1 minute
    • Infinite stage progression
    • Shop available between stages
    • Equipment inventory showing head and owned segments with descriptions and statistics

    Technical Requirements:

    • FPS counter display
    • FPS limiter with slider (disabled, 30-300 FPS range)
    • All graphics as 64x64 pixel-style SVG images generated from code
    • Responsive controls and smooth gameplay

    Visual Style:

    • Pixel art aesthetic using programmatically generated SVG graphics
    • All textures, graphics, and models created as inline SVG code
    • 64x64 pixel resolution for all visual elements

    Please implement this as a complete, playable game in a single HTML file with embedded CSS and JavaScript.

  2. Kimi Assistant
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Snake Survivors</title>
        <style>
            * {
                margin: 0;
                padding: 0;
                box-sizing: border-box;
            }
            
            body {
                background: #111;
                color: #fff;
                font-family: 'Courier New', monospace;
                overflow: hidden;
                display: flex;
                justify-content: center;
                align-items: center;
                height: 100vh;
            }
            
            #gameContainer {
                position: relative;
                width: 800px;
                height: 600px;
                border: 2px solid #333;
                background: #000;
            }
            
            #gameCanvas {
                position: absolute;
                top: 0;
                left: 0;
                image-rendering: pixelated;
                image-rendering: -moz-crisp-edges;
                image-rendering: crisp-edges;
            }
            
            #ui {
                position: absolute;
                top: 10px;
                left: 10px;
                z-index: 10;
                font-size: 14px;
                text-shadow: 2px 2px 0 #000;
            }
            
            #fpsCounter {
                position: absolute;
                top: 10px;
                right: 10px;
                z-index: 10;
                font-size: 14px;
                color: #0f0;
            }
            
            #fpsSlider {
                position: absolute;
                top: 30px;
                right: 10px;
                z-index: 10;
                width: 150px;
            }
            
            #upgradePanel {
                position: absolute;
                top: 50%;
                left: 50%;
                transform: translate(-50%, -50%);
                background: rgba(0, 0, 0, 0.9);
                border: 2px solid #fff;
                padding: 20px;
                display: none;
                z-index: 100;
                text-align: center;
            }
            
            .upgradeOption {
                display: inline-block;
                width: 200px;
                margin: 10px;
                padding: 10px;
                border: 1px solid #666;
                cursor: pointer;
                transition: all 0.3s;
            }
            
            .upgradeOption:hover {
                border-color: #fff;
                transform: scale(1.05);
            }
            
            .common { border-color: #fff; }
            .rare { border-color: #00f; }
            .epic { border-color: #f0f; }
            .legendary { border-color: #ff0; }
            .mythic { border-color: #f00; }
            
            #shopPanel {
                position: absolute;
                top: 50%;
                left: 50%;
                transform: translate(-50%, -50%);
                background: rgba(0, 0, 0, 0.9);
                border: 2px solid #fff;
                padding: 20px;
                display: none;
                z-index: 100;
                max-height: 80vh;
                overflow-y: auto;
            }
            
            .shopItem {
                margin: 10px;
                padding: 10px;
                border: 1px solid #666;
                cursor: pointer;
            }
            
            .shopItem:hover {
                background: rgba(255, 255, 255, 0.1);
            }
            
            #inventoryPanel {
                position: absolute;
                top: 50%;
                left: 50%;
                transform: translate(-50%, -50%);
                background: rgba(0, 0, 0, 0.9);
                border: 2px solid #fff;
                padding: 20px;
                display: none;
                z-index: 100;
                max-height: 80vh;
                overflow-y: auto;
            }
            
            .inventorySlot {
                display: inline-block;
                width: 100px;
                height: 100px;
                margin: 5px;
                border: 1px solid #666;
                position: relative;
                background: rgba(255, 255, 255, 0.1);
            }
            
            .inventorySlot img {
                width: 100%;
                height: 100%;
                image-rendering: pixelated;
            }
            
            .tooltip {
                position: absolute;
                background: rgba(0, 0, 0, 0.9);
                border: 1px solid #fff;
                padding: 5px;
                font-size: 12px;
                display: none;
                z-index: 200;
                pointer-events: none;
            }
        </style>
    </head>
    <body>
        <div id="gameContainer">
            <canvas id="gameCanvas" width="800" height="600"></canvas>
            
            <div id="ui">
                <div>Health: <span id="healthDisplay">100/100</span></div>
                <div>Level: <span id="levelDisplay">1</span></div>
                <div>XP: <span id="xpDisplay">0/100</span></div>
                <div>Stage: <span id="stageDisplay">1</span></div>
                <div>Time: <span id="timeDisplay">60</span></div>
                <div>Gold: <span id="goldDisplay">0</span></div>
                <div>Segments: <span id="segmentsDisplay">1</span></div>
            </div>
            
            <div id="fpsCounter">FPS: 0</div>
            <input type="range" id="fpsSlider" min="0" max="300" value="0" step="30">
            
            <div id="upgradePanel">
                <h2>Choose an Upgrade</h2>
                <div id="upgradeOptions"></div>
                <button onclick="skipUpgrade()">Skip</button>
            </div>
            
            <div id="shopPanel">
                <h2>Shop</h2>
                <div id="shopItems"></div>
                <button onclick="closeShop()">Close</button>
            </div>
            
            <div id="inventoryPanel">
                <h2>Inventory</h2>
                <div id="inventorySlots"></div>
                <button onclick="closeInventory()">Close</button>
            </div>
            
            <div class="tooltip" id="tooltip"></div>
        </div>
    
        <script>
            const canvas = document.getElementById('gameCanvas');
            const ctx = canvas.getContext('2d');
            ctx.imageSmoothingEnabled = false;
    
            // Game state
            let gameState = {
                paused: false,
                stage: 1,
                stageTime: 60,
                gold: 0,
                inventory: [],
                shopItems: []
            };
    
            // Player
            let player = {
                x: 400,
                y: 300,
                vx: 0,
                vy: 0,
                speed: 2,
                level: 1,
                xp: 0,
                xpToNext: 100,
                segments: [{
                    x: 400,
                    y: 300,
                    health: 100,
                    maxHealth: 100,
                    weapon: null,
                    buffs: []
                }],
                head: {
                    health: 100,
                    maxHealth: 100,
                    weapon: null
                }
            };
    
            // Input
            const keys = {};
            document.addEventListener('keydown', (e) => keys[e.key.toLowerCase()] = true);
            document.addEventListener('keyup', (e) => keys[e.key.toLowerCase()] = false);
    
            // FPS counter
            let lastTime = 0;
            let fps = 0;
            let frameCount = 0;
            let fpsInterval = 0;
            const fpsSlider = document.getElementById('fpsSlider');
    
            // Game objects
            let fruits = [];
            let enemies = [];
            let projectiles = [];
    
            // SVG graphics generator
            function createSVG(width, height, content) {
                return `data:image/svg+xml;base64,${btoa(`
                    <svg width="${width}" height="${height}" viewBox="0 0 ${width} ${height}" xmlns="http://www.w3.org/2000/svg">
                        ${content}
                    </svg>
                `)}`;
            }
    
            // Create pixel art textures
            const textures = {
                playerHead: createSVG(64, 64, `
                    <rect x="8" y="8" width="48" height="48" fill="#0f0"/>
                    <rect x="16" y="16" width="8" height="8" fill="#000"/>
                    <rect x="40" y="16" width="8" height="8" fill="#000"/>
                    <rect x="24" y="32" width="16" height="8" fill="#000"/>
                `),
                playerSegment: createSVG(64, 64, `
                    <rect x="8" y="8" width="48" height="48" fill="#0a0"/>
                    <rect x="12" y="12" width="40" height="40" fill="#0f0"/>
                `),
                enemy: createSVG(64, 64, `
                    <rect x="8" y="8" width="48" height="48" fill="#f00"/>
                    <rect x="16" y="16" width="8" height="8" fill="#fff"/>
                    <rect x="40" y="16" width="8" height="8" fill="#fff"/>
                    <rect x="20" y="32" width="24" height="8" fill="#fff"/>
                `),
                fruit: createSVG(64, 64, `
                    <circle cx="32" cy="32" r="24" fill="#ff0"/>
                    <circle cx="28" cy="28" r="4" fill="#000"/>
                `),
                projectile: createSVG(16, 16, `
                    <circle cx="8" cy="8" r="6" fill="#fff"/>
                `)
            };
    
            // Load images
            const images = {};
            Object.entries(textures).forEach(([key, src]) => {
                images[key] = new Image();
                images[key].src = src;
            });
    
            // Upgrade system
            const upgradeTiers = {
                common: { color: '#fff', minSegments: 0, maxSegments: 1 },
                rare: { color: '#00f', minSegments: 0, maxSegments: 2 },
                epic: { color: '#f0f', minSegments: 1, maxSegments: 2 },
                legendary: { color: '#ff0', minSegments: 1, maxSegments: 3 },
                mythic: { color: '#f00', minSegments: 2, maxSegments: 4 }
            };
    
            const upgradePool = {
                common: [
                    { name: 'Heal', effect: () => healPlayer(20), description: 'Heal 20 HP' },
                    { name: 'Gold', effect: () => addGold(10), description: 'Gain 10 gold' }
                ],
                rare: [
                    { name: 'Max Health', effect: () => increaseMaxHealth(20), description: '+20 max HP' },
                    { name: 'Speed Boost', effect: () => increaseSpeed(0.5), description: '+0.5 speed' }
                ],
                epic: [
                    { name: 'Multi Shot', effect: () => addWeapon('multishot'), description: 'Shoot 3 projectiles' },
                    { name: 'Life Steal', effect: () => addBuff('lifesteal'), description: 'Heal on hit' }
                ],
                legendary: [
                    { name: 'Explosive Rounds', effect: () => addWeapon('explosive'), description: 'Explosive projectiles' },
                    { name: 'Shield', effect: () => addBuff('shield'), description: 'Damage shield' }
                ],
                mythic: [
                    { name: 'God Mode', effect: () => addBuff('godmode'), description: 'Invincible for 10s' },
                    { name: 'Instant Kill', effect: () => addWeapon('instakill'), description: 'One-shot enemies' }
                ]
            };
    
            // Game functions
            function healPlayer(amount) {
                player.head.health = Math.min(player.head.health + amount, player.head.maxHealth);
                player.segments.forEach(seg => {
                    seg.health = Math.min(seg.health + amount, seg.maxHealth);
                });
            }
    
            function addGold(amount) {
                gameState.gold += amount;
            }
    
            function increaseMaxHealth(amount) {
                player.head.maxHealth += amount;
                player.head.health += amount;
                player.segments.forEach(seg => {
                    seg.maxHealth += amount;
                    seg.health += amount;
                });
            }
    
            function increaseSpeed(amount) {
                player.speed += amount;
            }
    
            function addWeapon(type) {
                // Add weapon to a random segment
                const target = Math.floor(Math.random() * (player.segments.length + 1));
                if (target === 0) {
                    player.head.weapon = type;
                } else {
                    player.segments[target - 1].weapon = type;
                }
            }
    
            function addBuff(type) {
                const target = Math.floor(Math.random() * player.segments.length);
                player.segments[target].buffs.push(type);
            }
    
            function spawnFruit() {
                if (fruits.length < 5) {
                    fruits.push({
                        x: Math.random() * (canvas.width - 64),
                        y: Math.random() * (canvas.height - 64),
                        type: Math.random() < 0.1 ? 'rare' : 'common',
                        value: Math.random() < 0.1 ? 0.2 : 0.1
                    });
                }
            }
    
            function spawnEnemy() {
                const side = Math.floor(Math.random() * 4);
                let x, y;
                switch(side) {
                    case 0: x = -32; y = Math.random() * canvas.height; break;
                    case 1: x = canvas.width + 32; y = Math.random() * canvas.height; break;
                    case 2: x = Math.random() * canvas.width; y = -32; break;
                    case 3: x = Math.random() * canvas.width; y = canvas.height + 32; break;
                }
                
                enemies.push({
                    x: x,
                    y: y,
                    health: 50 + gameState.stage * 10,
                    speed: 1 + gameState.stage * 0.1,
                    damage: 10 + gameState.stage * 2,
                    size: 32
                });
            }
    
            function updatePlayer() {
                if (gameState.paused) return;
    
                // Movement
                if (keys['w']) player.vy = -player.speed;
                else if (keys['s']) player.vy = player.speed;
                else player.vy = 0;
    
                if (keys['a']) player.vx = -player.speed;
                else if (keys['d']) player.vx = player.speed;
                else player.vx = 0;
    
                // Update head position
                player.x += player.vx;
                player.y += player.vy;
    
                // Keep in bounds
                player.x = Math.max(32, Math.min(canvas.width - 32, player.x));
                player.y = Math.max(32, Math.min(canvas.height - 32, player.y));
    
                // Update segments
                for (let i = 0; i < player.segments.length; i++) {
                    const target = i === 0 ? { x: player.x, y: player.y } : player.segments[i - 1];
                    const segment = player.segments[i];
                    
                    const dx = target.x - segment.x;
                    const dy = target.y - segment.y;
                    const dist = Math.sqrt(dx * dx + dy * dy);
                    
                    if (dist > 48) {
                        segment.x += (dx / dist) * (dist - 48);
                        segment.y += (dy / dist) * (dist - 48);
                    }
                }
    
                // Auto-attack
                attackNearby();
            }
    
            function attackNearby() {
                // Head attacks
                if (player.head.weapon) {
                    const nearest = findNearestEnemy(player.x, player.y);
                    if (nearest) {
                        shootProjectile(player.x, player.y, nearest.x, nearest.y, player.head.weapon);
                    }
                }
    
                // Segment attacks
                player.segments.forEach((segment, index) => {
                    if (segment.weapon) {
                        const nearest = findNearestEnemy(segment.x, segment.y);
                        if (nearest) {
                            shootProjectile(segment.x, segment.y, nearest.x, nearest.y, segment.weapon);
                        }
                    }
                });
            }
    
            function findNearestEnemy(x, y) {
                let nearest = null;
                let minDist = Infinity;
                
                enemies.forEach(enemy => {
                    const dist = Math.sqrt((enemy.x - x) ** 2 + (enemy.y - y) ** 2);
                    if (dist < minDist && dist < 200) {
                        minDist = dist;
                        nearest = enemy;
                    }
                });
                
                return nearest;
            }
    
            function shootProjectile(x, y, targetX, targetY, type) {
                const angle = Math.atan2(targetY - y, targetX - x);
                
                if (type === 'multishot') {
                    for (let i = -1; i <= 1; i++) {
                        projectiles.push({
                            x: x,
                            y: y,
                            vx: Math.cos(angle + i * 0.3) * 5,
                            vy: Math.sin(angle + i * 0.3) * 5,
                            damage: 10,
                            type: type
                        });
                    }
                } else {
                    projectiles.push({
                        x: x,
                        y: y,
                        vx: Math.cos(angle) * 5,
                        vy: Math.sin(angle) * 5,
                        damage: type === 'instakill' ? 9999 : 20,
                        type: type
                    });
                }
            }
    
            function updateEnemies() {
                enemies.forEach(enemy => {
                    // Move towards player
                    const dx = player.x - enemy.x;
                    const dy = player.y - enemy.y;
                    const dist = Math.sqrt(dx * dx + dy * dy);
                    
                    if (dist > 0) {
                        enemy.x += (dx / dist) * enemy.speed;
                        enemy.y += (dy / dist) * enemy.speed;
                    }
    
                    // Check collision with player
                    if (dist < 32) {
                        player.head.health -= enemy.damage;
                        if (player.head.health <= 0) {
                            // Game over
                            alert('Game Over!');
                            location.reload();
                        }
                    }
    
                    // Check collision with segments
                    player.segments.forEach(segment => {
                        const segDist = Math.sqrt((segment.x - enemy.x) ** 2 + (segment.y - enemy.y) ** 2);
                        if (segDist < 32) {
                            segment.health -= enemy.damage;
                            if (segment.health <= 0) {
                                // Remove segment
                                const index = player.segments.indexOf(segment);
                                player.segments.splice(index, 1);
                            }
                        }
                    });
                });
            }
    
            function updateProjectiles() {
                projectiles.forEach((proj, index) => {
                    proj.x += proj.vx;
                    proj.y += proj.vy;
    
                    // Check bounds
                    if (proj.x < 0 || proj.x > canvas.width || proj.y < 0 || proj.y > canvas.height) {
                        projectiles.splice(index, 1);
                        return;
                    }
    
                    // Check enemy collision
                    enemies.forEach((enemy, enemyIndex) => {
                        const dist = Math.sqrt((enemy.x - proj.x) ** 2 + (enemy.y - proj.y) ** 2);
                        if (dist < enemy.size) {
                            enemy.health -= proj.damage;
                            if (enemy.health <= 0) {
                                enemies.splice(enemyIndex, 1);
                                gameState.gold += 5;
                            }
                            projectiles.splice(index, 1);
                        }
                    });
                });
            }
    
            function checkCollisions() {
                // Check fruit collection
                fruits.forEach((fruit, index) => {
                    const dist = Math.sqrt((player.x - fruit.x - 32) ** 2 + (player.y - fruit.y - 32) ** 2);
                    if (dist < 48) {
                        player.xp += Math.floor(player.xpToNext * fruit.value);
                        fruits.splice(index, 1);
                        
                        if (player.xp >= player.xpToNext) {
                            levelUp();
                        }
                    }
                });
            }
    
            function levelUp() {
                player.level++;
                player.xp = 0;
                player.xpToNext = Math.floor(player.xpToNext * 1.5);
                gameState.paused = true;
                showUpgradePanel();
            }
    
            function showUpgradePanel() {
                const panel = document.getElementById('upgradePanel');
                const options = document.getElementById('upgradeOptions');
                options.innerHTML = '';
                
                // Generate 4 random upgrades
                for (let i = 0; i < 4; i++) {
                    const tier = getRandomTier();
                    const tierData = upgradeTiers[tier];
                    const upgrades = upgradePool[tier];
                    const upgrade = upgrades[Math.floor(Math.random() * upgrades.length)];
                    
                    const option = document.createElement('div');
                    option.className = `upgradeOption ${tier}`;
                    option.innerHTML = `
                        <h3>${upgrade.name}</h3>
                        <p>${upgrade.description}</p>
                        <p>Segments: +${tierData.minSegments}-${tierData.maxSegments}</p>
                    `;
                    
                    option.onclick = () => selectUpgrade(upgrade, tier);
                    options.appendChild(option);
                }
                
                panel.style.display = 'block';
            }
    
            function getRandomTier() {
                const rand = Math.random();
                if (rand < 0.5) return 'common';
                if (rand < 0.75) return 'rare';
                if (rand < 0.9) return 'epic';
                if (rand < 0.98) return 'legendary';
                return 'mythic';
            }
    
            function selectUpgrade(upgrade, tier) {
                upgrade.effect();
                
                const tierData = upgradeTiers[tier];
                const segmentsToAdd = tierData.minSegments + Math.floor(Math.random() * (tierData.maxSegments - tierData.minSegments + 1));
                
                for (let i = 0; i < segmentsToAdd; i++) {
                    player.segments.push({
                        x: player.x,
                        y: player.y,
                        health: player.head.maxHealth,
                        maxHealth: player.head.maxHealth,
                        weapon: null,
                        buffs: []
                    });
                }
                
                closeUpgradePanel();
            }
    
            function skipUpgrade() {
                closeUpgradePanel();
            }
    
            function closeUpgradePanel() {
                document.getElementById('upgradePanel').style.display = 'none';
                gameState.paused = false;
            }
    
            function updateStage() {
                gameState.stageTime -= 1/60;
                if (gameState.stageTime <= 0) {
                    nextStage();
                }
            }
    
            function nextStage() {
                gameState.stage++;
                gameState.stageTime = 60;
                
                // Regenerate segments
                const segmentCount = player.segments.length;
                player.segments = [];
                for (let i = 0; i < segmentCount; i++) {
                    player.segments.push({
                        x: player.x,
                        y: player.y,
                        health: player.head.maxHealth,
                        maxHealth: player.head.maxHealth,
                        weapon: null,
                        buffs: []
                    });
                }
                
                // Show shop
                showShop();
            }
    
            function showShop() {
                const panel = document.getElementById('shopPanel');
                const items = document.getElementById('shopItems');
                items.innerHTML = '';
                
                // Generate shop items
                for (let i = 0; i < 6; i++) {
                    const item = {
                        name: `Item ${i + 1}`,
                        cost: 10 + i * 5,
                        effect: () => {
                            if (gameState.gold >= this.cost) {
                                gameState.gold -= this.cost;
                                // Apply effect
                            }
                        }
                    };
                    
                    const div = document.createElement('div');
                    div.className = 'shopItem';
                    div.innerHTML = `${item.name} - ${item.cost} gold`;
                    div.onclick = item.effect;
                    items.appendChild(div);
                }
                
                panel.style.display = 'block';
                gameState.paused = true;
            }
    
            function closeShop() {
                document.getElementById('shopPanel').style.display = 'none';
                gameState.paused = false;
            }
    
            function showInventory() {
                const panel = document.getElementById('inventoryPanel');
                const slots = document.getElementById('inventorySlots');
                slots.innerHTML = '';
                
                // Show head
                const headSlot = document.createElement('div');
                headSlot.className = 'inventorySlot';
                headSlot.innerHTML = `<img src="${textures.playerHead}" title="Head - ${player.head.health}/${player.head.maxHealth} HP">`;
                slots.appendChild(headSlot);
                
                // Show segments
                player.segments.forEach((segment, index) => {
                    const slot = document.createElement('div');
                    slot.className = 'inventorySlot';
                    slot.innerHTML = `<img src="${textures.playerSegment}" title="Segment ${index + 1} - ${segment.health}/${segment.maxHealth} HP">`;
                    slots.appendChild(slot);
                });
                
                panel.style.display = 'block';
                gameState.paused = true;
            }
    
            function closeInventory() {
                document.getElementById('inventoryPanel').style.display = 'none';
                gameState.paused = false;
            }
    
            function updateUI() {
                document.getElementById('healthDisplay').textContent = `${player.head.health}/${player.head.maxHealth}`;
                document.getElementById('levelDisplay').textContent = player.level;
                document.getElementById('xpDisplay').textContent = `${player.xp}/${player.xpToNext}`;
                document.getElementById('stageDisplay').textContent = gameState.stage;
                document.getElementById('timeDisplay').textContent = Math.ceil(gameState.stageTime);
                document.getElementById('goldDisplay').textContent = gameState.gold;
                document.getElementById('segmentsDisplay').textContent = player.segments.length;
            }
    
            function render() {
                ctx.fillStyle = '#000';
                ctx.fillRect(0, 0, canvas.width, canvas.height);
                
                // Draw fruits
                fruits.forEach(fruit => {
                    ctx.drawImage(images.fruit, fruit.x, fruit.y, 64, 64);
                });
                
                // Draw segments
                player.segments.forEach(segment => {
                    ctx.drawImage(images.playerSegment, segment.x - 32, segment.y - 32, 64, 64);
                    
                    // Health bar
                    const barWidth = 48;
                    const barHeight = 4;
                    const barX = segment.x - barWidth / 2;
                    const barY = segment.y - 40;
                    
                    ctx.fillStyle = '#f00';
                    ctx.fillRect(barX, barY, barWidth, barHeight);
                    ctx.fillStyle = '#0f0';
                    ctx.fillRect(barX, barY, barWidth * (segment.health / segment.maxHealth), barHeight);
                });
                
                // Draw player
                ctx.drawImage(images.playerHead, player.x - 32, player.y - 32, 64, 64);
                
                // Health bar for head
                const barWidth = 48;
                const barHeight = 4;
                const barX = player.x - barWidth / 2;
                const barY = player.y - 40;
                
                ctx.fillStyle = '#f00';
                ctx.fillRect(barX, barY, barWidth, barHeight);
                ctx.fillStyle = '#0f0';
                ctx.fillRect(barX, barY, barWidth * (player.head.health / player.head.maxHealth), barHeight);
                
                // Draw enemies
                enemies.forEach(enemy => {
                    ctx.drawImage(images.enemy, enemy.x - 32, enemy.y - 32, 64, 64);
                    
                    // Health bar
                    const barWidth = 48;
                    const barHeight = 4;
                    const barX = enemy.x - barWidth / 2;
                    const barY = enemy.y - 40;
                    
                    ctx.fillStyle = '#f00';
                    ctx.fillRect(barX, barY, barWidth, barHeight);
                    ctx.fillStyle = '#0f0';
                    ctx.fillRect(barX, barY, barWidth * (enemy.health / (50 + gameState.stage * 10)), barHeight);
                });
                
                // Draw projectiles
                projectiles.forEach(proj => {
                    ctx.drawImage(images.projectile, proj.x - 8, proj.y - 8, 16, 16);
                });
            }
    
            function gameLoop(currentTime) {
                if (fpsInterval > 0) {
                    const delta = currentTime - lastTime;
                    if (delta < 1000 / fpsInterval) {
                        requestAnimationFrame(gameLoop);
                        return;
                    }
                }
                
                // Update FPS
                frameCount++;
                if (currentTime - lastTime >= 1000) {
                    fps = frameCount;
                    frameCount = 0;
                    document.getElementById('fpsCounter').textContent = `FPS: ${fps}`;
                }
                lastTime = currentTime;
                
                if (!gameState.paused) {
                    updatePlayer();
                    updateEnemies();
                    updateProjectiles();
                    checkCollisions();
                    updateStage();
                    
                    // Spawn entities
                    if (Math.random() < 0.02) spawnFruit();
                    if (Math.random() < 0.03 + gameState.stage * 0.005) spawnEnemy();
                }
                
                updateUI();
                render();
                
                requestAnimationFrame(gameLoop);
            }
    
            // Controls
            document.addEventListener('keydown', (e) => {
                if (e.key.toLowerCase() === 'i') {
                    if (document.getElementById('inventoryPanel').style.display === 'block') {
                        closeInventory();
                    } else {
                        showInventory();
                    }
                }
            });
    
            fpsSlider.addEventListener('input', (e) => {
                fpsInterval = parseInt(e.target.value) || 0;
            });
    
            // Start game
            requestAnimationFrame(gameLoop);
        </script>
    </body>
    </html>
    

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