FruitTetris.cpp
// Called at the start of play and every time a tile is placed.
Called at the start of play and every time a tile is placed.
Called at the start of play and every time a tile is placed .
void newtile()
{
	tilepos = vec2(5, 19); 
	int randTileType = rand() % 5;
	int randRotation = rand() % 4;
	randTileType = 1; 
	for (int i = 0; i < 4; i++) {
		tile[i] = allRotations[randTileType][randRotation][i];
	}
	currentRotation = randRotation; 
	for (int i = 0; i<4; i++) 
	{
		int x = tilepos.x + tile[i].x;
		int y = tilepos.y + tile[i].y;
		for (int j = 0; j<4; j++) 
			currentTileType[i][j] = allRotations[randTileType][i][j]; 
		if (y > 19) 
		{ 
			tilepos.y = tilepos.y - 1;
			y = 19;
		}
	}
	for (int i = 0; i < 4; i++)
	{
		int x = tilepos.x + tile[i].x;
		int y = tilepos.y + tile[i].y;
		if (board[x][y] == true) 
		{
			std::cout << "rewrwerew";
			exit(EXIT_SUCCESS);
		}
	}
	updatetile();
	vec4 newcolours[24];
	for (int i = 0; i < 4; i++) 
	{
		vec4 randomColour = colors[4];
		for (int j = 0; j < 6; j++) 
			newcolours[(i * 6) + j] = randomColour;
		tileCellColor[i] = randomColour; 
	}
	glBindBuffer(GL_ARRAY_BUFFER, vboIDs[5]); 
	glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(newcolours), newcolours); 
	glBindBuffer(GL_ARRAY_BUFFER, 0);
}
void newtile ( ) { tilepos = vec2 ( 5 , 19 ) ; int randTileType = rand ( ) % 5 ; int randRotation = rand ( ) % 4 ; randTileType = 1 ; for ( int i = 0 ; i < 4 ; i ++ ) { tile [ i ] = allRotations [ randTileType ] [ randRotation ] [ i ] ; } currentRotation = randRotation ; for ( int i = 0 ; i < 4 ; i ++ ) { int x = tilepos . x + tile [ i ] . x ; int y = tilepos . y + tile [ i ] . y ; for ( int j = 0 ; j < 4 ; j ++ ) currentTileType [ i ] [ j ] = allRotations [ randTileType ] [ i ] [ j ] ; if ( y > 19 ) { tilepos . y = tilepos . y - 1 ; y = 19 ; } } for ( int i = 0 ; i < 4 ; i ++ ) { int x = tilepos . x + tile [ i ] . x ; int y = tilepos . y + tile [ i ] . y ; if ( board [ x ] [ y ] == true ) { std :: cout << " " ; exit ( EXIT_SUCCESS ) ; } } updatetile ( ) ; vec4 newcolours [ 24 ] ; for ( int i = 0 ; i < 4 ; i ++ ) { vec4 randomColour = colors [ 4 ] ; for ( int j = 0 ; j < 6 ; j ++ ) newcolours [ ( i * 6 ) + j ] = randomColour ; tileCellColor [ i ] = randomColour ; } glBindBuffer ( GL_ARRAY_BUFFER , vboIDs [ 5 ] ) ; glBufferSubData ( GL_ARRAY_BUFFER , 0 , sizeof ( newcolours ) , newcolours ) ; glBindBuffer ( GL_ARRAY_BUFFER , 0 ) ; }
Called at the start of play and every time a tile is placed.
Called at the start of play and every time a tile is placed .
// Set tile at the top of the board. //Show current rotation. //load the current tile type with the right shape // After the grid is exceeded. // Bind the VBO containing current tile vertex colours. // Put the colour data in the VBO.