1
votes

I'm trying to create simple 2D action game, something similar to well known Fancy Pants Adventures :) I've been looking for answer for more than week and all I've found is https://gamedev.stackexchange.com/questions/4348/making-a-character-move-along-a-curved-slope-in-a-world-with-gravity which not answers the question. (Yeah, I've found also moving on platforms that are rotated but that's not I'm looking for). I have also found great (and free!) flash game engine - CitrusEngine which I'm currently using, but, sadly, it doesn't provide moving hero along curved terrain.

Well, I can't figure out how to make hero moving along curved terrain like this one: http://dl.dropbox.com/u/4611540/Stackexchange/curvedterrain.png (sorry, I can't post image because of spam prevention mechanism :()

There are plenty of games like this (for ex. Fancy Pants or Robot Unicorn Attack) where main character moves along the curved terrain but I can't find answer how can I do that.

Thanks in advance.

2
The link you posted basic told you what you needed. A few things were suggested in fact. What was the issue with them?bitbandit
Well, when I'm creating curved slope similar to this which I've linked to, flash doesn't make the curved terrain but simple rectangle (like black border around the curve), I suppose that's CitrusEngine ObjectMaker fault but I've no idea how to use only Box2D to create something similar to this, I'm looking for a piece of code which would inspire me :/mswiszcz

2 Answers

1
votes

Fancy Pants Adventures does not use a real physics engine. All of the physics as well as the character's angle on terrain is faked. You can read more about Fancy Pant's physics from the original creator of the game at this link

If you're going to use box2d to try to create curved platforms, it's going to be a bit more complex than what you were probably anticipating. Box2d does not support concave polygons so in order to create any concave polygons you will have to split it up into a series of convex polygons. The best way to do this is to split the conacave shapes up into triangles.

Check out this link to see how that can be done. You can go through his blog and read how he built it or you can just grab his source code from the post I linked to. Inside of the source is a file called Triangulation.as .

You can use the code in that file to split a convex polygon into multiple triangles and then using box2d you can group these new polygons as a single body. This will allow you to make curved terrain and curved platforms.

Good luck

1
votes

I hope this would give you more light on the subject: Create a terrain like the one in Tiny Wings with Flash and Box2D

There's also some pixel hit test collision implemented in Collision Detection Kit (see some example of more advanced collisions: AS3: CDK).