Skip to content
This repository was archived by the owner on Apr 11, 2022. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion agar-mini-map.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ window.msgpack = this.msgpack;
enableMultiCells: true,
enablePosition: true,
enableAxes: false,
ViewRectangle: true,
enableCross: true
};

Expand Down Expand Up @@ -162,14 +163,22 @@ window.msgpack = this.msgpack;
miniMapDrawCross(token.x, token.y, token.color);

if (options.enableAxes && -1 != current_cell_ids.indexOf(token.id))
miniMapDrawMiddleCross()
miniMapDrawMiddleCross();

if (options.ViewRectangle && -1 != current_cell_ids.indexOf(token.id))
miniMapDrawRectangle(token.x, token.y, size, token.color, true); // needs to send cell size

if (id_players[id] !== undefined) {
// Draw you party member's crosshair
if (options.enableCross) {
miniMapDrawCross(token.x, token.y, token.color);
}

// Draw you party member's Rectangle
if (options.ViewRectangle) {
miniMapDrawRectangle(token.x, token.y, size, token.color, false); // needs to send cell size
}

ctx.font = size * 2 + 'px Arial';
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
Expand Down Expand Up @@ -207,6 +216,23 @@ window.msgpack = this.msgpack;
ctx.stroke();
}

function miniMapDrawRectangle(x, y, size, color, self) {
var canvas = window.mini_map;
var ctx = canvas.getContext('2d');
x*=canvas.width;
y*=canvas.height;
var rectwidth=0.0364372469635628*size+41.6; // formula that works until 1000 mass
var recthight=0.0202429149797571*size+23.7; // dont know the real formula but this kinda works
ctx.beginPath();
ctx.fillStyle='rgba(200, 200, 200, 0.58)';
if (self)
ctx.fillRect(x-rectwidth/2, y-recthight/2, rectwidth, recthight);
ctx.strokeStyle=color || '#000000';
ctx.strokeRect(x-rectwidth/2, y-recthight/2, rectwidth, recthight);
ctx.closePath();
ctx.stroke();
}

function miniMapCreateToken(id, color) {
var mini_map_token = {
id: id,
Expand Down