I would like to draw a land for a motocross game. I've been thinking of Bezier Curves but I am not sure whether this is the best approach. Can you give me some advice? I want to do it in JavaScript, not very good choice but it's personal project so for time being it's OK.
|
|
I found a couple of links that might be useful for others: Example script of Bezier implementation in JS It can be used from JavaScript or ActionScript to animate along a bezier path. Online drawing script/plot, quite useful if you want to make some tests A bit of theory and an implementation example |
|||
|
|
|
Instead of beziers, you probably want b-splines or catmull-rom splines.
Usage: t ranges from 0 to 1, where the value interpolates the spline between two control points, and the floats p0, p1, p2 and p3 are represent the control points (previous, current, next, and the following). To interpolate n-dimensional curves, just call the functions once per axis. The practical difference between bsplines and catmull-rom is basically that catmull-rom goes through all control points while bsplines are more smooth. |
|||
|