Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Tetris removin rows problem.

This topic is 5851 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello! I am currently writing a tetris game and i have some trouble with my RemoveRow() function. It is suppose to check the whole playarea ( a [10][20] array ) if there are a complete row somewhere. If so, it shall remove it, move the part of the playarea that is above the row down by one unit. And clear out the top row. All works fine when i only remove one row. But if i remove two rows at once, i can tell by the score that the remove loop were run three times instead of two. I can''t figure out why this happens. This is the code:
void CTetris::RemoveRows()
	int x,

	// true if a fullrow is found, else false.

	bool fullrow;

	for( y = 0 ; y < PLAYAREA_MAXHEIGHT ; y++ )
		// Set fullrow to true.

		fullrow = true;

		// Check if there''s a gap in the current row

		for( x = 0; x < PLAYAREA_MAXWIDTH ; x++ )
			if( BackArea[x + PLAYAREA_OFFSET][y + PLAYAREA_OFFSET] == 0)
				fullrow = false; // if there is, set fullrow to false

		if( fullrow == true )
				for( y2 = y ; y2 > 0 ; y2--)
					for( x2 = 0 ; x2 < PLAYAREA_MAXWIDTH ; x2++ )

				for( x = 0 ; x < PLAYAREA_MAXWIDTH ; x++)
					BackArea[x + PLAYAREA_OFFSET][0 + PLAYAREA_OFFSET] = 0;

				Score = Score + 100;
				if( Score >= 1000 * Level )
					if( m_pTimeInterval >= 100 )
						m_pTimeInterval = m_pTimeInterval - 50;

				// Play deleterow sound



Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!