PDA

View Full Version : What is a good path following solution for a game like puzzloop/zuma?


Kruzoe
08-08-2005, 03:50 AM
Hello, this is my first post and I'm just a beginner. Please forgive me if I'm doing something wrong.

I'm trying to make a game like puzzloop/zuma. I have a problem with a path following method. Currently, I'm using waypoint which the balls start and run to another waypoint using vector. For the straigth line it run smooth and no problem but for the curve it go horrible. May be this is a bug of mine but I want to know.
- Is this a good method?
- Anybody who have made this type of game, Could you please share the solution you used? (Just a solution not source) or guide me to the right solution.
- Are there other solutions better or easier?

Any comments would be appreciated.

PS. Sorry for my bad english.

Regards.

digriz
08-08-2005, 04:02 AM
Using waypoints like you are, you will never get a really smooth looking path movement on curves. Unless you create lots of points for the curve.

Use bezier curves or normalised splines. There should be plenty of source-code and information about it on the net.

svero has been doing a game similar to zuma/puzzloop too. He might have some words of wisdom on the subject, but he might not be willing to give away source-code or his techniques.

svero
08-08-2005, 04:03 AM
Well I dont want to discourage you, but if you're really just a beginner then the zuma style game is probably not the best game to start with. The path algorithm and the various things that can happen along the path is actually very difficult and tricky problem to get right.

If you insist on going on with it.. most people probably use a bezier or similar curve algorithm to specify the path of the balls.

http://en.wikipedia.org/wiki/Bezier_curve

Course this is just the barest start of the problem. If you're really a beginner.. Id recommend a different style of game. Chances are you'll get bogged down trying to get this right with all the collisions, collapses, directions etc..

Emmanuel
08-08-2005, 04:39 AM
I use Bezier curves for Atlantis. The path following is very simple, you just increase the weight until the next control point has taken over and then you move on until you reach the end of the curve.

You will find many tutorials on how to calculate Bezier curves in realtime using linear interpolation. The DeCasteljau algorithm is the one used in Atlantis:
http://www.cubic.org/docs/bezier.htm

(nothing ground-breaking by any means)

Best regards,
Emmanuel

luggage
08-08-2005, 04:40 AM
Funnily enough I posted the source code to some Catmull-Rom interpolation not long ago. You can get it with a rough demo here (http://forums.indiegamer.com/showpost.php?p=52282&postcount=11)

The good thing about Catmull-Rom is that the path goes through all the control points. You'll basically want to make a list of points, then each ball has a 'currentpoint' and a 'position'. Move 'position' from 0.0 to 1.0 and when it gets to 1.0 move it's 'currentPoint' on by 1 and reset 'position' to 0.

To get the position of the ball use the CatmullRom function. You need to pass it 4 points (lets call them a, b, c and d) and a float between 0.0 and 1.0. B and C are the two points you're interested in so pass it...

a = currentpoint-1
b = currentpoint
c = currentpoint+1
d = currentpoint+2

You have to make sure they don't go off the edges of your array of points though. And the float is just your position.

That should be it.

svero
08-08-2005, 04:56 AM
I suspect that algorithm is not iteratively uniform.

That is... Curve(.2) is not equal to Curve(.1) + 10% of the distance of the curve travelled. Or is it?

For a puzzloop style game the balls have to roll at some particular speed so whatever algorithm you use you need a way of increasing the distance along the curve in a predictable way so that you know that the thing you're increasing corresponds with a particular distance along the curve.

svero
08-08-2005, 04:58 AM
Oh and FYI.. I started using the same algorithm as Emmanuel uses for Atlantis but later opted to use a set of detailed control points chopped up into uniform slices. So I don't use curves at all except in the editor when making a new path. The editor spits out a bunch of points and those are used in the game.

Kruzoe
08-08-2005, 05:11 AM
@digriz
Thank you very much for your suggestions.

@svero
Thanks and appreciate your comments. Actually, I have created some games on PocketPC and mobile phone before but it just small and simple game. In PC/Indie scene, I'm just beginner. I may try to code this type of game for a few week (in spare time), just to learn something new. I will return to it someday, If I've gain more level of coding PC game. Thanks again for your advise.

@Emmanuel
Wow! thank you very much for sharing your technique. Your game is look so cool. I'm going to read more and try more for beating it up.

@luggage
Again, Thank you very much. Just collect all invaluable informations here.

I very appreciate all of your comments here. I've just coincident found this forum and suddenly love it. Greate forum and great friendly members.

Regards.

luggage
08-08-2005, 06:19 AM
svero: you're right! good point! You'd have to do something similar to you and chop it up into fixed length segments. Shouldn't be too difficult.

To be honest, every time I see another PuzzLoop game I keep thinking "surely they've had enough of them now and this one can't sell?". Then it goes and sells lots.

svero
08-08-2005, 06:51 AM
I hope i can prove you wrong again next week when mine comes out... its been trying times to see all these clones one right after another. Especially tumble bugs.. similar theme even. I guess we'll see.

revve
08-08-2005, 07:02 AM
/me smells money!!! The all new ZDK - Zuma Developer's Kit. You supply the graphics, we do the rest. Full source included.

Pallav Nawani
08-08-2005, 07:54 AM
Well I dont want to discourage you, but if you're really just a beginner then the zuma style game is probably not the best game to start with. The path algorithm and the various things that can happen along the path is actually very difficult and tricky problem to get right.


What about the rolling balls in zuma? Are those things polygons, or they just have many, many sprites of balls rotating in all directions?

Emmanuel
08-08-2005, 08:11 AM
svero is right, I had the path code working and displaying balls within 1 day of starting Atlantis. The rest of the game took a lot longer :)

svero: you need a constant increase in pixel distance, not in the weight, you're right. Atlantis calculates how much to increase the weight by, in order to increase by a specified number of pixels, but probably there are simpler methods. I kept Beziers as, this way, the artist could save his curve as it was, and test it. That and other stuff allowed both of us to work at almost 100% capacity without waiting on one another (that was my primary objective, above making it easy to code).

pallavnawani: zuma uses sprites for rotation on the Y axis, and uses real-time rotation on the Z axis. You can't know when your balls will start rotating on Z, so you'd need a sprite for each of Y steps * Z steps. If you turn off hardware acceleration in Zuma, there's no rotation on Y if I remember correctly, and then they use sprites for Z.

Best regards,
Emmanuel