if i have X,Y(10,20) and the speed is 2, will be:
X = X + 2
Y = Y + 2
?
same goes for Z or it depends on direction?(Y or X rotation)

How are you storing the values?

What code are you having trouble with?

You cannot add a speed and a vector. They are different measures. It's mathematically impossible, like trying to add a length to an area.

You can add a vector, as in

i have X,Y(10,20) and the change is is (2,3) , the addition will be:
X = X + 2
Y = Y + 3

i need ask more 2 things:
1 - imagine the line starts on X, Y and Z(10, 20, 40) and ends on X, Y and Z(20, 40, 80)...
using the while() or even for(), how can i walk throw the line points? (like walk on hippotenuse);

2 - how can i add the speed on movement? the same way goes for jump(even on a circle jump)?

if it's to much math questions, you can put me on right tutorial ;)

OK. I'm doing this in 2D to save typing. For 3D just add a Z value.

You are at a point X,Y moving in a straight line. That means that at some regular interval you add something to X and Y. Let's call that a step. A step tells you how much to change the X and Y values by. Let's call those stepX and stepY. It's a loop hat looks like

do (at an interval of some milliseconds) {
       X = X + stepX;
       Y = Y + stepY;
 }

How fast you move along that line depends on (a) how often the loop runs and (b) how big the step is. Normally you would loop about 30 times per second for a smooth motion and reasonable CPU usage. So its the step that you change.

Suppose we are going from X1,Y1 to X2,Y2 and we want that to take 5 seconds - ie 150 times through the loop. The step .has to be

  stepX = (X2 - X1)/150;
  stepY = (Y2 - Y1)/150

ps: if you do this in integer arithmetic you'll hit all kinds of rounding problems. Make the variables doubles precision float.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.