Performance-wise, as long as you have followed the statements strictly, we could ensure a decent working solution. (I will demo a working one in the future post)

In this post, particularly, i would like to recap a number of features on the Candy Crush Saga that make the Match 3 game much more interesting - Special Candy Combinations, as stated below:

a)

**Color Bomb**- formed by a match involving 5 candies in a uni-direction

b)

**Striped Candy**- formed by a match involving 4 candies in a uni-direction

c)

**Wrapped Candy**- formed by a match involving 5 candies in a "T", "+" or "L" shape.

Technically speaking, to detect these special candy combinations, it isn't that hard since we could make some checking in the results of the matching detection algorithm.

For example, in the picture above, after the node of 35

^{th}is exchanged with the 43

^{rd}, we would obtain a match of 5 nodes (33

^{rd}, 34

^{th}, 35

^{th}, 36

^{th}and 37

^{th}) according to the 1st statement.

However, the problem does not just end here. Since we are going to 'generate' the special 'candy' (item) ourselves, you might further pose some questions:

Q1: How to determine at where does the special candy reside?

Q2: How to enable those special effects formed by the special candies matches?

To answer the Q1, you would need to take some efforts remembering the index of the nodes touched by the player. If it takes place through random falling, you may take the smallest index of the matches to be the index of the special candy.

In the case of Q2, on the other hand, it is likely more complicated that we have to look into the special combinations one by one.

Consider the nodes exchange of Color Bomb:

a) 1 Color Bomb with 1 normal node

Effect: All the nodes which are identical to the normal node will explode.

b) 1 Color Bomb with 1 Color Bomb

Effect: All the nodes in the matrix explode.

c) 1 Color Bomb with 1 Striped Candy

Effect: All the nodes having the same color become stripped candies and explode.

d) 1 Color Bomb with 1 Wrapped Candy

Effect: All the nodes having the same color explode. And then, all the nodes with a random color explode.

Apart from that, we have to consider the exchange of Striped candy and Wrapped candy:

a) 1 Striped Candy with 1 Striped Candy

Effect: Both Striped Candies explode

b) 1 Striped Candy with 1 Wrapped Candy

Effect: Both candies explode, along with 3x3 matrix crossing both horizontally and vertically

c) 1 Wrapped Candy with 1 Wrapped Candy

Effect: Both candies explode, along with 5x5 matrix surrounding both candies.

No pseudo-code? I believe with the basic algorithms in the previous posts, you would be able to construct the logic here. In case you really want, please leave a message here and i would update this :)

Note:

In my Match 3 game, i don't care about the orientation of the striped candy. Instead, i randomly explode either a horizontal or a vertical line.

Next: A real Android Match 3 Game Demo

## No comments:

## Post a Comment