Cazka / diepAPI

An API for https://diep.io
MIT License
15 stars 8 forks source link

Add canvas for minimap #25

Open Cazka opened 2 years ago

Cazka commented 2 years ago

I would like to have the ability to draw on the minimap using CanvasAPI.

 MinimapCanvas.getCanvas()

the canvas should have the dimensions of the arena so we dont have to convert the coordinates.

Cazka commented 2 years ago

this function will translate arenaPosition to canvasPosition so that it will be inside the minimap

function toMinimapPosition(vector) {
    const unscale = diepAPI.arena.unscale(vector);

    const minimapPos = diepAPI.Vector.multiply(diepAPI.minimap.minimapDim, unscale);

    return diepAPI.Vector.add(diepAPI.minimap.minimapPos, minimapPos);
}