Round a direction vector to an 8-way compass

Round a direction vector to an 8-way compass.
Modern game controllers can point in a wide range of directions. Game designers sometimes want to convert the joystick direction to get 8-directional movement. A typical solution offered is to compute the angle, round it up and then compute back the direction vector. double angle = atan2(y, x); angle = (int(round(4 * angle / PI + … Continue reading Round a direction vector to an 8-way compass

Read in full here:

This thread was posted by one of our members via one of our news source trackers.