diff --git a/engine.js b/engine.js index 38008c8..e4c97e7 100644 --- a/engine.js +++ b/engine.js @@ -19,6 +19,14 @@ class vector { this.x += other_vector.x; this.y += other_vector.y; } + rotate(rad) { + var cos = Math.cos(rad); + var sin = Math.sin(rad); + //this.x = Math.round(10000*(this.x*cos-this.y*sin))/10000; + //this.y = Math.round(10000*(this.x*sin+this.y*cos))/10000; + this.x = this.x*cos-this.y*sin; + this.y = this.x*sin+this.y*cos; + } } class node {