FruitTetris.cpp
// Check if the whether top or bottom is full.
Check if the whether top or bottom is full.
Check if the whether top or bottom is full .
void checkfullrow(int row)
{
	bool full = true;
	for (int i = 0; i<10; i++) 
	{
		full = full && board[i][row] == true;
	}
	if (full)
	{
		glBindBuffer(GL_ARRAY_BUFFER, vboIDs[3]);
		for (int i = row; i<20; i++) 
		{
			for (int j = 0; j<60; j++) 
			{
				if (i == 19) 
				{
					boardcolours[1140 + j] = black;
				}
				else 
				{
					boardcolours[60 * i + j] = boardcolours[60 * (i + 1) + j];
				}
			}
			for (int j = 0; j<10; j++) 
			{
				if (i == 19) 
				{
					board[j][i] = false;
				}
				else 
				{
					board[j][i] = board[j][i + 1];
				}
			}
		}
		glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(boardcolours), boardcolours);
		glBindVertexArray(0);
	}
	if (full)
	{
		checkfullrow(row);
	}
	else 
	{
		if (row < 20)
			checkfullrow(row + 1);
	}
}
void checkfullrow ( int row ) { bool full = true ; for ( int i = 0 ; i < 10 ; i ++ ) { full = full && board [ i ] [ row ] == true ; } if ( full ) { glBindBuffer ( GL_ARRAY_BUFFER , vboIDs [ 3 ] ) ; for ( int i = row ; i < 20 ; i ++ ) { for ( int j = 0 ; j < 60 ; j ++ ) { if ( i == 19 ) { boardcolours [ 1140 + j ] = black ; } else { boardcolours [ 60 * i + j ] = boardcolours [ 60 * ( i + 1 ) + j ] ; } } for ( int j = 0 ; j < 10 ; j ++ ) { if ( i == 19 ) { board [ j ] [ i ] = false ; } else { board [ j ] [ i ] = board [ j ] [ i + 1 ] ; } } } glBufferSubData ( GL_ARRAY_BUFFER , 0 , sizeof ( boardcolours ) , boardcolours ) ; glBindVertexArray ( 0 ) ; } if ( full ) { checkfullrow ( row ) ; } else { if ( row < 20 ) checkfullrow ( row + 1 ) ; } }
Check if the whether top or bottom is full.
Check if the whether top or bottom is full .