From 9dc916f9adee3632b59e2d0b09f4a2690164abdd Mon Sep 17 00:00:00 2001 From: TheTastefulToastie Date: Thu, 22 Nov 2018 20:30:28 +0000 Subject: [PATCH] Fix radians command. Commit 5502ec2397cfafb39ad9a88896f735037fccfd46 to fix issue #68 broke the `radians` command. Simply stopped using `Math.sin()` and `Math.cos()` and instead used the p5.js `sin()` and `cos()` global functions which take into account the p5.js `angleMode()`. --- turtle.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/turtle.js b/turtle.js index 849e5e9..dfbc84a 100644 --- a/turtle.js +++ b/turtle.js @@ -18,8 +18,8 @@ class Turtle { forward(amt) { // Move the turtle - this.x += Math.cos(this.dir * Math.PI / 180) * amt; - this.y += Math.sin(this.dir * Math.PI / 180) * amt; + this.x += cos(this.dir) * amt; + this.y += sin(this.dir) * amt; // If the pen is down we should draw a line from the previous position to the new position if (this.pen) {