After spending some hours trying to solve a simple equation I realized that I've to get back to the math books, I found a very good discussion about this subject in yahoo answers what you need to know about maths in order to create games.
Ok, I wasted 2 hours into this equations and then remembered something (very blur btw) about vectors, how they should be used to move a point into the direction of a line (vector), that's how I crossed with this: http://www.gamedev.net/topic/600086-find-point-between-2-points/ actually the problem was very easy to solve:
p1x=1;
p1y=1;
p2x=4;
p2y=4;
dirx=p2x-p1x;
diry=p2y-p1y;
p3x = p1x+dirx*0.25;
p3y = p1y+diry*0.25;
First you need to find the direction of the vector, you get that doing a substraction between the 2 points (x2, y2) - (x1, y1), now that you have the direction you should apply it to the new point and that's it. easy right?
Now my game has a beatiful rocket moving into the direction of the UFO, one step further in the game creation.
No comments:
Post a Comment