Constant speed, known distance movement

Ok, so I have an image that needs to move from point A(entryX,entryY) to point B(destinationX, destinationY).

There are different images moving at the same time, all headed for the same point B. Each have their own random point A.

Their co-ordinates are updated every 100ms by doing myX+=travelX and myY+=travelY

Using the code below that someone helped me with the images do travel to point B but their speed is different depending on their start location - if they are basically head on (i.e. point A x is almost the same as point B x) then the speed is very fast. If there is large difference in x, then speed is slow.

How do I make it so speed will be constant no matter where the start point (Point A) is?

myX = entryX;

myY = entryY;

destinationX = 300;

destinationY = 300;

xDistance = entryX-destinationX;

yDistance = entryY-destinationY;

double yD2 = yDistance * yDistance;

double xD2 = xDistance * xDistance;

travelX = Math.sqrt( (xD2 + yD2) / yD2 );

travelY = Math.sqrt( (xD2 + yD2) / xD2 );

[1158 byte] By [nealbo101a] at [2007-11-26 20:07:47]
# 1
Have a look at the Bresenham line drawing algoritm: http://en.wikipedia.org/wiki/Bresenham's_line_algorithmkind regards,Jos
JosAHa at 2007-7-9 23:10:03 > top of Java-index,Java Essentials,New To Java...
# 2
Thanks for the link - it seems to be what I need, however I can't seem to get a grip on how I'd implement this. Could somebody please help me out?
nealbo101a at 2007-7-9 23:10:03 > top of Java-index,Java Essentials,New To Java...
# 3
I think i should also mention that this is gradual movement as in it may take 10 seconds to get from pointA to pointB.
nealbo101a at 2007-7-9 23:10:03 > top of Java-index,Java Essentials,New To Java...
# 4

> I think i should also mention that this is gradual

> movement as in it may take 10 seconds to get from

> pointA to pointB.

@both of your last two replies: Bresenham simply calculates what points

to travel through from point A to point B. It doesn't forbid anything if you

want to Thread.sleep between drawing each point/image.

kind regards,

Jos

JosAHa at 2007-7-9 23:10:03 > top of Java-index,Java Essentials,New To Java...