It has been a long time ago when I wrote the above code.
I guess x is the center for ball 2, and x is the coordinate for the wall.
If there distance x-x<size2 (assume x is always large than x )
Then the ball collide with the wall, so some code are used to calculated the collision process.
If you just want to change the wall position, you should change value for x and keep the rest the same.
If you just change where you draw the wall, and you did not change the code to check the collosion: x.
The ball will be bounced back at the same place.
It is the same as you draw the wall at the wrong place.