Basically I've got a game scren containing lots of square blocks and a ball which is fired from a starting point and needs to bounce off the blocks realistically.
I've got most of it working but I'm having real trouble with corners. Check out the pic and I'll explain.

Firstly as all of the blocks have vertical and horizontal sides I'm not using any fancy maths to rebound a ball off an angled wall. I'm simply saying: If ball hits a vertical wall reverse the X coord; and If ball hits a horizontal wall reverse the Y coord. This works fine for the blocks and for the outer wall surrounding the game area.
I'm also doing a little extra thing to make it better and this is where my problems come in...
Look at the top three pictures. Say a ball is moving at an angle like in the first one, you can see how it should rebound. I do this by:
1) moving the ball to it's new position based on it's X and Y speeds.
2) checking the ball against the vertical line with a "circle and line intersect function" which returns True if there is a collision.
3) if there is a collision this means that the balls new coordinates have placed it slightly in the wall. Well sure I can reverse the X Speed but I can't leave the ball at those coordinates because it's in the wall!
4) So what I do is I find out how much it has gone into the wall by looking at the ball centre + ball radius (it's far right edge) and seeing how far into the wall it is (this distance is depicted by the red line in the second picture).
5) Then I set the ball's new X coordinate to be that calculated distance BACK from the wall (see 3rd picture where red line is that distance applied). This means that it still travelled the SAME distance. Get it? I hope so as that's where my problems come in...
The same technique is applied for hitting a horizontal wall (see pic 4)
Anyway, this works fine and is nice and realistic UNTIL I get to corners. Why? I'll explain...
Look at the bottom left pic. If the collision is detected and the ball is well into the corner, that's fine because my red lines (distance from wall edge to edge of ball which has a blue dot on) can be subtracted from the ball x/y coords and the ball is in a good position after the bounce.
Now look at the bottom right picture. A collision has occured but the ball is not very far into the corner. Note how neither the bottom or the right edge have actually touched the corner yet. Instead the ball has collided at about 4 and 5 o'clock roughly. So if I use my code before which gets the (vert and horiz) distance from the edge of the ball to the wall and uses it to reset the ball coords, the ball will be moved back TOO FAR. Really I need to calculate the SMALLER distances shown by the GREEN lines and use that to move the ball back from the wall. This will be accurate.
But how can I do that without loads of crazy vector maths, dot products, angles etc? I.e. simply. Maybe it's not possible OR maybe there's a different approach that will yield the same result that is not a "bodge" or an "ignore" if you see what I mean.
Basically I'm thinking that I need to know the coordinates of those 4 and 5 o'clock collisions, then I can work out the green distances. Perhaps I need to modify the cirlce/line insect code to return those coords...but that won't be easy with my current maths skills because I don't even understand how the circle/line intersect code works!
I'd really appreciate any feedback on this as I'm like a zombie today due to lots of late nights and early starts and my brain has ceased to function and I'm not seeing clearly any more, thanks! :-)
I've got most of it working but I'm having real trouble with corners. Check out the pic and I'll explain.

Firstly as all of the blocks have vertical and horizontal sides I'm not using any fancy maths to rebound a ball off an angled wall. I'm simply saying: If ball hits a vertical wall reverse the X coord; and If ball hits a horizontal wall reverse the Y coord. This works fine for the blocks and for the outer wall surrounding the game area.
I'm also doing a little extra thing to make it better and this is where my problems come in...
Look at the top three pictures. Say a ball is moving at an angle like in the first one, you can see how it should rebound. I do this by:
1) moving the ball to it's new position based on it's X and Y speeds.
2) checking the ball against the vertical line with a "circle and line intersect function" which returns True if there is a collision.
3) if there is a collision this means that the balls new coordinates have placed it slightly in the wall. Well sure I can reverse the X Speed but I can't leave the ball at those coordinates because it's in the wall!
4) So what I do is I find out how much it has gone into the wall by looking at the ball centre + ball radius (it's far right edge) and seeing how far into the wall it is (this distance is depicted by the red line in the second picture).
5) Then I set the ball's new X coordinate to be that calculated distance BACK from the wall (see 3rd picture where red line is that distance applied). This means that it still travelled the SAME distance. Get it? I hope so as that's where my problems come in...
The same technique is applied for hitting a horizontal wall (see pic 4)
Anyway, this works fine and is nice and realistic UNTIL I get to corners. Why? I'll explain...
Look at the bottom left pic. If the collision is detected and the ball is well into the corner, that's fine because my red lines (distance from wall edge to edge of ball which has a blue dot on) can be subtracted from the ball x/y coords and the ball is in a good position after the bounce.
Now look at the bottom right picture. A collision has occured but the ball is not very far into the corner. Note how neither the bottom or the right edge have actually touched the corner yet. Instead the ball has collided at about 4 and 5 o'clock roughly. So if I use my code before which gets the (vert and horiz) distance from the edge of the ball to the wall and uses it to reset the ball coords, the ball will be moved back TOO FAR. Really I need to calculate the SMALLER distances shown by the GREEN lines and use that to move the ball back from the wall. This will be accurate.
But how can I do that without loads of crazy vector maths, dot products, angles etc? I.e. simply. Maybe it's not possible OR maybe there's a different approach that will yield the same result that is not a "bodge" or an "ignore" if you see what I mean.
Basically I'm thinking that I need to know the coordinates of those 4 and 5 o'clock collisions, then I can work out the green distances. Perhaps I need to modify the cirlce/line insect code to return those coords...but that won't be easy with my current maths skills because I don't even understand how the circle/line intersect code works!
I'd really appreciate any feedback on this as I'm like a zombie today due to lots of late nights and early starts and my brain has ceased to function and I'm not seeing clearly any more, thanks! :-)