The use of lerp in that specific case can be a pain for many reasons:
- it's not a linear movement, it's an ease out. For grid movement it might look a bit weird
- it's very unprecise because the way you use it is the "tricky" way and you reach destination only because of floating point rounding. So you have to do sensibility checks if you want to stay on grid.
- the speed value is not really a speed, it's only a factor that make the interpolation faster of slower but it's not a 'x pixel per second' value (ok I'm being picky here (: )
so yeah for grid movement I prefer either using what I posted, or using lerp but by making the third parameter (t) evolve from 0 to 1.
Using lerp could be intersting because this way you can do ease in or out like this
set X to lerp(start,end,t^2) for ease in
set X to lerp(start,end,t^0.5) for ease outYann2012-05-11 18:08:15