mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-23 23:58:02 -05:00
Update vector.coffee
Make Vector do the right thing if you forget new,
This commit is contained in:
parent
2d89de8183
commit
0a06022b8f
1 changed files with 3 additions and 1 deletions
|
@ -10,7 +10,9 @@ class Vector
|
|||
isVector: true
|
||||
apiProperties: ['x', 'y', 'z', 'magnitude', 'heading', 'distance', 'dot', 'equals', 'copy', 'distanceSquared', 'rotate']
|
||||
|
||||
constructor: (@x=0, @y=0, @z=0) ->
|
||||
constructor: (x=0, y=0, z=0) ->
|
||||
return new Vector(x,y,z) unless this instanceof Vector
|
||||
[@x, @y, @z] = [x,y,z]
|
||||
|
||||
copy: ->
|
||||
new Vector(@x, @y, @z)
|
||||
|
|
Loading…
Reference in a new issue