Add zooming
This commit is contained in:
parent
56a09f98c5
commit
b02675f4fb
12 changed files with 156 additions and 29 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue