Movement. Only one side


I would like to ask. I stucked on one moment. Does it posibile to make charactor move only left right up or down. I want make 2D game, where camera will look from top, like on this game


Send please any tutorials, cuz my char can move by diagonally.

Can you show your movement code?