Motion towards the northwest

Listing 4 handles a value of dir equal to 0.

This means that the current direction of motion for the ball is toward the northwest.

Depending on where the ball began its journey towards the northwest: