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

28
js/graphics/world.mjs Normal file
View file

@ -0,0 +1,28 @@
import {canvas, context} from './index.mjs';
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);
}
function renderShip(ship) {
context.fillStyle = 'red';
//context.fillRect(ship.x, ship.y, 10, 10);
let size = 1;
context.drawImage(assets.modules.capsule.small, ship.x, ship.y,
size, size);
context.drawImage(assets.modules.fuel.small, ship.x, ship.y + size,
size, size);
context.drawImage(assets.modules.thruster.light, ship.x,
ship.y + size * 2, size, size);
}
const celestialImages = {
green: Object.values(assets.celestials.green)
}
function renderCelestial(cel) {
context.drawImage(cel.image, cel.x, cel.y, cel.diameter, cel.diameter);
}