Hello i want to calculate the distance between the centre of Pac-Man and the centre of the treat and If this distance is less than the radius of Pac-Man, we will consider Pac-Man to have “eaten” the treat. When Pac-Man has “eaten” the treat, make the treat reappear in a new random location

To work out the (purple) distance, you need to take the square root of the sum of the squares of the change in the X position (blue) and Y positions (green).

How can you work out the lengths of the blue and green lines?

Compare that with what you’re doing! Do you see the problem?

This Abe Pazos tutorial may be of help. There is a built-in distance function in processing – dist() – that I think will make your task easier.
Do not get distracted by the use of noise() in the tutorial, just focus on the implementation of dist().

Since you don’t show setup() or draw() in your code, I’m not sure what your overall thought process is… but provided you’ve worked that all out…