Skip to content
The Chat Archive
o4-mini-2025-04-16· OpenAI LMArena Human Preference 140K

faça uma versao 3d desse jogo

  1. User

    faça uma versao 3d desse jogo

  2. Assistant

    Segue uma versão 3D “psicodélica” do Pong, tudo num único arquivo HTML. Usei Three.js para a renderização e apliquei um efeito geral de hue-rotate em CSS para dar aquele toque colorido em loop infinito.

    Salve como pong3d_psicodelico.html e abra no seu navegador:

    <!DOCTYPE html>
    <html lang="pt-BR">
    <head>
      <meta charset="UTF-8" />
      <meta name="viewport" content="width=device-width,initial-scale=1.0" />
      <title>Pong 3D Psicodélico</title>
      <style>
        body {
          margin: 0;
          overflow: hidden;
          background: #000;
          display: flex;
          align-items: center;
          justify-content: center;
        }
        /* Container com hue-rotate animado */
        #container {
          width: 100vw;
          height: 100vh;
          filter: hue-rotate(0deg);
          animation: hueShift 20s infinite linear;
        }
        @keyframes hueShift {
          from   { filter: hue-rotate(0deg); }
          to     { filter: hue-rotate(360deg); }
        }
        /* Placar */
        #score {
          position: absolute;
          top: 20px;
          width: 100%;
          text-align: center;
          font-family: 'Courier New', monospace;
          font-size: 48px;
          color: #fff;
          pointer-events: none;
          text-shadow: 0 0 10px #fff;
        }
      </style>
    </head>
    <body>
      <div id="container"></div>
      <div id="score">0 : 0</div>
    
      <!-- Three.js via CDN -->
      <script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
      <script>
        // — CONFIGURAÇÃO BÁSICA —
        const container = document.getElementById('container');
        const scene = new THREE.Scene();
        const camera = new THREE.PerspectiveCamera(55, window.innerWidth / window.innerHeight, 0.1, 1000);
        camera.position.set(0, 0, 25);
        camera.lookAt(scene.position);
    
        const renderer = new THREE.WebGLRenderer({ antialias: true });
        renderer.setSize(window.innerWidth, window.innerHeight);
        container.appendChild(renderer.domElement);
    
        // luz ambiente + direcional
        scene.add(new THREE.AmbientLight(0x555555));
        const dirLight = new THREE.DirectionalLight(0xffffff, 1);
        dirLight.position.set(5, 10, 7);
        scene.add(dirLight);
    
        // — PARAMETROS DO JOGO —
        const FIELD_W = 20, FIELD_H = 12;
        const PADDLE_W = 0.5, PADDLE_H = 3, PADDLE_D = 1;
        const BALL_R = 0.4;
        let hue = 0;               // para psicodelia
        let speed = 0.2;           // velocidade inicial da bola
        const MAX_SPEED = 1;
        const AI_SPEED = 0.04;
    
        let playerScore = 0, aiScore = 0;
        const scoreEl = document.getElementById('score');
    
        // — MATERIAIS NEON —
        function makeMaterial() {
          return new THREE.MeshStandardMaterial({
            color: 0xffffff,
            emissive: 0xffffff,
            roughness: 0.2,
            metalness: 0.8
          });
        }
    
        const matPaddle = makeMaterial();
        const matBall = makeMaterial();
        const matWall  = new THREE.MeshBasicMaterial({ color: 0x333333 });
    
        // — OBJETOS DO CENÁRIO —
        // Paredes de cima e baixo
        const wallGeo = new THREE.BoxGeometry(FIELD_W, 0.2, 2);
        const wallTop = new THREE.Mesh(wallGeo, matWall);
        const wallBot = wallTop.clone();
        wallTop.position.y =  FIELD_H / 2 + 0.1;
        wallBot.position.y = -FIELD_H / 2 - 0.1;
        scene.add(wallTop, wallBot);
    
        // Paddles
        const paddleGeo = new THREE.BoxGeometry(PADDLE_W, PADDLE_H, PADDLE_D);
        const paddlePlayer = new THREE.Mesh(paddleGeo, matPaddle);
        const paddleAI     = new THREE.Mesh(paddleGeo, matPaddle);
        paddlePlayer.position.x = -FIELD_W/2 + PADDLE_W;
        paddleAI.position.x     =  FIELD_W/2 - PADDLE_W;
        scene.add(paddlePlayer, paddleAI);
    
        // Bola
        const ballGeo = new THREE.SphereGeometry(BALL_R, 32, 16);
        const ball = new THREE.Mesh(ballGeo, matBall);
        scene.add(ball);
    
        // Velocidade da bola
        let ballVel = new THREE.Vector3(speed, 0, 0);
    
        // — FUNÇÕES AUXILIARES —
        function resetBall() {
          ball.position.set(0, 0, 0);
          speed = 0.2;
          const dir = Math.random() > 0.5 ? 1 : -1;
          ballVel.set(dir * speed, 0, 0);
        }
    
        // Mapea mouse Y para paddle do jogador
        window.addEventListener('mousemove', e => {
          const y = (e.clientY / window.innerHeight) * 2 - 1;
          paddlePlayer.position.y = -y * (FIELD_H / 2 - PADDLE_H/2);
        });
    
        // Ajusta viewport no resize
        window.addEventListener('resize', () => {
          camera.aspect = window.innerWidth / window.innerHeight;
          camera.updateProjectionMatrix();
          renderer.setSize(window.innerWidth, window.innerHeight);
        });
    
        // — LOOP DE JOGO —
        function animate() {
          requestAnimationFrame(animate);
    
          // 1) Atualiza cores psicodélicas
          hue = (hue + 0.5) % 360;
          const h1 = hue / 360, h2 = (hue + 0.2) % 1, h3 = (hue + 0.4) % 1;
          matPaddle.color.setHSL(h1, 1, 0.5);
          matPaddle.emissive.setHSL(h2, 1, 0.3);
          matBall.color.setHSL(h3, 1, 0.7);
          matBall.emissive.setHSL(h3, 1, 0.7);
    
          // 2) Move a bola
          ball.position.add(ballVel);
    
          // 3) Colisão com paredes de cima/baixo
          if (ball.position.y + BALL_R > FIELD_H/2 || ball.position.y - BALL_R < -FIELD_H/2) {
            ballVel.y *= -1;
          }
    
          // 4) IA: move em direção à bola
          const diffY = ball.position.y - paddleAI.position.y;
          paddleAI.position.y += diffY * AI_SPEED;
          // limita IA dentro do campo
          paddleAI.position.y = THREE.MathUtils.clamp(
            paddleAI.position.y,
            -FIELD_H/2 + PADDLE_H/2,
             FIELD_H/2 - PADDLE_H/2
          );
    
          // 5) Colisão bola vs paddles
          function hitPaddle(paddle) {
            const dx = Math.abs(ball.position.x - paddle.position.x);
            const dy = Math.abs(ball.position.y - paddle.position.y);
            return dx < PADDLE_W + BALL_R && dy < PADDLE_H/2 + BALL_R;
          }
          if (hitPaddle(paddlePlayer) && ballVel.x < 0 ||
              hitPaddle(paddleAI)     && ballVel.x > 0) {
            // rebate e ajusta ângulo com base no ponto de impacto
            const paddle = ballVel.x < 0 ? paddlePlayer : paddleAI;
            const relY = (ball.position.y - paddle.position.y) / (PADDLE_H/2);
            const angle = relY * Math.PI/4; // ±45°
            const dir = ballVel.x < 0 ? 1 : -1;
            speed = Math.min(MAX_SPEED, speed + 0.02);
            ballVel.set(
              dir * speed * Math.cos(angle),
              speed * Math.sin(angle),
              0
            );
          }
    
          // 6) Verifica pontuação
          if (ball.position.x < -FIELD_W/2 - BALL_R) {
            aiScore++;
            scoreEl.textContent = `${playerScore} : ${aiScore}`;
            resetBall();
          }
          if (ball.position.x > FIELD_W/2 + BALL_R) {
            playerScore++;
            scoreEl.textContent = `${playerScore} : ${aiScore}`;
            resetBall();
          }
    
          renderer.render(scene, camera);
        }
    
        // Inicia
        resetBall();
        animate();
      </script>
    </body>
    </html>
    

    Como funciona:

    1. Usamos Three.js para criar uma cena 3D, com câmera em perspectiva.
    2. Dois paddles (caixas), uma esfera (bola) e duas “paredes” superiores/inferiores.
    3. Controle do jogador via mouse Y, IA simples que segue a bola.
    4. Sistema de pontuação exibido em HTML.
    5. Efeito psicodélico garantido por: • Animação CSS de hue-rotate no container,
      • Atualização contínua de materiais Three.js via HSL.

    Basta abrir o HTML num navegador moderno e curtir o Pong 3D em looping colorido! 🎮🌈

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