Prevent diagonally movement - C# [resolved]

Please note the dates on posts, this was from 2016 so nearly 6 years old. Also, please use code-tags when posting code; plain text isn’t useful.