Skip to content
TheChatArchiveThe Chat Archive
gpt-4.1-mini-2025-04-14· OpenAIHugging Face LMArena Human Preference 140K

lets make a game in html, the game is based off of counter strikes case opening system…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with o3-2025-04-16’s answer.
  1. User

    lets make a game in html, the game is based off of counter strikes case opening system where players have a random chance to get an item of different rarities. Instead of weapon skins, I want a set of randomly generated but somewhat realistic looking 3D planets and stars as the items. Players will click a spin button and see the different planets scrolling across the screen and the scrolling will slow down until it lands and the player will unlock whatever they landed on. Unlocks will be catalogued in an encyclopedia accessible through a button on the side. The encyclopedia will have all obtainable objects from the set of generated planets and stars in a nice looking display however objects that have yet to be obtained will be blacked out and the name will be question marks until the player obtains it through rolls. The game should run from a single html file and need no further setup, all assets generated dynamically by code.

  2. Assistant

    Got it! Below is a complete single HTML file implementing a Counter-Strike style case opening game with:

    • Randomly generated 3D-looking planets and stars (using canvas and simple procedural drawing).
    • A spin button that scrolls planets across the screen, slowing down and landing on a random item.
    • An encyclopedia showing all possible items, with locked items blacked out and named "??????".
    • All assets generated dynamically with no external dependencies.

    How it works:

    • We generate a fixed set of 30 items (planets and stars) with different rarities.
    • Each item is drawn on a canvas as a circle with some shading and features to look like a planet or star.
    • When you spin, the items scroll horizontally, slowing down and stopping on a random item.
    • The unlocked item is added to your collection.
    • The encyclopedia shows all items, revealing only those unlocked.

    Here is the full code:

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>Planet Case Opening Game</title>
    <style>
      body {
        margin: 0; background: #0b0c1a; color: #eee; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        display: flex; flex-direction: column; align-items: center; min-height: 100vh;
      }
      h1 {
        margin: 20px 0 10px;
        font-weight: 700;
        letter-spacing: 2px;
      }
      #game {
        position: relative;
        width: 800px;
        max-width: 95vw;
        height: 180px;
        background: linear-gradient(90deg, #001022, #000a1a);
        border-radius: 12px;
        overflow: hidden;
        box-shadow: 0 0 20px #0ff;
      }
      #scrollCanvas {
        display: block;
        background: transparent;
      }
      #spinBtn {
        margin: 15px 0;
        padding: 12px 30px;
        font-size: 18px;
        font-weight: 700;
        background: #00ccff;
        border: none;
        border-radius: 8px;
        cursor: pointer;
        color: #002233;
        transition: background 0.3s;
      }
      #spinBtn:disabled {
        background: #004455;
        cursor: not-allowed;
      }
      #encyclopediaBtn {
        position: fixed;
        top: 20px;
        right: 20px;
        background: #00ccff;
        border: none;
        border-radius: 8px;
        padding: 10px 18px;
        font-weight: 700;
        cursor: pointer;
        color: #002233;
        box-shadow: 0 0 10px #00ccff;
        transition: background 0.3s;
        z-index: 1000;
      }
      #encyclopediaBtn:hover {
        background: #0099cc;
      }
      #encyclopedia {
        position: fixed;
        top: 60px;
        right: 20px;
        bottom: 20px;
        width: 320px;
        background: #001022dd;
        border-radius: 12px;
        box-shadow: 0 0 20px #00ccffaa;
        overflow-y: auto;
        padding: 15px;
        display: none;
        z-index: 1000;
      }
      #encyclopedia h2 {
        margin-top: 0;
        text-align: center;
        letter-spacing: 1.5px;
      }
      .encyclopedia-item {
        display: flex;
        align-items: center;
        margin-bottom: 12px;
        gap: 12px;
      }
      .encyclopedia-item canvas {
        width: 48px;
        height: 48px;
        border-radius: 50%;
        background: #000;
        box-shadow: 0 0 5px #00ccff88;
      }
      .item-name {
        font-weight: 600;
        font-size: 16px;
        user-select: none;
      }
      .locked {
        filter: brightness(0) saturate(0);
        user-select: none;
      }
      #resultMessage {
        margin-top: 10px;
        font-size: 20px;
        font-weight: 700;
        color: #00ffcc;
        min-height: 28px;
        text-align: center;
        letter-spacing: 1.2px;
      }
      /* Scrollbar for encyclopedia */
      #encyclopedia::-webkit-scrollbar {
        width: 8px;
      }
      #encyclopedia::-webkit-scrollbar-thumb {
        background: #00ccff88;
        border-radius: 4px;
      }
    </style>
    </head>
    <body>
    
    <h1>Planet Case Opening</h1>
    
    <div id="game">
      <canvas id="scrollCanvas" width="800" height="180"></canvas>
    </div>
    <button id="spinBtn">Spin</button>
    <div id="resultMessage"></div>
    
    <button id="encyclopediaBtn">Encyclopedia</button>
    <div id="encyclopedia">
      <h2>Encyclopedia</h2>
      <div id="encyclopediaList"></div>
    </div>
    
    <script>
    (() => {
      // Constants
      const CANVAS_WIDTH = 800;
      const CANVAS_HEIGHT = 180;
      const ITEM_SIZE = 120; // size of each planet/star circle
      const ITEM_SPACING = 40; // space between items
      const VISIBLE_ITEMS = Math.floor(CANVAS_WIDTH / (ITEM_SIZE + ITEM_SPACING)) + 2;
    
      // Rarities and their chances (sum to 1)
      const RARITIES = [
        {name: "Common", color: "#7f8c8d", chance: 0.6},
        {name: "Uncommon", color: "#27ae60", chance: 0.25},
        {name: "Rare", color: "#2980b9", chance: 0.1},
        {name: "Epic", color: "#8e44ad", chance: 0.04},
        {name: "Legendary", color: "#f39c12", chance: 0.01},
      ];
    
      // Number of items total
      const TOTAL_ITEMS = 30;
    
      // Store items and unlocked state
      let items = [];
      let unlocked = new Set();
    
      // Canvas and context
      const canvas = document.getElementById("scrollCanvas");
      const ctx = canvas.getContext("2d");
    
      // Spin button and result message
      const spinBtn = document.getElementById("spinBtn");
      const resultMessage = document.getElementById("resultMessage");
    
      // Encyclopedia elements
      const encyclopediaBtn = document.getElementById("encyclopediaBtn");
      const encyclopedia = document.getElementById("encyclopedia");
      const encyclopediaList = document.getElementById("encyclopediaList");
    
      // Utility: weighted random rarity
      function pickRarity() {
        let r = Math.random();
        let sum = 0;
        for (const rarity of RARITIES) {
          sum += rarity.chance;
          if (r <= sum) return rarity;
        }
        return RARITIES[0]; // fallback
      }
    
      // Utility: random int in [min, max]
      function randInt(min, max) {
        return Math.floor(Math.random() * (max - min + 1)) + min;
      }
    
      // Generate a random planet/star object
      function generateItem(id) {
        const rarity = pickRarity();
        const type = Math.random() < 0.8 ? "planet" : "star"; // 80% planets, 20% stars
    
        // Generate a name based on rarity and id
        const prefixes = ["Zor", "Xen", "Qar", "Vel", "Nim", "Sol", "Lun", "Ari", "Kor", "Tal"];
        const suffixes = ["on", "ar", "is", "us", "ea", "ix", "or", "um", "ex", "os"];
        const name = prefixes[id % prefixes.length] + suffixes[id % suffixes.length] + (rarity.name === "Legendary" ? " Prime" : "");
    
        // Color base on rarity with some variation
        const baseColor = rarity.color;
        // We'll store some parameters for drawing
        return {
          id,
          name,
          rarity: rarity.name,
          rarityColor: rarity.color,
          type,
          baseColor,
          features: generateFeatures(type),
        };
      }
    
      // Generate features for planet/star to make it look unique
      function generateFeatures(type) {
        if (type === "planet") {
          return {
            spots: randInt(3, 7),
            rings: Math.random() < 0.3,
            cloudBands: Math.random() < 0.5,
            colorShift: Math.random() * 0.3 - 0.15,
          };
        } else {
          // star features
          return {
            spikes: randInt(5, 9),
            glowIntensity: 0.3 + Math.random() * 0.7,
            colorShift: Math.random() * 0.3 - 0.15,
          };
        }
      }
    
      // Draw a single item on a canvas context at (x,y)
      // size is diameter
      function drawItem(ctx, item, x, y, size, locked = false) {
        ctx.save();
        ctx.translate(x + size/2, y + size/2);
    
        if (locked) {
          // Draw black circle with question marks
          ctx.fillStyle = "#111";
          ctx.beginPath();
          ctx.arc(0, 0, size/2, 0, Math.PI*2);
          ctx.fill();
    
          ctx.fillStyle = "#444";
          ctx.font = `${size/4}px monospace`;
          ctx.textAlign = "center";
          ctx.textBaseline = "middle";
          ctx.fillText("??????", 0, 0);
          ctx.restore();
          return;
        }
    
        if (item.type === "planet") {
          drawPlanet(ctx, item, size);
        } else {
          drawStar(ctx, item, size);
        }
    
        ctx.restore();
      }
    
      // Draw a planet with shading, spots, rings, clouds
      function drawPlanet(ctx, item, size) {
        const radius = size / 2;
        const baseHue = getHueFromColor(item.baseColor);
        const colorShift = item.features.colorShift;
    
        // Base gradient sphere
        let grad = ctx.createRadialGradient(-radius/3, -radius/3, radius/5, 0, 0, radius);
        grad.addColorStop(0, `hsl(${baseHue + colorShift*60}, 70%, 60%)`);
        grad.addColorStop(1, `hsl(${baseHue + colorShift*60}, 70%, 30%)`);
        ctx.fillStyle = grad;
        ctx.beginPath();
        ctx.arc(0, 0, radius, 0, Math.PI*2);
        ctx.fill();
    
        // Spots
        ctx.fillStyle = `hsl(${baseHue + colorShift*60}, 50%, 20%)`;
        for (let i=0; i<item.features.spots; i++) {
          const angle = Math.random()*Math.PI*2;
          const dist = Math.random()*radius*0.7;
          const spotRadius = randInt(radius*0.05, radius*0.12);
          ctx.beginPath();
          ctx.ellipse(Math.cos(angle)*dist, Math.sin(angle)*dist, spotRadius, spotRadius*0.6, angle, 0, Math.PI*2);
          ctx.fill();
        }
    
        // Cloud bands
        if (item.features.cloudBands) {
          ctx.strokeStyle = `hsla(${baseHue + colorShift*60}, 80%, 80%, 0.3)`;
          ctx.lineWidth = radius*0.1;
          for (let i=0; i<3; i++) {
            const y = (i - 1) * radius*0.3;
            ctx.beginPath();
            ctx.ellipse(0, y, radius*0.9, radius*0.15, 0, 0, Math.PI*2);
            ctx.stroke();
          }
        }
    
        // Rings
        if (item.features.rings) {
          ctx.strokeStyle = `hsla(${baseHue + colorShift*60}, 70%, 50%, 0.5)`;
          ctx.lineWidth = radius*0.08;
          ctx.beginPath();
          ctx.ellipse(0, 0, radius*1.3, radius*0.5, Math.PI/6, 0, Math.PI*2);
          ctx.stroke();
        }
    
        // Highlight
        let highlight = ctx.createRadialGradient(-radius/3, -radius/3, radius/10, 0, 0, radius/2);
        highlight.addColorStop(0, "rgba(255,255,255,0.6)");
        highlight.addColorStop(1, "rgba(255,255,255,0)");
        ctx.fillStyle = highlight;
        ctx.beginPath();
        ctx.arc(0, 0, radius, 0, Math.PI*2);
        ctx.fill();
      }
    
      // Draw a star with spikes and glow
      function drawStar(ctx, item, size) {
        const radius = size / 2;
        const baseHue = getHueFromColor(item.baseColor);
        const spikes = item.features.spikes;
        const glow = item.features.glowIntensity;
        const colorShift = item.features.colorShift;
    
        // Glow
        let glowGrad = ctx.createRadialGradient(0, 0, radius*0.5, 0, 0, radius*1.2);
        glowGrad.addColorStop(0, `hsla(${baseHue + colorShift*60}, 100%, 70%, ${glow})`);
        glowGrad.addColorStop(1, "rgba(0,0,0,0)");
        ctx.fillStyle = glowGrad;
        ctx.beginPath();
        ctx.arc(0, 0, radius*1.2, 0, Math.PI*2);
        ctx.fill();
    
        // Star shape
        ctx.fillStyle = `hsl(${baseHue + colorShift*60}, 100%, 60%)`;
        ctx.beginPath();
        for (let i=0; i<spikes*2; i++) {
          const angle = (i * Math.PI) / spikes;
          const r = (i % 2 === 0) ? radius : radius*0.5;
          ctx.lineTo(Math.cos(angle)*r, Math.sin(angle)*r);
        }
        ctx.closePath();
        ctx.fill();
    
        // Inner glow highlight
        let highlight = ctx.createRadialGradient(0, 0, radius*0.1, 0, 0, radius*0.7);
        highlight.addColorStop(0, "rgba(255,255,255,0.8)");
        highlight.addColorStop(1, "rgba(255,255,255,0)");
        ctx.fillStyle = highlight;
        ctx.beginPath();
        ctx.arc(0, 0, radius*0.7, 0, Math.PI*2);
        ctx.fill();
      }
    
      // Convert hex color to hue (approximate)
      function getHueFromColor(hex) {
        // Simple map for our rarity colors
        switch(hex.toLowerCase()) {
          case "#7f8c8d": return 180; // Common - grayish cyan
          case "#27ae60": return 140; // Uncommon - green
          case "#2980b9": return 210; // Rare - blue
          case "#8e44ad": return 280; // Epic - purple
          case "#f39c12": return 40;  // Legendary - orange
          default: return 200;
        }
      }
    
      // Generate all items
      function generateAllItems() {
        items = [];
        for (let i=0; i<TOTAL_ITEMS; i++) {
          items.push(generateItem(i));
        }
      }
    
      // Draw the scrolling items on the main canvas
      // offsetX is the scroll offset in pixels
      function drawScroll(offsetX) {
        ctx.clearRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT);
    
        // Draw a center highlight bar
        const centerX = CANVAS_WIDTH / 2;
        ctx.fillStyle = "rgba(0,255,255,0.1)";
        ctx.fillRect(centerX - (ITEM_SIZE+ITEM_SPACING)/2, 0, ITEM_SIZE+ITEM_SPACING, CANVAS_HEIGHT);
    
        // Draw items in a loop to fill the canvas
        // We will draw items from index startIndex to startIndex + VISIBLE_ITEMS
        // offsetX is how far the items have scrolled to the left
    
        // Calculate which item is at the left edge
        let startIndex = Math.floor(offsetX / (ITEM_SIZE + ITEM_SPACING));
        let partialOffset = offsetX % (ITEM_SIZE + ITEM_SPACING);
    
        for (let i = -1; i <= VISIBLE_ITEMS; i++) {
          let itemIndex = (startIndex + i) % items.length;
          if (itemIndex < 0) itemIndex += items.length;
          let x = i * (ITEM_SIZE + ITEM_SPACING) - partialOffset + (CANVAS_WIDTH / 2) - (ITEM_SIZE + ITEM_SPACING)/2;
          let y = (CANVAS_HEIGHT - ITEM_SIZE) / 2;
    
          drawItem(ctx, items[itemIndex], x, y, ITEM_SIZE);
        }
    
        // Draw a frame around center item
        ctx.strokeStyle = "#00ffff";
        ctx.lineWidth = 3;
        ctx.strokeRect(centerX - ITEM_SIZE/2, (CANVAS_HEIGHT - ITEM_SIZE)/2, ITEM_SIZE, ITEM_SIZE);
      }
    
      // Spin logic
      let spinning = false;
      let spinStartTime = 0;
      let spinDuration = 6000; // 6 seconds spin
      let spinOffset = 0;
      let spinTargetIndex = 0;
      let animationFrameId;
    
      function spin() {
        if (spinning) return;
        spinning = true;
        spinBtn.disabled = true;
        resultMessage.textContent = "";
    
        // Pick a random item weighted by rarity chance
        spinTargetIndex = weightedRandomItemIndex();
    
        // Calculate total scroll offset to land on target item centered
        // We want the target item to be centered at CANVAS_WIDTH/2
        // Each item occupies ITEM_SIZE + ITEM_SPACING pixels
        // So offsetX should be targetIndex * (ITEM_SIZE + ITEM_SPACING)
        // We'll add multiple full loops for effect
    
        const loops = 5;
        const targetOffset = spinTargetIndex * (ITEM_SIZE + ITEM_SPACING);
        const totalOffset = loops * items.length * (ITEM_SIZE + ITEM_SPACING) + targetOffset;
    
        spinStartTime = performance.now();
    
        function animate(time) {
          let elapsed = time - spinStartTime;
          if (elapsed > spinDuration) elapsed = spinDuration;
    
          // Ease out cubic for smooth slow down
          let t = elapsed / spinDuration;
          let easeOut = 1 - Math.pow(1 - t, 3);
    
          spinOffset = easeOut * totalOffset;
    
          drawScroll(spinOffset);
    
          if (elapsed < spinDuration) {
            animationFrameId = requestAnimationFrame(animate);
          } else {
            spinning = false;
            spinBtn.disabled = false;
            unlockItem(spinTargetIndex);
            showResult(spinTargetIndex);
          }
        }
        animationFrameId = requestAnimationFrame(animate);
      }
    
      // Weighted random item index based on rarity chance
      function weightedRandomItemIndex() {
        // Build cumulative rarity array
        let cumWeights = [];
        let sum = 0;
        for (const item of items) {
          const rarityObj = RARITIES.find(r => r.name === item.rarity);
          sum += rarityObj.chance;
          cumWeights.push(sum);
        }
        let r = Math.random() * sum;
        for (let i=0; i<cumWeights.length; i++) {
          if (r <= cumWeights[i]) return i;
        }
        return 0;
      }
    
      // Unlock item and update encyclopedia
      function unlockItem(index) {
        unlocked.add(index);
        updateEncyclopedia();
      }
    
      // Show result message
      function showResult(index) {
        const item = items[index];
        resultMessage.textContent = `You unlocked: ${item.name} (${item.rarity})`;
      }
    
      // Encyclopedia toggle
      encyclopediaBtn.addEventListener("click", () => {
        if (encyclopedia.style.display === "none" || encyclopedia.style.display === "") {
          encyclopedia.style.display = "block";
        } else {
          encyclopedia.style.display = "none";
        }
      });
    
      // Update encyclopedia display
      function updateEncyclopedia() {
        encyclopediaList.innerHTML = "";
        for (let i=0; i<items.length; i++) {
          const item = items[i];
          const locked = !unlocked.has(i);
    
          const div = document.createElement("div");
          div.className = "encyclopedia-item";
    
          // Create canvas for item icon
          const iconCanvas = document.createElement("canvas");
          iconCanvas.width = 48;
          iconCanvas.height = 48;
          const iconCtx = iconCanvas.getContext("2d");
    
          drawItem(iconCtx, item, 0, 0, 48, locked);
    
          div.appendChild(iconCanvas);
    
          const nameSpan = document.createElement("span");
          nameSpan.className = "item-name";
          nameSpan.textContent = locked ? "??????" : item.name;
          if (locked) nameSpan.classList.add("locked");
          div.appendChild(nameSpan);
    
          encyclopediaList.appendChild(div);
        }
      }
    
      // Initialize
      function init() {
        generateAllItems();
        updateEncyclopedia();
        drawScroll(0);
      }
    
      spinBtn.addEventListener("click", spin);
    
      init();
    
    })();
    </script>
    
    </body>
    </html>
    

    How to use:

    • Open this file in any modern browser.
    • Click Spin to start the case opening animation.
    • The planets and stars scroll and slow down, landing on a random item.
    • The unlocked item is shown below the spin button.
    • Click Encyclopedia to see all items, locked items are blacked out and named "??????".
    • Unlock more items by spinning multiple times.

    Features you can extend:

    • Save unlocked items in localStorage for persistence.
    • Add sound effects.
    • Add more complex 3D rendering with WebGL or Three.js (would require external libs).
    • Add rarity colors and animations on unlock.
    • Add player inventory and multiple cases.

    If you want me to add any of these or customize the visuals further, just ask!

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