class Transform { position = null; scale = null; rotation = 0; gameObject = null; velocity = null; angularVelocity = 0; get size() { return new vector( this.scale.x * this.gameObject.renderer.sprite.width, this.scale.y * this.gameObject.renderer.sprite.height); } constructor(gameObject, x, y, w, h, r) { this.gameObject = gameObject; this.position = new vector(x, y); this.scale = new vector(w, h); this.rotation = r; this.velocity = new vector(0, 0) } pointTowards(point) { var delta = point.subtract(this.position); this.rotation = delta.toAngle(); } left() { return this.g_dir(0); } right() { return this.g_dir(180); } forward() { return this.g_dir(90); } back() { return this.g_dir(270); } g_dir(offset) { var myAngleInRadians = (this.rotation + offset) * (Math.PI / 180); return angleVector = new vector( -Math.cos(myAngleInRadians), -Math.sin(myAngleInRadians) ); } }