Hi, my end goal is to create a "creature" donated as 'C' on a 30x30 grid in terminal, and "food" as 'F'. The creature and food x and y's are randomly generated. However, I would like to know if any foods are within 5 blocks/units from a creature. So far I have:
main.cpp
I was going to try and make a loop for each creature, return its x and y positions and compare them with each foods x and ys, but I wasnt sure if that was the easiest way.
If all you have is a single collection of all food, then yes, you must go through each food and ask it where it lives so the creature can decide if it is within eating distance.
If you have a grid that is occupied by food and creatures, then that's a different story.
Looking at your code I think you have the first implementation.