diff --git a/src/test.coffee b/src/test.coffee index 5eadbf8..4ff216c 100644 --- a/src/test.coffee +++ b/src/test.coffee @@ -8,7 +8,7 @@ z=new Vector2(v) console.log(z) -###test add +#test add v.add(1) console.log v.getX(),v.getY() v.add(v) @@ -21,4 +21,4 @@ console.log v.getX(),v.getY() n = new WorldObject() console.log(n) -### \ No newline at end of file + diff --git a/src/vector.coffee b/src/vector.coffee index 988529a..7baafe8 100644 --- a/src/vector.coffee +++ b/src/vector.coffee @@ -1,7 +1,7 @@ class Vector2 constructor:(@x=0,@y=0) -> - if @x instanceof Vector2 - vec=@x + if x instanceof Vector2 + vec=x @x=vec.x @y=vec.y @@ -88,7 +88,7 @@ class Vector3 return this.z # add ascalar add: (vec) -> - if typeof vec is "Vector2" + if vec instanceof Vector3 this.x += vec.getX() this.y += vec.getY() else