JSFiddle - React, Tailwind, and code Playground

by mendelthecoder

JavaScript

function writePiece(){
	fallingPiecePos = shapes[fallingPiece - 1];
	for ( i = 0; i < 4; i++ ) {
		board[ fallingPiecePos[i].y ][ fallingPiecePos[i].x ] = fallingPiece;
	}
}


function writePiece(){
	fallingPiecePos = [];
	for ( var i = 0; i < 4; i++ ) {
	fallingPiecePos[i] = {};
		for( var j in shapes[fallingPiece - 1]){
			fallingPiecePos[i][j] = shapes[fallingPiece - 1][j];
		}
		board[ fallingPiecePos[i].y ][ fallingPiecePos[i].x ] = fallingPiece;
	}
}