targetPos is likely to be a Vector as [].pos method returns a vector. So, you’ve been dealing with vectors longer than you realized. I haven’t played with Vector.magnitude() yet, however, so I can’t comment further.
Example 2: The example is correct. diff is a Vector and the angle is in radians. Math.PI * 2 = 360 degrees. Math.PI / 2 = 90 degrees turn, thus the variable name “tangent”. I agree, the title needs work:
Vector.rotate(theta, angle) would probably be better.
Example3: Agreed, that’s java. It is not difficult to translate that, however.
targetPos = self.getNearestEnemy().pos
diff = Vector(5,5)
res = Vector.add(targetPos, diff)
I would note that the odds of folks still having access to getNearestEnemy() at this stage is fairly low. I’d suggest a slightly different example: