Skip to content
TheChatArchiveThe Chat Archive
o4-mini-2025-04-16· OpenAIHugging Face LMArena Human Preference 140K

Génère un code d'un jeu falpibird

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with chatgpt-4o-latest-20250326’s answer.
  1. User

    Génère un code d'un jeu falpibird

  2. Assistant

    Voici un petit clone de FalpiBird en HTML5 / JavaScript. Copie-colle ce code dans un fichier index.html, ouvre-le dans ton navigateur, et amuse-toi ! 🚀🐦

    <!DOCTYPE html>
    <html lang="fr">
    <head>
      <meta charset="UTF-8" />
      <title>FalpiBird</title>
      <style>
        /* Reset & background */
        * { margin: 0; padding: 0; }
        body, html { width: 100%; height: 100%; overflow: hidden; background: #70c5ce; }
        canvas { display: block; margin: auto; background: #4ec0ca; }
        /* Police pour le score */
        #score {
          position: absolute;
          top: 10px;
          left: 50%;
          transform: translateX(-50%);
          font: bold 24px sans-serif;
          color: white;
          text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
        }
      </style>
    </head>
    <body>
      <div id="score">Score: 0</div>
      <canvas id="gameCanvas" width="320" height="480"></canvas>
    
      <script>
        // Récupère le canevas et son contexte
        const canvas = document.getElementById('gameCanvas');
        const ctx = canvas.getContext('2d');
        const scoreDiv = document.getElementById('score');
    
        // Taille
        const WIDTH  = canvas.width;
        const HEIGHT = canvas.height;
    
        // Oiseau
        const bird = {
          x: WIDTH / 4,
          y: HEIGHT / 2,
          radius: 12,
          gravity: 0.6,
          lift: -12,
          velocity: 0
        };
    
        // Tuyaux
        const pipes     = [];
        const pipeGap   = 100;
        const pipeWidth = 40;
        const pipeDist  = 150;  // écart horizontal entre les tuyaux
        let frameCount  = 0;
    
        // Score
        let score = 0;
    
        // Contrôle (espace ou clic)
        function flap() {
          bird.velocity = bird.lift;
        }
        document.addEventListener('keydown', e => {
          if (e.code === 'Space' || e.code==='ArrowUp') flap();
        });
        canvas.addEventListener('mousedown', flap);
    
        // Fonction pour générer un nouveau tuyau
        function addPipe() {
          const topHeight = Math.random() * (HEIGHT - pipeGap - 40) + 20;
          pipes.push({
            x: WIDTH,
            top: topHeight,
            bottom: topHeight + pipeGap
          });
        }
    
        // Boucle de mise à jour
        function update() {
          frameCount++;
    
          // Applique gravité et vitesse à l'oiseau
          bird.velocity += bird.gravity;
          bird.y += bird.velocity;
    
          // Ajoute un nouveau tuyau tous les pipeDist frames
          if (frameCount % pipeDist === 0) addPipe();
    
          // Déplace les tuyaux, vérifie collision et score
          for (let i = pipes.length - 1; i >= 0; i--) {
            const p = pipes[i];
            p.x -= 2;  // vitesse du scroll
    
            // Si l'oiseau passe le tuyau, +1 point
            if (!p.passed && p.x + pipeWidth < bird.x) {
              score++;
              p.passed = true;
              scoreDiv.textContent = 'Score: ' + score;
            }
    
            // Collision rect/cercles
            const hitTop    = (bird.x + bird.radius > p.x) && (bird.x - bird.radius < p.x + pipeWidth) && (bird.y - bird.radius < p.top);
            const hitBottom = (bird.x + bird.radius > p.x) && (bird.x - bird.radius < p.x + pipeWidth) && (bird.y + bird.radius > p.bottom);
            if (hitTop || hitBottom || bird.y + bird.radius > HEIGHT || bird.y - bird.radius < 0) {
              resetGame();
              return;
            }
    
            // Supprime les tuyaux hors-écran
            if (p.x + pipeWidth < 0) {
              pipes.splice(i, 1);
            }
          }
        }
    
        // Boucle de dessin
        function draw() {
          // Efface le canvas
          ctx.clearRect(0, 0, WIDTH, HEIGHT);
    
          // Oiseau
          ctx.fillStyle = 'yellow';
          ctx.beginPath();
          ctx.arc(bird.x, bird.y, bird.radius, 0, Math.PI * 2);
          ctx.fill();
    
          // Tuyaux
          ctx.fillStyle = '#4CAF50';
          pipes.forEach(p => {
            // tuyau du haut
            ctx.fillRect(p.x, 0, pipeWidth, p.top);
            // tuyau du bas
            ctx.fillRect(p.x, p.bottom, pipeWidth, HEIGHT - p.bottom);
          });
        }
    
        // Réinitialiser après game over
        function resetGame() {
          bird.y         = HEIGHT / 2;
          bird.velocity  = 0;
          pipes.length   = 0;
          frameCount     = 0;
          score          = 0;
          scoreDiv.textContent = 'Score: 0';
        }
    
        // Game loop
        function loop() {
          update();
          draw();
          requestAnimationFrame(loop);
        }
    
        // Démarre le jeu !
        loop();
      </script>
    </body>
    </html>
    

    Comment ça marche ?

    1. L’oiseau subit une gravité et peut “flap” (espace / clic).
    2. Des tuyaux (pipes) apparaissent à intervalle régulier avec une ouverture aléatoire.
    3. On regarde les collisions cercle/rectangle et les limites de l’écran.
    4. Le score augmente à chaque tuyau franchi.

    Amuse-toi à modifier les couleurs, les vitesses, la taille de l’oiseau… et bonne chance pour battre ton propre record ! 🎮💯

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