Collision between two shape

I was working on an animation on processing. But, I have a question about the code below: So, you can see on the output, the ball is going everywhere on the window. I want to make a barrier for the …