[need help] I have problem with game algorithm

• September 8th, 2013, 03:28 PM
Tlipre
[need help] I have problem with game algorithm
Attachment 2307
I want to create games like this. And now I can check nearly of block click by user.(I use algorithm name "Floodfill")
But when it disappear I can't check which block must fall replace that block.

If you don't understand my explanation. Please see the picture on top. when I click purple block at (1,2). It will be floodfill to block at (1,3).
And all of them will be disappear. BUT ! I can't coding to dismount the blue block add(1,1) to (1,3).

Ps. I come from country where don't use English is Official language.
If I use wrong word or wrong tense. Please provide me a correct word.

Thank you
• September 8th, 2013, 08:48 PM
jps
Re: [need help] I have problem with game algorithm
Quote:

Originally Posted by Tlipre
Ps. I come from country where don't use English is Official language.

Welcome to the forum :D
Happy to see you here no matter where you are from.

Quote:

Originally Posted by Tlipre
I can't coding to dismount the blue block add(1,1) to (1,3).

How does the program store these objects? Post the code?
• September 8th, 2013, 09:31 PM
Tlipre
Re: [need help] I have problem with game algorithm
Quote:

void floodfill(int x, int y, int color) {
int[] left = { x - 1, y };
int[] right = { x + 1, y };
int[] up = { x, y - 1 };
int[] down = { x, y + 1 };
if (block[x][y].getColor() == color) {
count++;
if (left[0] != -1 && !isInList(left[0], left[1])) {
floodfill(left[0], left[1], color);
}
if (right[0] != 10 && !isInList(right[0], right[1])) {
floodfill(right[0], right[1], color);
}
if (up[1] != -1 && !isInList(up[0], up[1])) {
floodfill(up[0], up[1], color);
}
if (down[1] != 10 && !isInList(down[0], down[1])) {
floodfill(down[0], down[1], color);
}
}
}
I have Global arrayList to keep beside of block what user click (beside and same color).In this code it name "pastTemp"

Ps. The arrayList name "past" is build for keep block what I recursive to check. you can ignore them.
• September 8th, 2013, 10:04 PM
jps
Re: [need help] I have problem with game algorithm

[0,0] [0,1] [0,2] [0,3]
[1,0] [1,1] [1,2] [1,3]
[2,0] [2,1] [2,2] [2,3]
[3,0] [3,1] [3,2] [3,3]

With this you can easily move blocks side to side, or up and down
• September 9th, 2013, 07:45 AM
KevinWorkman
Re: [need help] I have problem with game algorithm
This thread has been cross posted here: