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

Please make a browser based pvp fighting game like Street Fighter or Tekken. I want you…

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

    Please make a browser based pvp fighting game like Street Fighter or Tekken. I want you to generate a highly detailed and actionable game, it should have atleast 2 different characters to choose from.

  2. Assistant

    Creating a fully featured browser-based PvP fighting game like Street Fighter or Tekken is a complex task, but I can provide you with a detailed, actionable, and extendable foundation using HTML, CSS, and JavaScript. This will include:

    • Character selection (2 characters)
    • Basic movement and attack controls
    • Health bars and damage system
    • Simple animations using CSS and sprite frames
    • PvP functionality on the same keyboard (local multiplayer)

    You can later extend this foundation with more characters, combos, sound effects, and online multiplayer.


    Overview

    • Characters: Two fighters with different stats and moves.
    • Controls: WASD + F for Player 1, Arrow keys + Numpad 0 for Player 2.
    • Gameplay: Move left/right, jump, basic attack.
    • Health: Each player has a health bar.
    • Win condition: When a player’s health reaches zero.

    Step 1: Project Structure

    /index.html
    /styles.css
    /game.js
    /assets/
      /char1.png
      /char2.png
      /background.png
    

    Step 2: Code

    index.html

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>Browser PvP Fighting Game</title>
    <link rel="stylesheet" href="styles.css" />
    </head>
    <body>
      <div id="game-container">
        <div id="character-select">
          <h2>Select Your Character</h2>
          <div class="characters">
            <div class="character" data-char="fighter1">
              <img src="assets/char1.png" alt="Fighter 1" />
              <p>Fighter 1</p>
            </div>
            <div class="character" data-char="fighter2">
              <img src="assets/char2.png" alt="Fighter 2" />
              <p>Fighter 2</p>
            </div>
          </div>
          <button id="start-game" disabled>Start Game</button>
        </div>
    
        <div id="game" style="display:none;">
          <div id="background"></div>
          <div id="player1" class="fighter"></div>
          <div id="player2" class="fighter"></div>
    
          <div id="hud">
            <div class="health-bar" id="health1">
              <div class="health-fill"></div>
            </div>
            <div class="health-bar" id="health2">
              <div class="health-fill"></div>
            </div>
          </div>
    
          <div id="message"></div>
        </div>
      </div>
    
    <script src="game.js"></script>
    </body>
    </html>
    

    styles.css

    * {
      box-sizing: border-box;
      user-select: none;
    }
    
    body, html {
      margin: 0;
      padding: 0;
      background: #222;
      color: #fff;
      font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
      height: 100vh;
      overflow: hidden;
    }
    
    #game-container {
      width: 100vw;
      height: 100vh;
      position: relative;
    }
    
    #character-select {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      height: 100%;
    }
    
    .characters {
      display: flex;
      gap: 40px;
      margin: 20px 0;
    }
    
    .character {
      cursor: pointer;
      border: 3px solid transparent;
      padding: 10px;
      transition: border-color 0.3s;
      text-align: center;
    }
    
    .character.selected {
      border-color: #0f0;
    }
    
    .character img {
      width: 120px;
      height: 120px;
      object-fit: contain;
    }
    
    #start-game {
      padding: 10px 20px;
      font-size: 18px;
      cursor: pointer;
    }
    
    #game {
      position: relative;
      width: 100vw;
      height: 100vh;
      background: url('assets/background.png') center bottom no-repeat;
      background-size: cover;
      overflow: hidden;
    }
    
    .fighter {
      position: absolute;
      bottom: 50px;
      width: 80px;
      height: 120px;
      background-size: contain;
      background-repeat: no-repeat;
      transition: transform 0.1s;
    }
    
    #player1 {
      left: 100px;
      transform-origin: center bottom;
    }
    
    #player2 {
      right: 100px;
      transform-origin: center bottom;
      transform: scaleX(-1);
    }
    
    #hud {
      position: absolute;
      top: 20px;
      width: 100%;
      display: flex;
      justify-content: space-between;
      padding: 0 40px;
    }
    
    .health-bar {
      width: 300px;
      height: 30px;
      background: #444;
      border: 2px solid #fff;
      border-radius: 8px;
      overflow: hidden;
    }
    
    .health-fill {
      height: 100%;
      background: #f00;
      width: 100%;
      transition: width 0.3s ease;
    }
    
    #message {
      position: absolute;
      top: 50%;
      width: 100%;
      text-align: center;
      font-size: 48px;
      font-weight: bold;
      color: #fff;
      text-shadow: 0 0 10px #000;
      pointer-events: none;
    }
    

    game.js

    // Game constants
    const GAME_WIDTH = window.innerWidth;
    const GAME_HEIGHT = window.innerHeight;
    const GROUND_LEVEL = 50; // px from bottom
    
    // Character data
    const characters = {
      fighter1: {
        name: "Fighter 1",
        sprite: "assets/char1.png",
        health: 100,
        attackDamage: 10,
        speed: 6,
        jumpHeight: 150,
      },
      fighter2: {
        name: "Fighter 2",
        sprite: "assets/char2.png",
        health: 100,
        attackDamage: 12,
        speed: 5,
        jumpHeight: 130,
      },
    };
    
    // Game state
    let player1Char = null;
    let player2Char = null;
    let gameStarted = false;
    
    const player1 = {
      x: 100,
      y: GROUND_LEVEL,
      width: 80,
      height: 120,
      health: 100,
      speed: 6,
      jumping: false,
      jumpVelocity: 0,
      facing: 1, // 1 = right, -1 = left
      attacking: false,
      attackCooldown: 0,
    };
    
    const player2 = {
      x: GAME_WIDTH - 180,
      y: GROUND_LEVEL,
      width: 80,
      height: 120,
      health: 100,
      speed: 5,
      jumping: false,
      jumpVelocity: 0,
      facing: -1,
      attacking: false,
      attackCooldown: 0,
    };
    
    const gravity = 0.8;
    const jumpStrength = 15;
    
    const keys = {
      // Player 1: WASD + F
      w: false,
      a: false,
      d: false,
      f: false,
      // Player 2: Arrow keys + Numpad 0
      ArrowUp: false,
      ArrowLeft: false,
      ArrowRight: false,
      Numpad0: false,
    };
    
    const player1El = document.getElementById("player1");
    const player2El = document.getElementById("player2");
    const health1El = document.querySelector("#health1 .health-fill");
    const health2El = document.querySelector("#health2 .health-fill");
    const messageEl = document.getElementById("message");
    
    const characterSelectEl = document.getElementById("character-select");
    const startGameBtn = document.getElementById("start-game");
    const gameEl = document.getElementById("game");
    
    let selectedChars = {
      player1: null,
      player2: null,
    };
    
    // Character selection logic
    document.querySelectorAll(".character").forEach((charEl) => {
      charEl.addEventListener("click", () => {
        const char = charEl.dataset.char;
        if (!selectedChars.player1) {
          selectedChars.player1 = char;
          charEl.classList.add("selected");
        } else if (!selectedChars.player2 && char !== selectedChars.player1) {
          selectedChars.player2 = char;
          charEl.classList.add("selected");
        } else if (selectedChars.player1 === char) {
          selectedChars.player1 = null;
          charEl.classList.remove("selected");
        } else if (selectedChars.player2 === char) {
          selectedChars.player2 = null;
          charEl.classList.remove("selected");
        }
    
        startGameBtn.disabled = !(selectedChars.player1 && selectedChars.player2);
      });
    });
    
    startGameBtn.addEventListener("click", () => {
      if (selectedChars.player1 && selectedChars.player2) {
        startGame(selectedChars.player1, selectedChars.player2);
      }
    });
    
    function startGame(char1, char2) {
      player1Char = characters[char1];
      player2Char = characters[char2];
    
      // Initialize players
      player1.health = player1Char.health;
      player1.speed = player1Char.speed;
      player1.attackDamage = player1Char.attackDamage;
      player1.jumpHeight = player1Char.jumpHeight;
      player1.x = 100;
      player1.y = GROUND_LEVEL;
      player1.facing = 1;
    
      player2.health = player2Char.health;
      player2.speed = player2Char.speed;
      player2.attackDamage = player2Char.attackDamage;
      player2.jumpHeight = player2Char.jumpHeight;
      player2.x = GAME_WIDTH - 180;
      player2.y = GROUND_LEVEL;
      player2.facing = -1;
    
      // Set sprites
      player1El.style.backgroundImage = `url(${player1Char.sprite})`;
      player2El.style.backgroundImage = `url(${player2Char.sprite})`;
    
      // Reset health bars
      updateHealthBars();
    
      // Hide character select, show game
      characterSelectEl.style.display = "none";
      gameEl.style.display = "block";
    
      gameStarted = true;
      messageEl.textContent = "";
    
      requestAnimationFrame(gameLoop);
    }
    
    // Input handling
    window.addEventListener("keydown", (e) => {
      if (!gameStarted) return;
      if (e.repeat) return;
    
      if (e.key in keys) {
        keys[e.key] = true;
      }
    });
    
    window.addEventListener("keyup", (e) => {
      if (!gameStarted) return;
      if (e.key in keys) {
        keys[e.key] = false;
      }
    });
    
    // Game loop
    function gameLoop() {
      if (!gameStarted) return;
    
      updatePlayer(player1, keys, "player1");
      updatePlayer(player2, keys, "player2");
    
      checkCollisions();
    
      updatePositions();
    
      updateHealthBars();
    
      checkWinCondition();
    
      requestAnimationFrame(gameLoop);
    }
    
    function updatePlayer(player, keys, playerId) {
      // Movement
      if (playerId === "player1") {
        if (keys.a) {
          player.x -= player.speed;
          player.facing = -1;
        }
        if (keys.d) {
          player.x += player.speed;
          player.facing = 1;
        }
        if (keys.w && !player.jumping) {
          player.jumping = true;
          player.jumpVelocity = -player.jumpHeight / 10;
        }
        if (keys.f && player.attackCooldown <= 0) {
          player.attacking = true;
          player.attackCooldown = 30; // cooldown frames
        }
      } else if (playerId === "player2") {
        if (keys.ArrowLeft) {
          player.x -= player.speed;
          player.facing = -1;
        }
        if (keys.ArrowRight) {
          player.x += player.speed;
          player.facing = 1;
        }
        if (keys.ArrowUp && !player.jumping) {
          player.jumping = true;
          player.jumpVelocity = -player.jumpHeight / 10;
        }
        if (keys.Numpad0 && player.attackCooldown <= 0) {
          player.attacking = true;
          player.attackCooldown = 30;
        }
      }
    
      // Jumping physics
      if (player.jumping) {
        player.y += player.jumpVelocity;
        player.jumpVelocity += gravity;
    
        if (player.y >= GROUND_LEVEL) {
          player.y = GROUND_LEVEL;
          player.jumping = false;
          player.jumpVelocity = 0;
        }
      }
    
      // Attack cooldown
      if (player.attackCooldown > 0) {
        player.attackCooldown--;
      } else {
        player.attacking = false;
      }
    
      // Boundaries
      player.x = Math.max(0, Math.min(GAME_WIDTH - player.width, player.x));
    }
    
    function updatePositions() {
      // Update player1 element
      player1El.style.left = player1.x + "px";
      player1El.style.bottom = player1.y + "px";
      player1El.style.transform = `scaleX(${player1.facing})`;
    
      // Update player2 element
      player2El.style.left = player2.x + "px";
      player2El.style.bottom = player2.y + "px";
      player2El.style.transform = `scaleX(${player2.facing})`;
    }
    
    function checkCollisions() {
      // Simple hitbox for attack: if attacking and close enough, deal damage
      if (player1.attacking && player1.attackCooldown === 29) {
        if (isHit(player1, player2)) {
          player2.health -= player1.attackDamage;
          if (player2.health < 0) player2.health = 0;
        }
      }
    
      if (player2.attacking && player2.attackCooldown === 29) {
        if (isHit(player2, player1)) {
          player1.health -= player2.attackDamage;
          if (player1.health < 0) player1.health = 0;
        }
      }
    }
    
    function isHit(attacker, defender) {
      // Check horizontal range and vertical overlap
      const attackRange = 50;
      const attackerFrontX = attacker.x + (attacker.facing === 1 ? attacker.width : 0);
      const defenderFrontX = defender.x + (defender.facing === 1 ? 0 : defender.width);
    
      const horizontalHit =
        attacker.facing === 1
          ? defender.x < attackerFrontX + attackRange && defender.x + defender.width > attackerFrontX
          : defender.x + defender.width > attackerFrontX - attackRange && defender.x < attackerFrontX;
    
      const verticalHit =
        defender.y < attacker.y + attacker.height && defender.y + defender.height > attacker.y;
    
      return horizontalHit && verticalHit;
    }
    
    function updateHealthBars() {
      health1El.style.width = (player1.health / player1Char.health) * 100 + "%";
      health2El.style.width = (player2.health / player2Char.health) * 100 + "%";
    }
    
    function checkWinCondition() {
      if (player1.health <= 0) {
        endGame(player2Char.name + " Wins!");
      } else if (player2.health <= 0) {
        endGame(player1Char.name + " Wins!");
      }
    }
    
    function endGame(message) {
      gameStarted = false;
      messageEl.textContent = message;
    
      setTimeout(() => {
        // Reset game
        messageEl.textContent = "";
        gameEl.style.display = "none";
        characterSelectEl.style.display = "flex";
        selectedChars = { player1: null, player2: null };
        document.querySelectorAll(".character").forEach((el) => el.classList.remove("selected"));
        startGameBtn.disabled = true;
      }, 4000);
    }
    

    Step 3: Assets

    You will need two character sprites and a background image. For simplicity, you can use any PNG images with transparent backgrounds sized roughly 80x120 px for characters and a 1920x1080 or similar for the background.


    How to Play

    • Player 1 Controls:

      • Move Left: A
      • Move Right: D
      • Jump: W
      • Attack: F
    • Player 2 Controls:

      • Move Left: Left Arrow
      • Move Right: Right Arrow
      • Jump: Up Arrow
      • Attack: Numpad 0

    Extending the Game

    • Add more moves (crouch, combos, special attacks)
    • Add animations for attacks and movement
    • Add sound effects and music
    • Add online multiplayer using WebSockets or WebRTC
    • Add AI opponent for single player mode
    • Add rounds and timer

    If you want, I can help you build any of these extensions or polish the game further! Would you like me to generate some simple character sprites or animations next?

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

Identical first prompt