Function to get the opposite direction for Dir8.
Rotates the current direction based on the given rotation direction.
Converts the current Dir8 value to the corresponding Dir4 value based on the given rotation direction.