how to create a random 2d vector in js 1

how to create a random 2d vector in js

let vector = p5.Vector.random2D();

Here is what the above code is Doing:
1. We create a new p5.Vector object called vector.
2. We set the vector’s x and y values to random values between 0 and 1.
3. We normalize the vector, which means we set its length to 1.
4. We multiply the vector by a number to set its length.
5. We add the vector to the position of the Mover object.

Similar Posts