Skip to main content
simplify stuff
Source Link
sam hocevar
  • 24k
  • 2
  • 65
  • 95

You want the absolute value of the angle difference to be smaller than area or greater than 360-area.

Based on your code, I believe this should work:

var isfacing = function (obj1,obj2,area) {
   var toface = direction(obj1.pos,obj2.pos);
   var difference = abs(toface - ob1.angle);
   ifreturn (difference <= area || difference >= 360 - area) {
       return true;
   }
   return false;;
}

Edit: my first attempt was totally buggy. Sorry.

You want the absolute value of the angle difference to be smaller than area or greater than 360-area.

Based on your code, I believe this should work:

var isfacing = function (obj1,obj2,area) {
   var toface = direction(obj1.pos,obj2.pos);
   var difference = abs(toface - ob1.angle);
   if (difference <= area || difference >= 360 - area) {
       return true;
   }
   return false;
}

Edit: my first attempt was totally buggy. Sorry.

You want the absolute value of the angle difference to be smaller than area or greater than 360-area.

Based on your code, I believe this should work:

var isfacing = function (obj1,obj2,area) {
   var toface = direction(obj1.pos,obj2.pos);
   var difference = abs(toface - ob1.angle);
   return (difference <= area || difference >= 360 - area);
}

Edit: my first attempt was totally buggy. Sorry.

Source Link
sam hocevar
  • 24k
  • 2
  • 65
  • 95

You want the absolute value of the angle difference to be smaller than area or greater than 360-area.

Based on your code, I believe this should work:

var isfacing = function (obj1,obj2,area) {
   var toface = direction(obj1.pos,obj2.pos);
   var difference = abs(toface - ob1.angle);
   if (difference <= area || difference >= 360 - area) {
       return true;
   }
   return false;
}

Edit: my first attempt was totally buggy. Sorry.