#### Archived

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

# Tetris removin rows problem.

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

## 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,
y,
x2,
y2;

// 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++ )
BackArea[x2 + PLAYAREA_OFFSET][y2 + PLAYAREA_OFFSET] = PlayArea[x2 + PLAYAREA_OFFSET][y2 +PLAYAREA_OFFSET - 1];

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

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

// Play deleterow sound

g_pDeleteRow->Play();
}
}

}


1. 1
2. 2
3. 3
Rutin
16
4. 4
5. 5

• 11
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633718
• Total Posts
3013522
×