JSFiddle - React, Tailwind, and code Playground

by mendelthecoder

JavaScript

function nothingIsBelow() {

		//check if square below is actually itself
	function selfCheck(i){
		if(fallingPiecePos.indexOf({
			y : fallingPiecePos[i].y + 1,
			x : fallingPiecePos[i].x
		}) < 0 ){ 
			return false; 
		} else {
			return true;
		}
	}
	
		//loop through the four squares that make up the falling piece
	for ( i = 0; i < 4; i++ ) {
			//check if square is resting on something			***other then itself***     or has hit the bottom
		if( ( ( fallingPiecePos[i].y + 1 ) > ( ROWS - 1 ) ) || ( !board[ fallingPiecePos[i].y + 1 ][ fallingPiecePos[i].x ] && selfCheck(i) ) ){
			return false;
		}
	}
	return true;
}