I have a Player class that houses my player.
I have an Enemy class that houses my enemy.
I want an enemy to appear at the center of the screen and then get the position if the player and move in that direction, in a straight line.
It must not follow but rather get the position of the player at a point in time and move in a straight line to that position and off the screen.
I can get it to move to the player using vector maths, but how do I make it continue to go off the screen in that straight line?
I do I get the player's position? I get the position but it's the live position that the player is moving in which is constantly updated.
How do I store these enemies? Using a vector, but how to go about it?
Let E(0) be the enemy's starting position and P(0) the player's position at that moment, and let s be the enemy's moment speed in space units per time units. Then the enemy's position after t time units is
E(t) = (P(0) - E(0)) / length(P(0) - E(0)) * s * t
Note that P(0) and E(0) are vectors, and s and t are scalars. Also note that (P(0) - E(0)) / length(P(0) - E(0)) is the same as getting the normalized form of (P(0) - E(0)) (a parallel vector with an absolute value [or length] of 1).