Well, if you have rectangle walls, you can check if the character collides each side of the rectangle, for example if the character collides the top side of the rectangle you can set the vertical speed to 0 or you can use a while loop like this:
while(player collide rectangle top){
player.y++;
}
Remember that this only works for rectangles.
I hope this helps you :D