Skip to content

Instantly share code, notes, and snippets.

@PyroLagus
Created February 12, 2017 04:26
Show Gist options
  • Select an option

  • Save PyroLagus/150e69ff775e22d101f3a4328c5950ad to your computer and use it in GitHub Desktop.

Select an option

Save PyroLagus/150e69ff775e22d101f3a4328c5950ad to your computer and use it in GitHub Desktop.

Revisions

  1. PyroLagus created this gist Feb 12, 2017.
    31 changes: 31 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    function Point(x, y) {
    this.x = x;
    this.y = y;
    }

    Point.prototype = {
    west: function() {
    return new this(this.x-1, this.y);
    },
    east: function() {
    return new this(this.x+1, this.y);
    },
    north: function() {
    return new this(this.x, this.y-1);
    },
    south: function() {
    return new this(this.x, this.y+1);
    },
    moveWest: function() {
    this.x--;
    },
    moveEast: function() {
    this.x++;
    },
    moveNorth: function() {
    this.y--;
    },
    moveSouth: function() {
    this.y++;
    }
    };