# From A ( X1,Y1) to B(X2,Y2) dose this work and what dose not work?

This topic is 4108 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

hi ppl. i´m trying to just do a simple 2d moveTo command. so this is the Math i use so far. X = X1 - X2; Y = Y1 - Y2; X_Pos += X; Y_Pos += Y; and i can get 2 results. 1: the pixel just jumps to the EXAKT kordinats of my B point. just from A to B. and well thats what i want but i actualy want it to move not just jump. 2: it moves in the wrong direction and it actualy Moves but its going fast as hell. and im using C++ // if my description is bad tell me.

##### Share on other sites
hi

Take these lessons

http://www.arabteam2000-forum.com/index.php?showtopic=130727

and

http://www.arabteam2000-forum.com/index.php?showtopic=131334

Or can Translated by (google Translate)

Tell me if you don't understanding that lessons.

##### Share on other sites
Firstly, just to point out that a post on a topic such as this doesn't really belong in the AI forum, preferably you'd post it in For Beginners or else in Math and Physics forum.

Anyway,

One way to achieve what you want is as follows:

xPos = x1;yPos = y1;for (int i = 0; i <= numSteps; i++) {       clearScreen();    drawPixel( xPos, yPos );    xPos += (x2 - x1) / numSteps;    yPos += (y2 - y1) / numSteps;}

And there's also this method:

for (int i = 0; i <= numSteps; i++) {    step = i / numSteps;    xPos = x1 + (x2 - x1) * step;    yPos = y1 + (y2 - y1) * step;    clearScreen();    drawPixel( xPos, yPos );}

1. 1
2. 2
Rutin
16
3. 3
4. 4
5. 5

• 11
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633721
• Total Posts
3013532
×