From d389e69b632c74ee935fd6951ce6d319cb1b981b Mon Sep 17 00:00:00 2001 From: tjvr Date: Thu, 17 Mar 2016 21:38:37 +0000 Subject: [PATCH] Fix point towards the current location Fixes #552. --- phosphorus.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/phosphorus.js b/phosphorus.js index 3a144861..7a5d72ed 100644 --- a/phosphorus.js +++ b/phosphorus.js @@ -1653,7 +1653,13 @@ var P = (function() { x = sprite.scratchX; y = sprite.scratchY; } - this.direction = Math.atan2(x - this.scratchX, y - this.scratchY) * 180 / Math.PI; + var dx = x - this.scratchX; + var dy = y - this.scratchY; + if (dx === 0 && dy === 0) { + this.direction = 90; + } else { + this.direction = Math.atan2(dx, dy) * 180 / Math.PI; + } if (this.saying) this.updateBubble(); };