I want to make a 2d soul like game, but the problem is that my character can move left and right, but how to make it so that he can also move up and down
That is still only two dimensions. Just apply the same logic you are using to move it left and right but do it in the Y-axis instead of the X-axis.