On Wed, Aug 18, 2010 at 1:25 PM, B W <stabbingfin...@gmail.com> wrote:
> To use real-time curves in this manner I had to solve the same problem you > mention, Mark, that the distance between points varies and results in > unwanted sprite speed variations. I ended up tracking sub-pixel sprite > position as a float, and advancing to the next curve point when the distance > traversed meets or exceeds the distance between the current and next point. > Hi, Yes, I've noticed this problem. However, reading this gives me an idea; you could advance to the next timestep, and then converge on another point on the line based on distance. Example pseudocode "thoughts" of an algorithm. t = 0.0; target distance = 5px/step LOOP { #Begin time step t += 0.1 d = distance(bézier _point[0.1],bézier_point[0.0]) = 7.33 px #7.33 px is too far! Try (0.1 - 0.0) * 0.5 + 0.0 = 0.05 t = 0.05 d = distance(bézier_point[0.05],bézier_point[0.0]) = 4.68 px #4.68 px is too short! Try (0.1 - 0.05) * 0.5 + 0.05 = 0.0725 t = 0.0725 d = distance(bézier_point[0.05],bézier_point[0.0]) = 5.01 px #Our target is 5 px/step, so this is slightly too far to move the #sprite, but 5.01 px falls within a set tolerance of 5 px. #Thus, we'll use this value for t at the next timestep. t = 0.0725 } ENDLOOP Ian