Add collectable fuel cans

This commit is contained in:
asraelite 2018-03-07 02:19:06 +00:00
parent 4f8fd6e1af
commit b27bd7bba2
9 changed files with 141 additions and 27 deletions

View file

@ -110,13 +110,13 @@ export default class Body {
this.rvel += r / this.mass;
}
orbit(cel, altitude) {
orbit(cel, altitude, angle = 0) {
this.gravity = true;
let speed = Math.sqrt(G * cel.mass / (altitude + cel.radius));
let [cx, cy] = cel.com;
this.x = cx;
this.y = cy - (altitude + cel.radius);
this.yvel = 0;
this.xvel = speed;
let [dx, dy] = this.rotateVector(0, -(altitude + cel.radius), angle);
[this.xvel, this.yvel] = this.rotateVector(speed, 0, angle);
this.x = cx + dx;
this.y = cy + dy;
}
}