You dont state what the arguments are in RectsOverlap. The variables YP, AP and GP arent mentioned in your code. Try replacing this line:
If RectsOverlap(XF,YF,HF,WF,XP,YP,AP,GP)With this one:
If RectsOverlap(XF,YF,HF,WF,XW,YW,WW,HW)If I've read your code correctly, you're checking to see if there is an overlap between the food item and the current wall in the loop, but you dont check the wall variables.