reduce physics cpu usage

This commit is contained in:
Asraelite 2016-03-29 22:35:08 +01:00
parent 8a059b92d5
commit 8ea6c2d937
10 changed files with 2435 additions and 34 deletions

View file

@ -49,7 +49,7 @@ class Body {
}
applyDelta() {
this.world.applyDelta(this.packDelta());
this.world.applyDelta(this.packDelta(), this.pos);
}
applyForce(x, y, center) {

View file

@ -8,8 +8,10 @@ class Grapple extends Projectile {
super(world, pos);
this.r = pos.r;
this.x = pos.x * 32;
this.y = pos.y * 32;
this.x = pos.x;
this.y = pos.y;
this.xvel = pos.xvel;
this.yvel = pos.yvel;
this.xvel += Math.cos(this.r) * 0.25;
this.yvel += Math.sin(this.r) * 0.25;

View file

@ -6,8 +6,8 @@ class Missile extends Projectile {
constructor(world, pos, source) {
super(world);
this.x = pos.x * 32;
this.y = pos.y * 32;
this.x = pos.x;
this.y = pos.y;
this.xvel = pos.xvel;
this.yvel = pos.yvel;
this.r = pos.r;

View file

@ -15,6 +15,7 @@ class Ship extends Body {
// Body data.
this.x = pos.x || 0;
this.y = pos.y || 0;
this.r = player.team == 'b' ? Math.PI : 0;
this.type = 'ship';
this.class = build.ship;
@ -64,6 +65,7 @@ class Ship extends Body {
if (this.grapple) {
this.grapple.retract();
} else {
let s = this.world.scale;
this.launchGrapple(this.inputs.mx, this.inputs.my);
}
}