Add basic planet collision
This commit is contained in:
parent
b02675f4fb
commit
09b3df649c
6 changed files with 42 additions and 11 deletions
|
@ -102,10 +102,10 @@ class Perspective {
|
|||
}
|
||||
|
||||
transformCanvas() {
|
||||
let [bx, by, bw, bh] = this.bounds;
|
||||
let tx = -this.x + bw / 2;
|
||||
let ty = -this.y + bh / 2;
|
||||
context.translate(tx, ty);
|
||||
let [,,bw, bh] = this.bounds;
|
||||
let tx = -this.x * this.zoom;
|
||||
let ty = -this.y * this.zoom;
|
||||
context.translate(tx + bw / 2, ty + bh / 2);
|
||||
context.scale(this.zoom, this.zoom);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,8 +3,8 @@ import {images as assets} from '../assets.mjs';
|
|||
import * as world from '../world/index.mjs';
|
||||
|
||||
export function render() {
|
||||
world.ships.forEach(renderShip);
|
||||
world.celestials.forEach(renderCelestial);
|
||||
world.ships.forEach(renderShip);
|
||||
}
|
||||
|
||||
function renderShip(ship) {
|
||||
|
@ -24,5 +24,6 @@ const celestialImages = {
|
|||
}
|
||||
|
||||
function renderCelestial(cel) {
|
||||
context.drawImage(cel.image, cel.x, cel.y, cel.diameter, cel.diameter);
|
||||
context.drawImage(cel.image, cel.x - cel.radius, cel.y - cel.radius,
|
||||
cel.diameter, cel.diameter);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue