The game is a game where you click a colored block it disappears with the surround in blocks of the same color. However, when I call erase inside this function, it causes an illegal operation
Can anyone see anything wrong with this code?
Code: Select all
void Erase(int x, int y, int ex)
{
int tokill = g_blocks[x][y];
g_blocks[x][y] = BLOCK_EMPTY;
//kill the linked ones
if(((x + 1) <= 9) && (ex != EXCLUDE_LEFT))
{
if(g_blocks[x + 1][y] == tokill)
{
Erase(x + 1, y,EXCLUDE_LEFT);
}
}
if(((x - 1) >= 0) && (ex != EXCLUDE_RIGHT))
{
if(g_blocks[(x - 1)][y] == tokill)
{
Erase(x - 1, y,EXCLUDE_RIGHT);
}
}
if(((y + 1) <= 15) && (ex != EXCLUDE_BELOW))
{
if(g_blocks[x][(y + 1)] == tokill)
{
Erase(x, y + 1,EXCLUDE_BELOW);
}
}
if(((y - 1) >= 0) && (ex != EXCLUDE_ABOVE))
{
if(g_blocks[x][(y - 1)] == tokill)
{
Erase(x, y - 1,EXCLUDE_ABOVE);
}
}
}
