In the physical world, things don't just "be" at a location; they are constantly moving toward a location with a specific speed. To handle this in code, we use Vectors.
The Core Concept
A 2D vector is just a pair of numbers: (x, y). But it represents two things at once:
1. Direction: Which way is it pointing?
2. Magnitude: How long (fast) is it?
In games, we use vectors for Position, Velocity (speed + direction), and Acceleration (change in velocity).
// Each frame:
velocity.x += acceleration.x;
velocity.y += acceleration.y;
position.x += velocity.x;
position.y += velocity.y;
Why It Matters
Using vectors allows you to create emergent behavior. By simply adjusting the Acceleration toward a target, you get a ball that feels like it has weight and momentum. If you simply set position = mouse, the movement would look robotic and lifeless.
The Takeaway
Vectors are the grammar of game physics. Master them, and you can build everything from gravity to homing missiles.