Beispiel #1
0
 /**
  * returns the food object if it in within the given radius on the given position.
  *
  * @param x the given x-position
  * @param y the given y-position
  * @param radius the given radius
  * @return |if(isImpassable(x,y,radius)) | return null; |for(Food food: foodRations){ |
  *     if(Math.pow(Math.pow((food.getX() - x), 2.0) + | Math.pow((food.getY() - y),
  *     2.0),(1.0/2.0)) <= | (Food.getRadius() + radius)){ | return food; | } | } |return null;
  */
 public Food hitAnyFood(double x, double y, double radius) {
   if (isImpassable(x, y, radius)) return null;
   for (Food food : foodRations) {
     if (Math.pow(Math.pow((food.getX() - x), 2.0) + Math.pow((food.getY() - y), 2.0), (1.0 / 2.0))
         <= (Food.getRadius() + radius)) {
       return food;
     }
   }
   return null;
 }