Algorithim for deleting lines in tetris?

I'm making tetris but didn't go the conventional way of using matrices to hold binary id's of my shapes. I thought it would be easier that way, but now I'm stuck on deleting complete lines of blocks. Here is my code that checks for complete lines:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
bool lineComplete = true;
	std::vector<sf::FloatRect> lineTest;
	sf::RectangleShape rect;
	rect.setSize(sf::Vector2f(1, 1));
	sf::FloatRect fr;
	for(int i = 0; i < 58; i++){
		rect.setPosition(i * SQUARE_SIZE, i * SQUARE_SIZE);
		fr = rect.getGlobalBounds();
		while(lineComplete == true){
			for(int j = 0; j < level.GetCollisionObjects().size(); j++){
				if(!fr.intersects(level.GetCollisionObjects()[j])){
					lineComplete = false;
				}
			}
		}
		if(lineComplete == true){
			level.RemoveLine(i);
		}
	}


Now in RemoveLine(), I need to access the individual blocks of each gamePiece. Each gamePiece has a vector of sf::RectangleShapes (SFML), which represent one block of that tetromino:
std::vector<sf::RectangleShape> pieceRectangles_; the sf::RectangleShapes are stored like so:
1
2
3
4
5
6
7
8
9
case 0:
		//line
		for(int i = 0; i < 4; i++){
			sf::RectangleShape rect(sf::Vector2f(10, 10));
			rect.setPosition(origin.position.x + (i * 10), origin.position.y);
			rect.setTexture(&imgr.tetrominoTexture);
			rect.setFillColor(sf::Color(243, 16, 16));
			pieceRectangles_.push_back(rect);
		}


My question is how do I got about accessing particular sf::RectangleShapes stored in this vector if that sf::RectangleShape is located on a complete line that is being deleted? Would I need to create a Block class and give it members that hold each block's location? Or is there another way?
1) I suggest to not store playing field as shapes. After particular shape falls, it is no longer a shape, it is a part of the field. So in the end you will end with 2D array storing boolean variable if block is present here. After that you only need to delete one row and move everything above down.

Topic archived. No new replies allowed.