2D array Recursion -
so trying build bubble breaker program. way game works has board several colors. spots coming off spot (horizontal , vertical) not diaganol , off chech around new spot until no spots left
public void setsurroundingsimilartotrue(int row, int col, int correctcolor){ if(row >= 0 && row < this.myboard.length && col >= 0 && col < this.myboard.length) if(this.myboard[row][col].getcolorvalue() == correctcolor){ this.myboard[row][col].setstatustrue(); //system.out.println(row); setsurroundingsimilartotrue(row - 1, col, correctcolor); setsurroundingsimilartotrue(row + 1, col, correctcolor); setsurroundingsimilartotrue(row, col - 1, correctcolor); setsurroundingsimilartotrue(row, col + 1, correctcolor); } }
this did , cant see whats wrong.
you have infinite recursion code. before doing recursion, check if current row, col
position isn't set true
.
Comments
Post a Comment