Improve planet collision

This commit is contained in:
asraelite 2018-03-03 22:12:53 +00:00
parent 4959519f39
commit ba803b7ca9
7 changed files with 86 additions and 28 deletions

View file

@ -1,7 +1,7 @@
import {images as assets} from '../assets.mjs';
export default class Module {
constructor(x, y, {
constructor(x, y, ship, {
name = 'Unnamed Module',
type = 'block',
id = 'unknown',
@ -16,6 +16,7 @@ export default class Module {
this.name = name;
this.type = type;
this.mass = mass;
this.ship = ship;
this.id = id;
this.images = assets.modules[this.type][this.id];
// Fuel
@ -32,6 +33,10 @@ export default class Module {
}
}
get com() {
return this.ship.getWorldPoint(...this.localCom);
}
get currentImage() {
if (this.type == 'thruster') {
return this.power > 0 ? this.images.on : this.images.off;
@ -40,7 +45,7 @@ export default class Module {
}
}
get com() {
get localCom() {
return [this.x + 0.5, this.y + 0.5];
}
}