Input, looks quite good imho
var angle = Math.floor(
Math.atan2(
entity.gridY - this.gridY,
entity.gridX - this.gridX
) * 180 / Math.PI
);
Prettier Output
var angle = Math.floor(
Math.atan2(entity.gridY - this.gridY, entity.gridX - this.gridX) *
180 /
Math.PI
);
Agreed, the input looks better and the output worse. I'm not really sure how to fix it though. Prettier doesn't know how to print the first form and making it know about it would change a bunch of other things. I'll think about it but right now you'll have to live with it i'm afraid :(
function toDegrees(radians) {
return radians * 180 / Math.PI;
}
var dx = entity.gridX - this.gridX;
var dy = entity.gridY - this.gridY;
var angle = Math.floor(toDegrees(Math.atan2(dy, dx)));
I'm going to close this since I don't really know how we can gracefully handle this case :(
Most helpful comment