Sign in to follow this  

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

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
hi

If you can read Arabic


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 this post


Link to post
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 );
}

Share this post


Link to post
Share on other sites

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

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this