>> I want to calculate a straight path of points between two points and >> each frame do: >> >> sprite.x, sprite.y = sprite.path[step] >> step++ >> > If you want to be really really really specific with your sprite's movement, > there are some spline classes you can use to make your sprite be > interpolated through multiple points, with a smooth path between them. > There's probably some easily accessible ones on pygame.org--I know that > there's a Kochanek-Bartels spline class in the math section of my graphics > library. > > Ian > I found some code Ian wrote a few years ago to draw the KB spline and modified it to save the points which I've attached which kind of works as a path editor except sometimes it backtracks some if I put a bunch of control points in a line.. My problem is if I draw multiple lines then each of them is drawn in 30 points (steps) right? Each line has to be the exact same length or else using it as a path the sprite will speed up or slow down as it gets to different length lines and obviously curves are more of a problem. I guess I can space out the points and have the sprite go its own speed from point to point, but then I have to handle not passing the target point and dealing with hitting a curve of points which are closer to each other than the sprites per frame movement distance... I imagine having the path editor handle this would be better. Any path editors out there? Mark
Attachment:
Kochanek-Bartels.py
Description: Binary data