Add particles

This commit is contained in:
asraelite 2018-03-04 01:21:34 +00:00
parent dda4a44386
commit 9435e887a4
11 changed files with 1684 additions and 4826 deletions

View file

@ -20,6 +20,10 @@ export default class Body {
return [this.x, this.y];
}
get speed() {
return Math.sqrt(this.xvel ** 2 + this.yvel ** 2);
}
getWorldPoint(lx, ly) {
let [cx, cy] = this.localCom;
let [nx, ny] = this.rotateVector(lx - cx, ly - cy, this.r);
@ -38,6 +42,10 @@ export default class Body {
(y * Math.cos(this.r) - x * Math.sin(this.r))];
}
relativeVector(x, y) {
return this.rotateVector(x, y, this.r);
}
tickMotion() {
this.x += this.xvel;
this.y += this.yvel;