Add item markers

This commit is contained in:
asraelite 2018-03-07 11:17:09 +00:00
parent b27bd7bba2
commit 3eb74e44aa
8 changed files with 41 additions and 12 deletions

View file

@ -11,6 +11,7 @@ const TAU = consts.TAU;
export let canvas, context, tempCanvas, tempContext;
export let perspective;
export let trace = false;
export let markers = false;
export function init() {
canvas = document.querySelector('#main');
@ -74,6 +75,11 @@ export function toggleTrace() {
return trace;
}
export function toggleMarkers() {
markers = !markers;
return markers;
}
export function changeZoom(delta) {
perspective.zoomDelta(delta);
}

View file

@ -28,6 +28,17 @@ function renderParticle(particle) {
function renderEntity(entity) {
context.save();
context.translate(...entity.com);
if (graphics.perspective.zoom < 2 && graphics.markers) {
context.globalAlpha = 0.7 / graphics.perspective.zoom;
context.beginPath();
context.arc(0, 0, 4, 0, 2 * Math.PI);
context.lineWidth = 1;
context.strokeStyle = '#31911b';
if (entity.type === 'fuelcan')
context.strokeStyle = '#af4021';
context.stroke();
context.globalAlpha = 1;
}
context.rotate(entity.r);
context.drawImage(entity.image, -0.5, -0.5, 1, 1);
context.restore();