Reputation: 27653
I want to have a pac-man like game where the characters can move only in a certain path, preferably, with the option to have curved paths as well. What's the correct way to achieve that?
Upvotes: 2
Views: 79
Reputation: 6363
You can use splines to model this. The levels would be made up by a set of 2d-points and each player/bot would always be on his way from one point to another. Splines also handle curved paths.
In games Catmull-Rom splines are often used. If you google Catmull-Rom splines you can find theory, pseudo code or implementation of Catmull-Rom in just about any language.
Upvotes: 2