Add zooming

This commit is contained in:
asraelite 2018-03-03 13:29:14 +00:00
parent 56a09f98c5
commit b02675f4fb
12 changed files with 156 additions and 29 deletions

View file

@ -1,10 +1,29 @@
import {images as assets} from '../assets.mjs';
import Body from './body.mjs';
export default class Celestial extends Body {
constructor(x, y, radius, {
density = 1,
mass = (radius ** 2) * density
type = 'rock'
}) {
let mass = (radius ** 2) * density
super(x, y, mass);
this.radius = radius;
this.type = type;
let imageArr = Object.values(assets.celestials[this.type]);
this.image = imageArr[Math.random() * imageArr.length | 0];
}
tick() {
}
get center() {
return [this.x + this.radius / 2, this.y + this.radius / 2];
}
get diameter() {
return this.radius * 2;
}
}