# Drawing Tetrominoes using classList.add()

Created by Ania about a year ago

0

No description provided

0

Tetrimino Shape Not able to understand , how i draw tetrimino shapes (stuck with width concept).

Umapati Kumar Sinha

@umapati

0

currentPosition By currentPosition initialization, which position we are talking about and why it is 4?

Shivam Kumar

@shiv23

0

I can't understand what is logic for const lTetromino = [ [1,width+1,width*2+1,2]]

Swarup Das

@swarupd

2

In Tetris, the `lTetromino` represents one of the tetromino shapes that can be used in the game. Tetrominos are geometric shapes made up of four square blocks, and they are the building blocks of the game.

The code snippet you provided represents the `lTetromino` shape as an array of numbers. Each number corresponds to an index position of a square block within the game grid.

Let's break down the array and its values:

``````const lTetromino = [1, width + 1, width * 2 + 1, 2];
``````
• `1` corresponds to the index position of the first block in the tetromino shape.
• `width + 1` corresponds to the index position of the second block, which is one row below the first block.
• `width * 2 + 1` corresponds to the index position of the third block, which is two rows below the first block.
• `2` corresponds to the index position of the fourth block, which is one column to the right of the first block.

To visualize this tetromino shape, let's assume `width` represents the number of columns in the game grid. For example, if `width` is set to `10`, the `lTetromino` shape would look like this:

``````. . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . .
1 1 . . . . . . . .
``````

In this visualization, the numbers `1` represent the blocks of the `lTetromino` shape. The empty spaces `.` represent the empty cells in the game grid.

In the game of Tetris, these tetromino shapes can be moved, rotated, and stacked to fill rows and clear them. Each shape has its own unique array of numbers representing its position and orientation within the game grid.

ChatGpt to rescue xd.

Paras Mittal

@paras09

0

Aadha dum to maine yaha tod diya,lekin guys contniue kro resume me kaam aayega

Shreyas Dhande

@shreyasthelofer

0

Here all tetrominoes :

const lTetris = [ [1, width + 1, width * 2 + 1, 2], [width, width + 1, width + 2, width * 2 + 2], [1, width + 1, width * 2 + 1, width * 2], [width, width * 2, width * 2 + 1, width * 2 + 1] ]

``````const zTetris = [
[0, width, width + 1, width * 2 + 1],
[width + 1, width + 2, width * 2, width * 2 + 1],
[0, width, width + 1, width * 2 + 1],
[width+1, width+2, width*2, width*2+1]
]

const tTetris = [
[1, width, width + 1, width + 2],
[1, width + 1, width + 2, width * 2 + 1],
[width, width + 1, width + 2, width * 2 + 1],
[1, width, width+1, width*2+1]
]

const oTetris = [
[0, 1, width, width + 1],
[0, 1, width, width + 1],
[0, 1, width, width + 1],
[0, 1, width, width + 1],
]

const iTetris = [
[1, width + 1, width * 2 + 1, width * 3 + 1],
[width, width + 1, width + 2, width + 3],
[1, width + 1, width * 2 + 1, width * 3 + 1],
[width, width+1, width+2, width+3]
]
``````

Parmjeet Mishra

@parmjeetmishra