

Coding Drawing the grid of blocksĪ square is drawn for each block in the playing area. Once all of the pieces have been taken, a new random sequence is created. When a piece comes to rest, the blocks of the piece are added to the inert blocks, and the next piece is created.Ī sequence of one of each of the seven pieces in a random order is created, and the next piece is taken from this sequence. When the drop button is pressed, the piece moves down until the next position would overlap an inert block or be outside the playing area, at which point it has come to rest. When one of the rotate buttons is pressed, the piece changes its rotation variation, unless this variation would overlap an inert block or be outside the playing area. The player can move the piece left and right, unless this new position would overlap an inert block or be outside the playing area.Īfter an amount of time has passed, the piece moves down, unless this new position would overlap an inert block or be outside the playing area, in which case it has come to rest. The currently falling piece is stored as a number representing which type of piece it is, a number representing which rotation variation it is at, and numbers representing its X and Y position in the playing area.Ī new piece is created at the top of the screen, unless it would overlap an inert block, in which case the game is over. The string ' ' (a space) represents an empty block, and the strings 'i', 'j', 'l', 'o', 's', 't' and 'z' represent blocks of different colors.Īll the different types of pieces are stored with their rotated variations. The state of a block can either be empty or filled with a block of a certain color. Controls Left arrowĪ grid stores the inert blocks which have already fallen. The game ends when a piece has come to rest and the next piece would immediately overlap a previously fallen block. When an unbroken row of blocks is formed, the row disappears and all the blocks above it move down one row. The type of the next piece that will fall is shown above the playing area. When a piece comes to rest, the next piece falls. The player can move the pieces left and right and rotate them. Pieces fall from the top of the playing area.

Please send any feedback to blocks.love Rules
