O clássico jogo Tetris, lançado originalmente em 1984, comemorou recentemente seu 40º aniversário com uma série de lançamentos e eventos especiais. /EXEMPLO DE ALGORITIMO/SEGURO AUTO E CONSÓRCIOS 027 99949-7001

 SEGURO AUTO CONTATO (027) 99949-7001 WHATS


CONFIRA ESSA OPORTUNIDADE^^

<!DOCTYPE html>

<html lang="en">

<head>

  <meta charset="UTF-8" />

  <meta name="viewport" content="width=device-width, initial-scale=1.0"/>

  <title>Tetris em JavaScript</title>

  <style>

    body {

      background: #111;

      display: flex;

      justify-content: center;

      align-items: center;

      height: 100vh;

      margin: 0;

      color: #fff;

      font-family: Arial, sans-serif;

    }

    canvas {

      background: #222;

      box-shadow: 0 0 10px #0f0;

    }

  </style>

</head>

<body>

  <canvas id="tetris" width="240" height="400"></canvas>


  <script>

    const canvas = document.getElementById('tetris');

    const context = canvas.getContext('2d');

    context.scale(20, 20); // Escala para facilitar o desenho


    // Criação das peças

    function createPiece(type) {

      switch (type) {

        case 'T':

          return [

            [0, 1, 0],

            [1, 1, 1],

            [0, 0, 0]

          ];

        case 'O':

          return [

            [2, 2],

            [2, 2]

          ];

        case 'L':

          return [

            [0, 0, 3],

            [3, 3, 3],

            [0, 0, 0]

          ];

        case 'J':

          return [

            [4, 0, 0],

            [4, 4, 4],

            [0, 0, 0]

          ];

        case 'I':

          return [

            [0, 5, 0, 0],

            [0, 5, 0, 0],

            [0, 5, 0, 0],

            [0, 5, 0, 0]

          ];

        case 'S':

          return [

            [0, 6, 6],

            [6, 6, 0],

            [0, 0, 0]

          ];

        case 'Z':

          return [

            [7, 7, 0],

            [0, 7, 7],

            [0, 0, 0]

          ];

      }

    }


    // Cores das peças

    const colors = [

      null,

      '#FF0D72',

      '#0DC2FF',

      '#0DFF72',

      '#F538FF',

      '#FF8E0D',

      '#FFE138',

      '#3877FF',

    ];


    // Arena (tabuleiro)

    function createMatrix(w, h) {

      const matrix = [];

      while (h--) {

        matrix.push(new Array(w).fill(0));

      }

      return matrix;

    }


    // Colisão entre a peça e o tabuleiro

    function collide(arena, player) {

      const [m, o] = [player.matrix, player.pos];

      for (let y = 0; y < m.length; ++y) {

        for (let x = 0; x < m[y].length; ++x) {

          if (

            m[y][x] !== 0 &&

            (arena[y + o.y] && arena[y + o.y][x + o.x]) !== 0

          ) {

            return true;

          }

        }

      }

      return false;

    }


    // Mescla peça ao tabuleiro

    function merge(arena, player) {

      player.matrix.forEach((row, y) => {

        row.forEach((value, x) => {

          if (value !== 0) {

            arena[y + player.pos.y][x + player.pos.x] = value;

          }

        });

      });

    }


    // Limpa linhas cheias

    function arenaSweep() {

      outer: for (let y = arena.length - 1; y >= 0; --y) {

        for (let x = 0; x < arena[y].length; ++x) {

          if (arena[y][x] === 0) continue outer;

        }

        const row = arena.splice(y, 1)[0].fill(0);

        arena.unshift(row);

        ++y;

      }

    }


    // Desenha uma matriz no canvas

    function drawMatrix(matrix, offset) {

      matrix.forEach((row, y) => {

        row.forEach((value, x) => {

          if (value !== 0) {

            context.fillStyle = colors[value];

            context.fillRect(x + offset.x, y + offset.y, 1, 1);

          }

        });

      });

    }


    function draw() {

      context.fillStyle = '#000';

      context.fillRect(0, 0, canvas.width, canvas.height);


      drawMatrix(arena, { x: 0, y: 0 });

      drawMatrix(player.matrix, player.pos);

    }


    function mergeDrop() {

      player.pos.y++;

      if (collide(arena, player)) {

        player.pos.y--;

        merge(arena, player);

        playerReset();

        arenaSweep();

      }

      dropCounter = 0;

    }


    function playerMove(dir) {

      player.pos.x += dir;

      if (collide(arena, player)) {

        player.pos.x -= dir;

      }

    }


    function playerReset() {

      const pieces = 'TJLOSZI';

      player.matrix = createPiece(pieces[(pieces.length * Math.random()) | 0]);

      player.pos.y = 0;

      player.pos.x = ((arena[0].length / 2) | 0) - ((player.matrix[0].length / 2) | 0);

      if (collide(arena, player)) {

        arena.forEach(row => row.fill(0));

        alert("Game Over!");

      }

    }


    function playerRotate(dir) {

      const pos = player.pos.x;

      let offset = 1;

      rotate(player.matrix, dir);

      while (collide(arena, player)) {

        player.pos.x += offset;

        offset = -(offset + (offset > 0 ? 1 : -1));

        if (offset > player.matrix[0].length) {

          rotate(player.matrix, -dir);

          player.pos.x = pos;

          return;

        }

      }

    }


    function rotate(matrix, dir) {

      for (let y = 0; y < matrix.length; ++y) {

        for (let x = 0; x < y; ++x) {

          [matrix[x][y], matrix[y][x]] = [matrix[y][x], matrix[x][y]];

        }

      }

      if (dir > 0) {

        matrix.forEach(row => row.reverse());

      } else {

        matrix.reverse();

      }

    }


    let dropCounter = 0;

    let dropInterval = 1000;

    let lastTime = 0;


    function update(time = 0) {

      const deltaTime = time - lastTime;

      lastTime = time;


      dropCounter += deltaTime;

      if (dropCounter > dropInterval) {

        mergeDrop();

      }


      draw();

      requestAnimationFrame(update);

    }


    document.addEventListener('keydown', event => {

      if (event.key === 'ArrowLeft') playerMove(-1);

      else if (event.key === 'ArrowRight') playerMove(1);

      else if (event.key === 'ArrowDown') mergeDrop();

      else if (event.key === 'q') playerRotate(-1);

      else if (event.key === 'w') playerRotate(1);

    });


    const arena = createMatrix(12, 20);


    const player = {

      pos: { x: 0, y: 0 },

      matrix: null

    };


    playerReset();

    update();

  </script>

