# How to allow character to keep moving after it hits a wall

I am developing an iPhone game. There is a fountain that the user should not be able to walk through. Now, this question is about checking circle-point collision or anything like that. I am checking collision with CGRectIntersectsRect(character1.frame, fountain.frame).

But, here is the problem: If I prevent the person from moving; he will never be able to move. So, I tried combatting this with following:

    if (character.center.y > fountain.center.y && CGRectIntersectsRect(character1.frame, fountain.frame) && g == false) {
g = true;
character1.center = CGPointMake(character1.center.x, character1.center.y-0.1);
}
if (character.center.x > fountain.center.x && CGRectIntersectsRect(character1.frame, fountain.frame)) {
character1.center = CGPointMake(character1.center.x-0.1, character1.center.y);
}
if (character.center.y < fountain.center.y && CGRectIntersectsRect(character1.frame, fountain.frame)) {
character1.center = CGPointMake(character1.center.x, character1.center.y+0.1);
}
if (character.center.x < fountain.center.x && CGRectIntersectsRect(character1.frame, fountain.frame)) {
character1.center = CGPointMake(character1.center.x+0.1, character1.center.y);
}


This should check what side the character1 is intersecting the fountain and then make it so it is not intersecting the fountain by incrementing or decrementing the x or y coordinates of the characters it. But, this still gives weird results. It will move it diagonally across the fountain if keep holding down on the the top side of the fountain and also, it will keep moving it left other wise on the top of the fountain.