Velocity

The velocity blocks (velocityX and velocityY), tell sprites how fast to move in a particular direction, just as the counter pattern did before. By hiding the counter pattern code inside a block, you can build even more complex programs.

Movement with Velocity

The code that uses the counter pattern is on the left, and the code that uses the velocity blocks is on the right.

With velocityX and velocityY, you can set the sprites' velocities when you first create them, but both programs will make the sprites move as in the picture below.

Found a bug in the documentation? Let us know at documentation@code.org