</body>

</html>

Para celebrar as quatro décadas de Tetris, a Digital Eclipse lançou "Tetris Forever", uma coletânea que reúne mais de 15 versões históricas do jogo, incluindo títulos raros como Tetris Battle Gaiden e Super Tetris 2 + Bombliss. Além disso, a coleção apresenta o modo inédito Tetris Time Warp, que permite aos jogadores alternar entre diferentes estilos e épocas do jogo. O lançamento ocorreu em 12 de novembro de 2024 para diversas plataformas, incluindo Nintendo Switch, PlayStation 4 e 5, Xbox Series X|S, Atari VCS e PC (Steam e GOG) .Adrenaline+5CNN Brasil+5Nintendo Blast+5Gizmodo+4Nintendo Blast+4Adrenaline+4Wikipedia+1


📚 Henk Rogers Lança Livro no Brasil

Henk Rogers, cofundador da The Tetris Company e figura chave na popularização do Tetris globalmente, esteve presente na Gamescom Latam 2025, realizada em São Paulo. Durante o evento, ele lançou seu livro The Perfect Game – Tetris: From Russia with Love, que detalha sua jornada para adquirir os direitos do jogo e sua colaboração com Alexey Pajitnov, criador do Tetris. Rogers também participou de um painel moderado por Dean Takahashi, compartilhando insights sobre a história do jogo e sua importância cultural .Wikipedia+3UOL+3Omelete+3Omelete+1


🏆 Red Bull Tetris World Final 2025

A Red Bull organizou o Red Bull Tetris World Final 2025, um torneio de eSports que culminou em um espetáculo aéreo em Dubai. Mais de 2.000 drones iluminaram o céu, criando o primeiro jogo de Tetris jogável ao vivo no ar. Jogadores de mais de 55 países competiram em qualificatórias móveis, com os melhores avançando para batalhas 1v1 em Toronto antes da final em Dubai .Esports.gg

Comentários

Postagens mais visitadas deste blog

Mão Robótica com Impressora 3D

💻 Trigonometria + Programação = Aprendizado Inteligente!