fix explosion physics
This commit is contained in:
parent
bf8226481d
commit
8a8a9c8ae3
7 changed files with 54 additions and 24 deletions
|
@ -11,10 +11,12 @@ class Missile extends Body {
|
|||
this.xvel = pos.xvel;
|
||||
this.yvel = pos.yvel;
|
||||
this.r = pos.r;
|
||||
this.xvel += Math.cos(this.r) * 0.2;
|
||||
this.yvel += Math.sin(this.r) * 0.2;
|
||||
|
||||
this.source = source;
|
||||
this.player = source.player;
|
||||
this.fuel = 100;
|
||||
this.fuel = 200;
|
||||
|
||||
this.type = 'missile';
|
||||
this.frame = [[[0, 0], [10, 0], [10, 3], [0, 3]]];
|
||||
|
@ -25,18 +27,19 @@ class Missile extends Body {
|
|||
}
|
||||
|
||||
detonate() {
|
||||
this.world.explosion(this.pos, 10);
|
||||
this.world.explosion(this.center, 10);
|
||||
this.world.removeBody(this);
|
||||
}
|
||||
|
||||
tickType() {
|
||||
let power = 0.005;
|
||||
let power = 0.004;
|
||||
let x = Math.cos(this.b2body.GetAngleRadians()) * power;
|
||||
let y = Math.sin(this.b2body.GetAngleRadians()) * power;
|
||||
this.applyForce(x, y);
|
||||
|
||||
if(this.fuel-- <= 0)
|
||||
if(this.fuel-- <= 0) {
|
||||
this.detonate();
|
||||
}
|
||||
}
|
||||
|
||||
packTypeDelta() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue