Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class Parser {
/**
* Private method
*
* @private
* @returns Boolean If the index has surpased the length of the text or not.
* @memberof Parser
*/
Expand All @@ -29,6 +30,7 @@ class Parser {
/**
* Private method
*
* @private
* @returns String The next token after the actual index.
* @memberof Parser
*/
Expand Down Expand Up @@ -85,6 +87,7 @@ class Parser {
/**
* Public method
*
* @public
* @returns [CommandExecutor] Parsed text converted into CommandExecutors
* ready to be executed.
* @memberof Parser
Expand Down
23 changes: 21 additions & 2 deletions turtle.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
class Turtle {

/**
* Creates an instance of the Turtle.
* @param {Number} x The home x location.
* @param {Number} y The home y location.
* @param {Number} angle The angle the turtle starts with
* @memberof Turtle
*/
constructor(x, y, angle) {
this.x = x;
this.y = y;
Expand All @@ -11,11 +19,15 @@ class Turtle {
this.strokeColor = 255;
this.strokeWeight = 1;
}

reset() {
this.pen = true;
}

/**
* Move the turtle forward.
* @param {Number} amt The amount the turtle needs to move forwards
*/
forward(amt) {
// Move the turtle
this.x += cos(this.dir) * amt;
Expand All @@ -32,11 +44,18 @@ class Turtle {
this.prevX = this.x;
this.prevY = this.y;
}


/**
* Rotate the turtle.
* @param {Number} angle The amount the turtle needs to rotate
*/
right(angle) {
this.dir += angle;
}

/**
* Sets the location back to the default.
*/
home() {
this.x = this.homeX;
this.y = this.homeY;
Expand Down