add ship destruction
This commit is contained in:
parent
44ddaacb15
commit
d9e8e217c6
5 changed files with 47 additions and 12 deletions
|
@ -54,6 +54,15 @@ class Body {
|
|||
destruct() {
|
||||
this.mounts.forEach(mount => mount.destruct());
|
||||
this.world.physics.remove(this);
|
||||
|
||||
this.destructType();
|
||||
}
|
||||
|
||||
destructType() {
|
||||
}
|
||||
|
||||
destroy() {
|
||||
this.world.removeBody(this);
|
||||
}
|
||||
|
||||
applyDelta() {
|
||||
|
@ -87,6 +96,14 @@ class Body {
|
|||
contact() {
|
||||
}
|
||||
|
||||
damage(value) {
|
||||
this.health -= value;
|
||||
|
||||
if (this.health <= 0) {
|
||||
this.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
tick() {
|
||||
let pos = this.b2body.GetPosition();
|
||||
let bounds = this.world.bounds;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue