Skip to main content
GameDev.net gamedev.net
🔒 Locked

Zuma algorithm

Started by tion80 Jan 21, 2005 at 12:12 PM 4 replies 9.7k views
Original Post
tion80
tion80
zuma game click Has anyone played this game before? I have the project to make the game similar to this Zuma. However, I have had hard time to implement the algorithm for this game. especially , when there's a chain combo, blocks move back to be destroyed which I think really hard to implement I consider using List... and I want to use precise OOP. Help me out guyz. [Edited by - tion80 on January 21, 2005 1:16:53 PM]
uncleben
uncleben
Since you use the word algorithm wrong,
i assume that you don't have that much experience in programming, so maybe you should start out with something more simple?
Benjamin Block
jbadams
jbadams
I've finished that game. A good concept, somewhat addictive gameplay.

To create the combos, you simply need to check if the balls on either side of a line of destroyed balls are of the same colour. If they are, you move the front of the line back into contact with the rear. Then, perform the check to see if there are now three matching balls in a row where the lines joined together, and if so, repeat the process. (If at the start of the process, the balls do not match, you simply stop moving the front line of balls until the rear line catches up to it again).


Some ASCII diagrams may help to illustrate how it works.
Letters are balls of a certain colour. Different letters represent different colours, so two of the same letter are balls of the same colour. Dashes indicate empty space on the track (which due to this being an ASCII diagram is straight). The ^ symbol indicates where the player has just shot a new ball into the line. Assume the balls are moving towards the right.

Example 1:
Before:---RGBBBYRR---      ^After:---RG---YRR---

Because the balls on either side of the blue (B) balls do not match (green (G) and yellow (Y)), when the blue balls are eliminated, the gap is not closed, and there is no combo. The front segment of the line stops moving until the rear catches it.

Example 2:
Before:---RGBBBGYRR---      ^After:---RGGYRR------

The balls on either side of the eliminated blue (B) balls match (both are green (G)), so the front of the line is dragged back into contact with the rear. However, because this doesn't create a new line of three green (G) balls, no further balls are eliminated - there is no combo.

Example 3:
Before:---RGBBBGGRY---      ^After:---RGGGRY------Combo result!:---RRY---------

The balls on either side of the eliminated blue (B) balls match (both are green (G)), so the front of the line is dragged back into contact with the rear. This creates a line of three green (G) balls, so an additional elimination is performed - this is a combo. The check is made again, with one of the above results.

I'll leave it to you to make an attempt at coding a solution to this. If you are unable to do so, then perhaps it would be wise to attempt a simpler game first, as uncleben suggested. If you've made an attempt at coding a solution yourself already (or if you do so now), but are still unable to get it to work, post your code (information on the source tag for posting code can be found in this FAQ), and someone will be happy to provide additional help.
- Jason Astle-Adams
raptorstrike
raptorstrike
in a word your answer is RECURSION (a function that calls itself or 2 functions that call each other), you need a ball to check for a ball of same color and if found you need that ball to check for another ball of same color ect...
void Ball::Search(){  Ball* found;  //search for balls of same color using "this" pointer (this->) and if you find one store it in found  if(found)  {   current_ball->Destroy(found);  };  else current_ball->Destory(NULL);};void Ball::Destroy(Ball* To_Die){ //make "this" ball blow up or whatever dont delete the pointer yet though if(To_Die) To_Die->Search();//call search on the To_Die ball else return;}


this is a psudo example and im pretty sure i got this right (i havnt used recursion much) but there you go

[Edited by - raptorstrike on January 22, 2005 11:20:49 AM]
____"This just in, 9 out of 10 americans agree that 1 out of 10 americans will disagree with the other 9"- Colin Mochrie
kzar
kzar
I was wondering how this game worked too actualy. I was wondering how they made it possible to have the path that the balls go down have smooth round corners or whatever shape they wanted.
jbadams
jbadams
Quote:
Original post by kzar
I was wondering how this game worked too actualy. I was wondering how they made it possible to have the path that the balls go down have smooth round corners or whatever shape they wanted.


The 'level' you see is simply an image displayed on the screen. You can store curved lines using an equation (in a similar fashion to the way that lines in vector-graphics are stored), and simply move the balls smoothly along that path. If you watch carefully, the individual movement of the balls over some corners isn't always perfectly smooth, but due to the image displayed behind the balls having a smooth path, the fact that there are many balls, and the fact you are kept distracted, it isn't really noticable. On the final level it stands out more, as the background doesn't actually contain the path the balls follow.

'Tunnels' and 'bridges' are stored in a seperate .gif file if you're interested. The background is stored as a .jpg, and the remaining information for each level is stored in a .dat file.
- Jason Astle-Adams

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.