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