Better solution for mapPos?

Personnaly, I’ve used the following code

mapPos = Vector2Negate(knight.getWorldPos());

instead of

mapPos = Vector2Scale(knight.getWorldPos(), -1.f);

I find it clearer.
But perhaps the solution in the courses is better. Tell me if it’s the case.

Both examples of code achieve the same thing, and from a performance standpoint one isn’t inherently faster than the other by any significant margin. So neither of them is exactly “better” than the other.

From a learning standpoint and because when you’re first learning, you may want to learn how something works. Vector2Negate hides too much away from first-time coders, so the Vector2Scale method is more suitable for this purpose.

1 Like

Privacy & Terms