Tiny Tanks!

shows a cute tank in the corner of your screen, x for menu

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey, Greasemonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

You will need to install an extension such as Tampermonkey to install this script.

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name        Tiny Tanks!
// @namespace    hi
// @version      3.0
// @description  shows a cute tank in the corner of your screen, x for menu
// @author       el bismüt (updated by CleverYeti)
// @match        *diep.io*
// @license      none
// @grant        GM_addStyle
// ==/UserScript==

function tinyTanks() {
    if (!(score >= 0)) {
        coins += Math.round(killCount * killCount * 3 / 4 + round);
        round = 0;
        killCount = 0;
    }
    let width = 15;
    let rotation = 0;

    function barrel(x, y, r, e, length) {
        let relW = e * width;
        let rot = r;
        ctx.strokeStyle = "#757575";
        ctx.fillStyle = '#999999';
        ctx.lineWidth = 2 * width / 7;
        ctx.beginPath();
        ctx.moveTo(x - relW * Math.sin(rot), y - relW * Math.cos(rot));
        ctx.lineTo(x - length * width * Math.cos(rot) - relW * Math.sin(rot), y - relW * Math.cos(rot) + length * width * Math.sin(rot));
        ctx.lineTo(x - length * width * Math.cos(rot) + relW * Math.sin(rot), y + relW * Math.cos(rot) + length * width * Math.sin(rot));
        ctx.lineTo(x + relW * Math.sin(rot), y + relW* Math.cos(rot));
        ctx.lineTo(x - relW * Math.sin(rot), y - relW * Math.cos(rot));
        ctx.closePath();
        ctx.stroke();
        ctx.fill();
    }
    function trapperTurret(x, y, r, e, n) {
        let relW = n / 4 * width;
        let rot = r;
        barrel(x, y, r, e, n);
        ctx.fillStyle = '#999999';
        ctx.beginPath();
        ctx.moveTo(x - relW * Math.sin(rot), y - relW * Math.cos(rot));
        ctx.lineTo(x - n * width * Math.cos(rot) - relW * Math.sin(rot), y - relW * Math.cos(rot) + n * width * Math.sin(rot));
        ctx.lineTo(x - n * width * Math.cos(rot) + relW * Math.sin(rot), y + relW * Math.cos(rot) + n * width * Math.sin(rot));
        ctx.lineTo(x + relW * Math.sin(rot), y + relW* Math.cos(rot));
        ctx.lineTo(x - relW * Math.sin(rot), y - relW * Math.cos(rot));
        ctx.closePath();
        ctx.fill();

        ctx.strokeStyle = "#757575";
        ctx.fillStyle = "#999999";
        ctx.lineWidth = 2 * width / 7;
        ctx.beginPath();
        ctx.moveTo(x - n * width * Math.cos(rot) - relW * Math.sin(rot), y - relW * Math.cos(rot) + n * width * Math.sin(rot));
        ctx.lineTo(x - n * width * Math.cos(rot) + relW * Math.sin(rot), y + relW * Math.cos(rot) + n * width * Math.sin(rot));
        ctx.lineTo(x - (e + 11 / 8) * width * Math.cos(rot) + e * 5 * width / 3 * Math.sin(rot), y + e * 5 * width / 3 * Math.cos(rot) + (e + 11 / 8) * width * Math.sin(rot));
        ctx.lineTo(x - (e + 11 / 8) * width * Math.cos(rot) - e * 5 * width / 3 * Math.sin(rot), y - e * 5 * width / 3 * Math.cos(rot) + (e + 11 / 8) * width * Math.sin(rot));
        ctx.lineTo(x - n * width * Math.cos(rot) - relW * Math.sin(rot), y - relW * Math.cos(rot) + n * width * Math.sin(rot));
        ctx.closePath();
        ctx.stroke();
        ctx.fill();
    }
    function olTurret(x, y, r) {
        let rot = r;
        ctx.strokeStyle = "#757575";
        ctx.fillStyle = '#999999';
        ctx.lineWidth = 2 * width / 7;
        ctx.beginPath();
        ctx.moveTo(x - width / 2 * Math.sin(rot), y - width / 2 * Math.cos(rot));
        ctx.lineTo(x - 3 * width / 2 * Math.cos(rot) - 3 * width / 4 * Math.sin(rot), y - 3 * width / 4 * Math.cos(rot) + 3 * width / 2 * Math.sin(rot));
        ctx.lineTo(x - 3 * width / 2 * Math.cos(rot) + 3 * width / 4 * Math.sin(rot), y + 3 * width / 4 * Math.cos(rot) + 3 * width / 2 * Math.sin(rot));
        ctx.lineTo(x + width / 2 * Math.sin(rot), y + width / 2 * Math.cos(rot));
        ctx.lineTo(x - width / 2 * Math.sin(rot), y - width / 2 * Math.cos(rot));
        ctx.closePath();
        ctx.stroke();
        ctx.fill();
    }
    function overlord(X, Y) {
        let rotation = -Math.atan((mouseY - Y) / (mouseX - X));
        if (mouseX - X >= 0) {rotation = (Math.PI + rotation) % (2 * Math.PI)}
        olTurret(X, Y, 0 + rotation);
        olTurret(X, Y, Math.PI / 2 + rotation);
        olTurret(X, Y, Math.PI + rotation);
        olTurret(X, Y, 3 * Math.PI / 2 + rotation);
        circleTank(X, Y)
    }
    function quadTank(X, Y) {
        let rotation = -Math.atan((mouseY - Y) / (mouseX - X));
        if (mouseX - X >= 0) {rotation = (Math.PI + rotation) % (2 * Math.PI)}
        barrel(X, Y, 0 + rotation, 3/8, 2);
        barrel(X, Y, Math.PI / 2 + rotation, 3/8, 2);
        barrel(X, Y, Math.PI + rotation, 3/8, 2);
        barrel(X, Y, 3 * Math.PI / 2 + rotation, 3/8, 2);
        circleTank(X, Y)
    }
    function triTrapper(X, Y) {
        let rotation = -Math.atan((mouseY - Y) / (mouseX - X));
        if (mouseX - X >= 0) {rotation = (Math.PI + rotation) % (2 * Math.PI)}
        trapperTurret(X, Y, 0 + rotation, 3/8, 3/2);
        trapperTurret(X, Y, 2 * Math.PI / 3 + rotation, 3/8, 3/2);
        trapperTurret(X, Y, 4 * Math.PI / 3 + rotation, 3/8, 3/2);
        circleTank(X, Y)
    }
    function megaTrapper(X, Y) {
        let rotation = -Math.atan((mouseY - Y) / (mouseX - X));
        if (mouseX - X >= 0) {rotation = (Math.PI + rotation) % (2 * Math.PI)}
        trapperTurret(X, Y, 0 + rotation, 1/2, 3/2);
        circleTank(X, Y)
    }
    function spreadShot(X, Y) {
        let rotation = -Math.atan((mouseY - Y) / (mouseX - X));
        if (mouseX - X >= 0) {rotation = (Math.PI + rotation) % (2 * Math.PI)}
        barrel(X, Y, rotation - 5 * Math.PI / 12, 3/16, 10/8);
        barrel(X, Y, rotation + 5 * Math.PI / 12, 3/16, 10/8);
        barrel(X, Y, rotation - 4 * Math.PI / 12, 3/16, 11/8);
        barrel(X, Y, rotation + 4 * Math.PI / 12, 3/16, 11/8);
        barrel(X, Y, rotation - 3 * Math.PI / 12, 3/16, 12/8);
        barrel(X, Y, rotation + 3 * Math.PI / 12, 3/16, 12/8);
        barrel(X, Y, rotation - 2 * Math.PI / 12, 3/16, 13/8);
        barrel(X, Y, rotation + 2 * Math.PI / 12, 3/16, 13/8);
        barrel(X, Y, rotation - 1 * Math.PI / 12, 3/16, 14/8);
        barrel(X, Y, rotation + 1 * Math.PI / 12, 3/16, 14/8);
        barrel(X, Y, rotation, 3/8, 15/8);
        circleTank(X, Y)
    }
    function pentaShot(X, Y) {
        let rotation = -Math.atan((mouseY - Y) / (mouseX - X));
        if (mouseX - X >= 0) {rotation = (Math.PI + rotation) % (2 * Math.PI)}
        barrel(X, Y, rotation - Math.PI / 4, 3/8, 3/2);
        barrel(X, Y, rotation + Math.PI / 4, 3/8, 3/2);
        barrel(X, Y, rotation - Math.PI / 8, 3/8, 15/8);
        barrel(X, Y, rotation + Math.PI / 8, 3/8, 15/8);
        barrel(X, Y, rotation, 3/8, 9/4);
        circleTank(X, Y)
    }
    function booster(X, Y) {
        let rotation = -Math.atan((mouseY - Y) / (mouseX - X));
        if (mouseX - X >= 0) {rotation = (Math.PI + rotation) % (2 * Math.PI)}
        barrel(X, Y, rotation, 3/8, 15/8);
        barrel(X, Y, rotation - 3 * Math.PI / 4, 3/8, 5/4);
        barrel(X, Y, rotation + 3 * Math.PI / 4, 3/8, 5/4);
        barrel(X, Y, rotation - 5 * Math.PI / 6, 3/8, 3/2);
        barrel(X, Y, rotation + 5 * Math.PI / 6, 3/8, 3/2);
        circleTank(X, Y)
    }
    function hybrid(X, Y) {
        let rotation = -Math.atan((mouseY - Y) / (mouseX - X));
        if (mouseX - X >= 0) {rotation = (Math.PI + rotation) % (2 * Math.PI)}
        olTurret(X, Y, Math.PI + rotation);
        barrel(X, Y, rotation, 3/4, 2);
        circleTank(X, Y)
    }
    function annihilator(X, Y) {
        let rotation = -Math.atan((mouseY - Y) / (mouseX - X));
        if (mouseX - X >= 0) {rotation = (Math.PI + rotation) % (2 * Math.PI)}
        barrel(X, Y, rotation, 1, 2);
        circleTank(X, Y)
    }
    function octoTank(X, Y) {
        let rotation = -Math.atan((mouseY - Y) / (mouseX - X));
        if (mouseX - X >= 0) {rotation = (Math.PI + rotation) % (2 * Math.PI)}
        for (let i = 0; i < 8; i++) {
        barrel(X, Y, i * Math.PI / 4 + rotation, 3/8, 2);
        }
        circleTank(X, Y)
    }
    function manager(X, Y) {
        let rotation = -Math.atan((mouseY - Y) / (mouseX - X));
        if (mouseX - X >= 0) {rotation = (Math.PI + rotation) % (2 * Math.PI)}
        olTurret(X, Y, 0 + rotation);
        circleTank(X, Y)
    }
    function factory(X, Y) {
        let rotation = -Math.atan((mouseY - Y) / (mouseX - X));
        if (mouseX - X >= 0) {rotation = (Math.PI + rotation) % (2 * Math.PI)}
        olTurret(X, Y, 0 + rotation);
        squareTank(X, Y)
    }
    function necromancer(X, Y) {
        let rotation = -Math.atan((mouseY - Y) / (mouseX - X));
        if (mouseX - X >= 0) {rotation = (Math.PI + rotation) % (2 * Math.PI)}
        olTurret(X, Y, Math.PI / 2 + rotation);
        olTurret(X, Y, 3 * Math.PI / 2 + rotation);
        squareTank(X, Y)
    }
    function predator(X, Y) {
        let rotation = -Math.atan((mouseY - Y) / (mouseX - X));
        if (mouseX - X >= 0) {rotation = (Math.PI + rotation) % (2 * Math.PI)}
        barrel(X, Y, rotation, 1/2, 5/2);
        barrel(X, Y, rotation, 5/8, 17/8);
        barrel(X, Y, rotation, 3/4, 7/4);
        circleTank(X, Y)
    }
    function rocketeer(X, Y) {
        let rot = -Math.atan((mouseY - Y) / (mouseX - X));
        if (mouseX - X >= 0) {rot = (Math.PI + rot) % (2 * Math.PI)}
        let x = X, y = Y;
        ctx.strokeStyle = "#757575";
        ctx.fillStyle = '#999999';
        ctx.lineWidth = 2 * width / 7;
        ctx.beginPath();
        ctx.moveTo(x - width / 3 * Math.sin(rot), y - width / 3 * Math.cos(rot));
        ctx.lineTo(x - 2 * width * Math.cos(rot) - 11 * width / 21 * Math.sin(rot), y - 11 * width / 21 * Math.cos(rot) + 2 * width * Math.sin(rot));
        ctx.lineTo(x - 2 * width * Math.cos(rot) + 11 * width / 21 * Math.sin(rot), y + 11 * width / 21 * Math.cos(rot) + 2 * width * Math.sin(rot));
        ctx.lineTo(x + width / 3 * Math.sin(rot), y + width / 3 * Math.cos(rot));
        ctx.lineTo(x - width / 3 * Math.sin(rot), y - width / 3 * Math.cos(rot));
        ctx.closePath();
        ctx.stroke();
        ctx.fill();
        ctx.strokeStyle = "#757575";
        ctx.fillStyle = '#999999';
        ctx.lineWidth = 2 * width / 7;
        ctx.beginPath();
        ctx.moveTo(x - width * Math.sin(rot), y - 0.96 * width * Math.cos(rot));
        ctx.lineTo(x - 7 * width / 4 * Math.cos(rot) - width / 2 * Math.sin(rot), y - width / 2 * Math.cos(rot) + 7 * width / 4 * Math.sin(rot));
        ctx.lineTo(x - 7 * width / 4 * Math.cos(rot) + width / 2 * Math.sin(rot), y + width / 2 * Math.cos(rot) + 7 * width / 4 * Math.sin(rot));
        ctx.lineTo(x + width * Math.sin(rot), y + 0.96 * width * Math.cos(rot));
        ctx.lineTo(x - width * Math.sin(rot), y - 0.96 * width * Math.cos(rot));
        ctx.closePath();
        ctx.stroke();
        ctx.fill();
        circleTank(X, Y)
    }
    function landmine(X, Y) {
        let x = X, y = Y, rot = -autorotation;
        ctx.strokeStyle = "#4F4F4F"+ hex;
        ctx.lineWidth = 2 * width / 7;
        ctx.beginPath();
        ctx.moveTo(X + 0.9 * width * Math.cos(rot) + 0.9 * width * Math.sin(rot), Y - 0.9 * width * Math.sin(rot) + 0.9 * width * Math.cos(rot));
        for (let i = 0; i < 6; i++) {
        ctx.lineTo(X + 0.9 * width * Math.cos(rot + i * Math.PI / 3) + 0.9 * width * Math.sin(rot + i * Math.PI / 3), Y - 0.9 * width * Math.sin(rot + i * Math.PI / 3) + 0.9 * width * Math.cos(rot + i * Math.PI / 3));
        }
        ctx.closePath();
        ctx.stroke();
        ctx.strokeStyle = "#4F4F4F"+ hex;
        ctx.lineWidth = 2 * width / 7;
        ctx.beginPath();
        ctx.moveTo(X + 0.9 * width * Math.cos(2 * rot) + 0.9 * width * Math.sin(2 * rot), Y - 0.9 * width * Math.sin(2 * rot) + 0.9 * width * Math.cos(2 * rot));
        for (let i = 0; i < 6; i++) {
        ctx.lineTo(X + 0.9 * width * Math.cos(2 * rot + i * Math.PI / 3) + 0.9 * width * Math.sin(2 * rot + i * Math.PI / 3), Y - 0.9 * width * Math.sin(2 * rot + i * Math.PI / 3) + 0.9 * width * Math.cos(2 * rot + i * Math.PI / 3));
        }
        ctx.closePath();
        ctx.stroke();
        invisCircleTank(X, Y);
    }
    function fighter(X, Y) {
        let rotation = -Math.atan((mouseY - Y) / (mouseX - X));
        if (mouseX - X >= 0) {rotation = (Math.PI + rotation) % (2 * Math.PI)}
        barrel(X, Y, rotation, 3/8, 15/8);
        barrel(X, Y, rotation - 2 * Math.PI / 4, 3/8, 3/2);
        barrel(X, Y, rotation + 2 * Math.PI / 4, 3/8, 3/2);
        barrel(X, Y, rotation - 5 * Math.PI / 6, 3/8, 3/2);
        barrel(X, Y, rotation + 5 * Math.PI / 6, 3/8, 3/2);
        circleTank(X, Y)
    }
    function triplet(X, Y) {
        let rotation = -Math.atan((mouseY - Y) / (mouseX - X));
        if (mouseX - X >= 0) {rotation = (Math.PI + rotation) % (2 * Math.PI)}
        barrel(X, Y, rotation, 15/16, 7/4);
        barrel(X, Y, rotation, 3/8, 2);
        circleTank(X, Y);
    }
    function tripleTwin(X, Y) {
        let rotation = Math.atan((mouseY - Y) / (mouseX - X)) + Math.PI;
        if (mouseX - X >= 0) {rotation = (Math.PI + rotation) % (2 * Math.PI)}
        ctx.strokeStyle = "#757575";
        ctx.lineWidth = 2 * width / 9;
        ctx.fillStyle = '#999999'
        for(let i = 0; i < 3; i++) {
            let rot = rotation + 2 * Math.PI / 3 * i;
            ctx.beginPath();
            ctx.moveTo(X + 7 / 8 * width * Math.sin(rot), Y - 7 / 8 * width * Math.cos(rot));
            ctx.lineTo(X + 7 / 8 * width * Math.sin(rot) + 2 * width * Math.cos(rot), Y - 7 / 8 * width * Math.cos(rot) + 2 * width * Math.sin(rot));
            ctx.lineTo(X + 1 / 8 * width * Math.sin(rot) + 2 * width * Math.cos(rot), Y - 1 / 8 * width * Math.cos(rot) + 2 * width * Math.sin(rot));
            ctx.lineTo(X + 1 / 8 * width * Math.sin(rot), Y - 1 / 8 * width * Math.cos(rot));
            ctx.stroke();
            ctx.fill();
            ctx.beginPath();
            ctx.moveTo(X - 7 / 8 * width * Math.sin(rot), Y + 7 / 8 * width * Math.cos(rot));
            ctx.lineTo(X - 7 / 8 * width * Math.sin(rot) + 2 * width * Math.cos(rot), Y + 7 / 8 * width * Math.cos(rot) + 2 * width * Math.sin(rot));
            ctx.lineTo(X - 1 / 8 * width * Math.sin(rot) + 2 * width * Math.cos(rot), Y + 1 / 8 * width * Math.cos(rot) + 2 * width * Math.sin(rot));
            ctx.lineTo(X - 1 / 8 * width * Math.sin(rot), Y + 1 / 8 * width * Math.cos(rot));
            ctx.stroke();
            ctx.fill();
        }
        circleTank(X, Y);
    }
    function overTrapper(X, Y) {
        let rotation = -Math.atan((mouseY - Y) / (mouseX - X));
        if (mouseX - X >= 0) {rotation = (Math.PI + rotation) % (2 * Math.PI)}
        trapperTurret(X, Y, 0 + rotation, 3/8, 3/2);
        olTurret(X, Y, rotation + 2 * Math.PI / 3);
        olTurret(X, Y, rotation + 4 * Math.PI / 3);
        circleTank(X, Y);
    }
    function battleship(X, Y) {
        let rotation = Math.atan((mouseY - Y) / (mouseX - X)) - Math.PI / 2;
        if (mouseX - X >= 0) {rotation = (Math.PI + rotation) % (2 * Math.PI)}
        ctx.strokeStyle = "#757575";
        ctx.fillStyle = '#999999'
        ctx.lineWidth = 2 * width / 9;
        for(let i = 0; i < 2; i++) {
            let rot = rotation + Math.PI * i;
            ctx.beginPath();
            ctx.moveTo(X + width * Math.sin(rot), Y - width * Math.cos(rot));
            ctx.lineTo(X + 5/8 * width * Math.sin(rot) + 3/2 * width * Math.cos(rot), Y - 5/8 * width * Math.cos(rot) + 3/2 * width * Math.sin(rot));
            ctx.lineTo(X + 1/8 * width * Math.sin(rot) + 3/2 * width * Math.cos(rot), Y - 1/8 * width * Math.cos(rot) + 3/2 * width * Math.sin(rot));
            ctx.lineTo(X - 1/4 * width * Math.sin(rot), Y + 1/4 * width * Math.cos(rot));
            ctx.stroke();
            ctx.fill();
            ctx.beginPath();
            ctx.moveTo(X - width * Math.sin(rot), Y + width * Math.cos(rot));
            ctx.lineTo(X - 5/8 * width * Math.sin(rot) + 3/2 * width * Math.cos(rot), Y + 5/8 * width * Math.cos(rot) + 3/2 * width * Math.sin(rot));
            ctx.lineTo(X - 1/8 * width * Math.sin(rot) + 3/2 * width * Math.cos(rot), Y + 1/8 * width * Math.cos(rot) + 3/2 * width * Math.sin(rot));
            ctx.lineTo(X + 1/4 * width * Math.sin(rot), Y - 1/4 * width * Math.cos(rot));
            ctx.stroke();
            ctx.fill();
        }
        circleTank(X, Y);
    }
    function streamliner(X, Y) {
        let rotation = - Math.atan((mouseY - Y) / (mouseX - X));
        if (mouseX - X >= 0) {rotation = (Math.PI + rotation) % (2 * Math.PI)}
        for (let e = 5; e > 0; e--) {
            barrel(X, Y, rotation, 3/8, 5/4 + e/4);
        }
        circleTank(X, Y);
    }
    function gunnerTrapper(X, Y) {
        let rot = -Math.atan((mouseY - Y) / (mouseX - X));
        if (mouseX - X >= 0) {rot = (Math.PI + rot) % (2 * Math.PI)}
        trapperTurret(X, Y, Math.PI + rot, 1/2, 3/2);
        rot = -rot + Math.PI;
        ctx.fillStyle = "#999999";
        ctx.strokeStyle = '#757575';
        ctx.lineWidth = 2 * width / 7;
        ctx.beginPath();
        ctx.moveTo(X + 7 / 16 * width * Math.sin(rot), Y - 7 / 16 * width * Math.cos(rot));
        ctx.lineTo(X + 7 / 16 * width * Math.sin(rot) + 3 / 2 * width * Math.cos(rot), Y - 7 / 16 * width * Math.cos(rot) + 3 / 2 * width * Math.sin(rot));
        ctx.lineTo(X + 3 / 16 * width * Math.sin(rot) + 3 / 2 * width * Math.cos(rot), Y - 3 / 16 * width * Math.cos(rot) + 3 / 2 * width * Math.sin(rot));
        ctx.lineTo(X + 3 / 16 * width * Math.sin(rot), Y - 3 / 16 * width * Math.cos(rot));
        ctx.stroke();
        ctx.fill();
        ctx.beginPath();
        ctx.moveTo(X - 7 / 16 * width * Math.sin(rot), Y + 7 / 16 * width * Math.cos(rot));
        ctx.lineTo(X - 7 / 16 * width * Math.sin(rot) + 3 / 2 * width * Math.cos(rot), Y + 7 / 16 * width * Math.cos(rot) + 3 / 2 * width * Math.sin(rot));
        ctx.lineTo(X - 3 / 16 * width * Math.sin(rot) + 3 / 2 * width * Math.cos(rot), Y + 3 / 16 * width * Math.cos(rot) + 3 / 2 * width * Math.sin(rot));
        ctx.lineTo(X - 3 / 16 * width * Math.sin(rot), Y + 3 / 16 * width * Math.cos(rot));
        ctx.stroke();
        ctx.fill();
        circleTank(X, Y);
    }
    function auto5(X, Y) {
        let rot = -autorotation / 2;
        for(let n = 0; n < 5; n++) {
            let place = (rot + 2 / 5 * n * Math.PI + 2 * Math.PI) % (2 * Math.PI);
            let barrelX = X + width * Math.cos(rot + 2 / 5 * n * Math.PI + Math.PI);
            let barrelY = Y - width * Math.sin(rot + 2 / 5 * n * Math.PI + Math.PI);
            let rotation = Math.atan((mouseY - barrelY) / (mouseX - barrelX)) - Math.PI;
            if (mouseX - barrelX >= 0) {rotation = (Math.PI + rotation) % (2 * Math.PI)}
            if (Math.abs(Math.abs(place + rotation) - Math.PI) < Math.PI * 0.48) {
                ctx.strokeStyle = '#757575';
                ctx.fillStyle = '#999999';
                ctx.lineWidth = 2 * width / 7;
                ctx.beginPath();
                ctx.moveTo(barrelX + 3 / 16 * width * Math.sin(rotation), barrelY - 3 / 16 * width * Math.cos(rotation));
                ctx.lineTo(barrelX + 3 / 16 * width * Math.sin(rotation) + 2 / 2 * width * Math.cos(rotation), barrelY - 3 / 16 * width * Math.cos(rotation) + 2 / 2 * width * Math.sin(rotation));
                ctx.lineTo(barrelX - 3 / 16 * width * Math.sin(rotation) + 2 / 2 * width * Math.cos(rotation), barrelY + 3 / 16 * width * Math.cos(rotation) + 2 / 2 * width * Math.sin(rotation));
                ctx.lineTo(barrelX - 3 / 16 * width * Math.sin(rotation), barrelY + 3 / 16 * width * Math.cos(rotation));
                ctx.stroke();
                ctx.fill();
            } else {
            barrel(X, Y, rot + 2 / 5 * n * Math.PI, 3/16, 2);
            }
            ctx.strokeStyle = '#757575';
            ctx.fillStyle = '#999999';
            ctx.lineWidth = 2 * width / 7;
            ctx.beginPath();
            ctx.arc(X + width * Math.cos(rot + 2 / 5 * n * Math.PI + Math.PI), Y - width * Math.sin(rot + 2 / 5 * n * Math.PI + Math.PI), width * 3 / 8, 0, 2 * Math.PI + Math.PI);
            ctx.stroke();
            ctx.fill();
        }
        circleTank(X, Y);
    }
    function sprayer(X, Y) {
        let rot = -Math.atan((mouseY - Y) / (mouseX - X));
        if (mouseX - X >= 0) {rot = (Math.PI + rot) % (2 * Math.PI)}
        barrel(X, Y, rot, 3/8, 10/4);
        ctx.strokeStyle = '#757575';
        ctx.fillStyle = '#999999';
        ctx.lineWidth = 2 * width / 7;
        ctx.beginPath();
        ctx.moveTo(X - 3/8 * width * Math.sin(rot), Y - 3/8 * width * Math.cos(rot));
        ctx.lineTo(X - 9/4 * width * Math.cos(rot) - 3/4 * width * Math.sin(rot), Y - 3/4 * width * Math.cos(rot) + 9/4 * width * Math.sin(rot));
        ctx.lineTo(X - 9/4 * width * Math.cos(rot) + 3/4 * width * Math.sin(rot), Y + 3/4 * width * Math.cos(rot) + 9/4 * width * Math.sin(rot));
        ctx.lineTo(X + 3/8 * width * Math.sin(rot), Y + 3/8 * width * Math.cos(rot));
        ctx.closePath();
        ctx.stroke();
        ctx.fill();
        circleTank(X, Y);
    }
    function stalker(X, Y) {
        let rot = -Math.atan((mouseY - Y) / (mouseX - X));
        if (mouseX - X >= 0) {rot = (Math.PI + rot) % (2 * Math.PI)}
        barrel(X, Y, rot, 3/8, 10/4);
        ctx.strokeStyle = '#757575';
        ctx.fillStyle = '#999999';
        ctx.lineWidth = 2 * width / 7;
        ctx.beginPath();
        ctx.moveTo(X - 7/8 * width * Math.sin(rot), Y - 7/8 * width * Math.cos(rot));
        ctx.lineTo(X - 5/4 * width * Math.cos(rot) - 3/8 * width * Math.sin(rot), Y - 3/8 * width * Math.cos(rot) + 5/4 * width * Math.sin(rot));
        ctx.lineTo(X - 5/4 * width * Math.cos(rot) + 3/8 * width * Math.sin(rot), Y + 3/8 * width * Math.cos(rot) + 5/4 * width * Math.sin(rot));
        ctx.lineTo(X + 7/8 * width * Math.sin(rot), Y + 7/8 * width * Math.cos(rot));
        ctx.closePath();
        ctx.stroke();
        ctx.fill();
        circleTank(X, Y);
    }
    function ranger(X, Y) {
        let rot = -Math.atan((mouseY - Y) / (mouseX - X));
        if (mouseX - X >= 0) {rot = (Math.PI + rot) % (2 * Math.PI)}
        ctx.strokeStyle = '#757575';
        ctx.fillStyle = '#999999';
        ctx.lineWidth = 2 * width / 7;
        ctx.beginPath();
        ctx.moveTo(X - 3/4 * width * Math.sin(rot), Y - 3/4 * width * Math.cos(rot));
        ctx.lineTo(X - 10/4 * width * Math.cos(rot) - 3/8 * width * Math.sin(rot), Y - 3/8 * width * Math.cos(rot) + 10/4 * width * Math.sin(rot));
        ctx.lineTo(X - 10/4 * width * Math.cos(rot) + 3/8 * width * Math.sin(rot), Y + 3/8 * width * Math.cos(rot) + 10/4 * width * Math.sin(rot));
        ctx.lineTo(X + 3/4 * width * Math.sin(rot), Y + 3/4 * width * Math.cos(rot));
        ctx.closePath();
        ctx.stroke();
        ctx.fill();
        circleTank(X, Y);
    }
    function skimmer(X, Y) {
        let rot = -Math.atan((mouseY - Y) / (mouseX - X));
        if (mouseX - X >= 0) {rot = (Math.PI + rot) % (2 * Math.PI)}
        ctx.strokeStyle = '#757575';
        ctx.fillStyle = '#999999';
        ctx.lineWidth = 2 * width / 7;
        ctx.beginPath();
        ctx.moveTo(X, Y);
        ctx.lineTo(X - 2 * width * Math.cos(rot) - 5/8 * width * Math.sin(rot), Y - 5/8 * width * Math.cos(rot) + 2 * width * Math.sin(rot));
        ctx.lineTo(X - 2 * width * Math.cos(rot) + 5/8 * width * Math.sin(rot), Y + 5/8 * width * Math.cos(rot) + 2 * width * Math.sin(rot));
        ctx.closePath();
        ctx.stroke();
        ctx.fill();
        barrel(X, Y, rot, 3/4, 7/4);
        circleTank(X, Y);
    }
    function fatoverprot(X, Y) {
        let rotation = -Math.atan((mouseY - Y) / (mouseX - X));
        if (mouseX - X >= 0) {rotation = (Math.PI + rotation) % (2 * Math.PI)}
        olTurret(X + 3 * width / 2, Y, 0 + rotation);
        olTurret(X + 3 * width / 2, Y, Math.PI / 2 + rotation);
        olTurret(X + 3 * width / 2, Y, Math.PI + rotation);
        olTurret(X + 3 * width / 2, Y, 3 * Math.PI / 2 + rotation);
        barrel(X - width * 3/2, Y - width / 4, rotation - 5 * Math.PI / 12, 3/16, 10/8);
        barrel(X - width * 3/2, Y - width / 4, rotation + 5 * Math.PI / 12, 3/16, 10/8);
        barrel(X - width * 3/2, Y - width / 4, rotation - 4 * Math.PI / 12, 3/16, 11/8);
        barrel(X - width * 3/2, Y - width / 4, rotation + 4 * Math.PI / 12, 3/16, 11/8);
        barrel(X - width * 3/2, Y - width / 4, rotation - 3 * Math.PI / 12, 3/16, 12/8);
        barrel(X - width * 3/2, Y - width / 4, rotation + 3 * Math.PI / 12, 3/16, 12/8);
        barrel(X - width * 3/2, Y - width / 4, rotation - 2 * Math.PI / 12, 3/16, 13/8);
        barrel(X - width * 3/2, Y - width / 4, rotation + 2 * Math.PI / 12, 3/16, 13/8);
        barrel(X - width * 3/2, Y - width / 4, rotation - 1 * Math.PI / 12, 3/16, 14/8);
        barrel(X - width * 3/2, Y - width / 4, rotation + 1 * Math.PI / 12, 3/16, 14/8);
        barrel(X - width * 3/2, Y - width / 4, rotation, 3/8, 15/8);
        for (let i = 0; i < 8; i++) {
        barrel(X - width * 5/4, Y + 3 * width, i * Math.PI / 4 + rotation, 3/8, 2);
        }
        circleTank(X + 3 * width / 2, Y)
        face(X + 3 * width / 2, Y, faceNum);
        mouth(X + 3 * width / 2, Y, mouthNum);
        circleTank(X - width * 3/2, Y - width / 4);
        face(X - width * 3/2, Y - width / 4, faceNum);
        mouth(X - width * 3/2, Y - width / 4, mouthNum);
        circleTank(X - width * 5/4, Y + 3 * width);
        face(X - width * 5/4, Y + 3 * width, faceNum);
        mouth(X - width * 5/4, Y + 3 * width, mouthNum);
        name(X + 3 * width / 2, Y - 2 * width, 'fat overprot', 10);
        name(X + 3 * width / 2, Y - 1.5 * width, '1.2m', 7);
        name(X - width * 3/2, Y - 1.6 * width, 'fat overprot', 10);
        name(X - width * 5/4, Y + 1.55 * width, 'Blep', 10);

    }
    function drawTank(X, Y, t) {
        if (t != 28 && color != 14) {
            if (t == 0) {
                overlord(X, Y)
            } else if (t == 1) {
                quadTank(X, Y)
            } else if (t == 2) {
                octoTank(X, Y)
            } else if (t == 3) {
                triTrapper(X, Y)
            } else if (t == 4) {
                megaTrapper(X, Y)
            } else if (t == 5) {
                spreadShot(X, Y)
            } else if (t == 6) {
                pentaShot(X, Y)
            } else if (t == 7) {
                booster(X, Y)
            } else if (t == 8) {
                hybrid(X, Y)
            } else if (t == 9) {
                annihilator(X, Y)
            } else if (t == 10) {
                manager(X, Y)
            } else if (t == 11) {
                factory(X, Y)
            } else if (t == 12) {
                necromancer(X, Y)
            } else if (t == 13) {
                predator(X, Y)
            } else if (t == 14) {
                rocketeer(X, Y)
            } else if (t == 15) {
                landmine(X, Y)
            } else if (t == 16) {
                fighter(X, Y)
            } else if (t == 17) {
                triplet(X, Y)
            } else if (t == 18) {
                tripleTwin(X, Y)
            } else if (t == 19) {
                overTrapper(X, Y)
            } else if (t == 20) {
                battleship(X, Y)
            } else if (t == 21) {
                streamliner(X, Y)
            } else if (t == 22) {
                gunnerTrapper(X, Y)
            } else if (t == 23) {
                auto5(X, Y)
            } else if (t == 24) {
                sprayer(X, Y)
            } else if (t == 25) {
                stalker(X, Y)
            } else if (t == 26) {
                ranger(X, Y)
            } else if (t == 27) {
                skimmer(X, Y)
            }
        }
        if (counter >= 10) {
            tank = 28;
        }
        if (t == 28) {
            fatoverprot(X,Y);
        }
        else if (tank < 28 && counter >= 10) {counter = 0}
    }
    function aRend(X, Y, num) {
        let length = 300;
        let height = 70;
        achieveBG(X, Y+5, length, height);
        achieveBG(X+length/2+25+height/2, Y+5, height, height);
        name(X + length/2+25+height/2, Y + 37, rewards[num].toString(), 15);
        diepCoins(X+length/2+25+height/2, Y-6, 25);
        if (num == 0) {
            kills(X-150, Y-100, achievements.reduce((a, b) => a + b, 0)+'/15 Complete', 30);
            name(X, Y, 'Starting Off', 30);
            name(X, Y + 35, 'Reach 500 total kills', 20);
        }
        else if (num == 1) {
            name(X, Y, '3rd Place', 30);
            name(X, Y + 35, 'Obtain 200 kills with one tank', 20);
        }
        else if (num == 2) {
            name(X, Y, 'Finalist', 30);
            name(X, Y + 35, 'Obtain 500 kills with one tank', 20);
        }
        else if (num == 3) {
            name(X, Y, 'Got the Gold', 30);
            name(X, Y + 35, 'Obtain 1500 kills with one tank', 20);
        }
        else if (num == 4) {
            name(X, Y, 'SHIIINY', 30);
            name(X, Y + 35, 'Obtain 5000 kills with one tank', 20);
        }
        else if (num == 5) {
            name(X, Y, 'Generalist', 30);
            name(X, Y + 35, 'Obtain 200 kills with ten tanks', 20);
        }
        else if (num == 6) {
            name(X, Y, 'Tryhard', 30);
            name(X, Y + 35, 'Obtain 500 kills with ten tanks', 20);
        }
        else if (num == 7) {
            name(X, Y, 'Actually OP', 30);
            name(X, Y + 35, 'Obtain 1500 kills with ten tanks', 20);
        }
        else if (num == 8) {
            name(X, Y, 'Did You Cheat?', 30);
            name(X, Y + 35, 'Obtain 5000 kills with ten tanks', 20);
        }
        else if (num == 9) {
            name(X, Y, 'Rampage', 30);
            name(X, Y + 35, 'Obtain 100 kills in one round', 20);
        }
        else if (num == 10) {
            name(X, Y, 'Dedicated', 30);
            name(X, Y + 35, 'Reach 10k kills', 20);
        }
        else if (num == 11) {
            name(X, Y, 'Dedicated v2', 30);
            name(X, Y + 35, 'Reach 1m score', 20);
        }
        else if (num == 12) {
            name(X, Y, 'Go Outside', 30);
            name(X, Y + 35, 'Obtain 200 kills with all tanks', 20);
        }
        else if (num == 13) {
            name(X, Y, 'Troll', 30);
            name(X, Y + 35, 'Obtain 500 kills with mega trapper', 18);
        }
        else if (num == 14) {
            name(X, Y, 'Fat Overprot', 30);
            name(X, Y + 35, '?????', 20);
        }
        if (achievements[num] == 0) {
            ctx.fillStyle = '#75757560';
            ctx.beginPath();
            ctx.fillRect(X - length/2 - height / 7, Y - height / 2 - height / 7 + 5, length + 2 * height / 7, 9 * height / 7);
        }
    }

    function directory() {
        if (map == 0) return;
        let spacing = 60 + 2 * 15;
        let corner1 = 60;
        let corner2 = canvas.height - 7 * spacing;
        if (button(corner1, corner2 - spacing * 0.8, spacing, spacing * 0.4)) {UIoption = 0; space = 7}
        if (button(corner1 + 1.2 * spacing, corner2 - spacing * 0.8, spacing, spacing * 0.4)) {UIoption = 1; space = 3}
        if (button(corner1 + 2.5 * spacing, corner2 - spacing * 0.8, spacing * 1.2, spacing * 0.4)) {UIoption = 2; space = 3}
        if (button(corner1 + 3.9 * spacing, corner2 - spacing * 0.8, spacing * 1.2, spacing * 0.4)) {UIoption = 3; space = 3}
        if (button(corner1 + 5.9 * spacing, corner2 - spacing * 0.8, spacing * 2.4, spacing * 0.4)) {UIoption = 4; space = 3}
        if (button(corner1 + 7.9 * spacing, corner2 - spacing * 0.8, spacing * 1.2, spacing * 0.4)) {UIoption = 5; space = 7}
        UIText(corner1, corner2 - spacing * 0.7, "Tank");
        UIText(corner1 + 1.2 * spacing, corner2 - spacing * 0.7, "Eyes");
        UIText(corner1 + 2.5 * spacing, corner2 - spacing * 0.7, "Mouth");
        UIText(corner1 + 3.9 * spacing, corner2 - spacing * 0.7, "Color");
        UIText(corner1 + 5.9 * spacing, corner2 - spacing * 0.7, "Achievements");
        UIText(corner1 + 7.9 * spacing, corner2 - spacing * 0.7, "Shop");
        UIText(corner1 + 10 * spacing, corner2 - spacing * 0.7, "el bismüt");
        if (UIoption == 0) {
            for(let row = 0; row < 7; row++) {
                for(let col = 0; col < 4; col++) {
                    if(Math.abs(corner1+row*spacing - downX) < spacing / 2 && Math.abs(corner2+col*spacing - downY) < spacing / 2) {
                        counter = 0;
                        tank = row + col * 7;
                    }
                    shinyGoldButtons(corner1+row*spacing, corner2+col*spacing, spacing * 3 / 4, spacing * 3 / 4, killList[row + col * 7]);
                    drawTank(corner1+row*spacing, corner2+col*spacing, row + col * 7)
                     if (row + 6 * col == 1 && faceNum == 1) {
                    face(corner1+row*spacing, corner2+col*spacing, 3);
                     }
                    else{face(corner1+row*spacing, corner2+col*spacing, faceNum);}
                    mouth(corner1+row*spacing, corner2+col*spacing, mouthNum);
                    kill(corner1+row*spacing, corner2+col*spacing, (killList[row + 7 * col]));
                }
            }
        }
        else if (UIoption == 1) {
            for (let row = 0; row < 3; row++) {
                for(let col = 0; col < 4; col++) {
                    button(corner1+row*spacing, corner2 + col*spacing, spacing * 3 / 4, spacing * 3 / 4);
                    if(Math.abs(corner1+row*spacing - downX) < spacing / 2 && Math.abs(corner2+col*spacing - downY) < spacing / 2) {
                        if (row + col*3 < 4) {
                            faceNum = row + col*3;
                        }
                        else if (row + 3*col == 4 && lifetimeKills >= 200) {
                            faceNum = 4;
                        }
                        else if (row + 3*col == 5 && lifetimeKills >= 500) {
                            faceNum = 5;
                        }
                        else if (row + 3*col == 6 && lifetimeKills >= 1000) {
                            faceNum = 6;
                        }
                        else if (row + 3*col == 7 && lifetimeKills >= 2000) {
                            faceNum = 7;
                        }
                        else if (row + 3*col > 7 && fShop[row+3*col - 8] == 1) {
                            faceNum = row+3*col;
                        }
                    }
                    face(corner1+row*spacing, corner2 + col*spacing, row + col*3);
                    rejected(corner1+spacing, corner2+spacing, 3/4*spacing, 3/4*spacing, 200);
                    rejected(corner1+2*spacing, corner2+spacing, 3/4*spacing, 3/4*spacing, 500);
                    rejected(corner1, corner2+2*spacing, 3/4*spacing, 3/4*spacing, 1000);
                    rejected(corner1+spacing, corner2+2*spacing, 3/4*spacing, 3/4*spacing, 2000);
                    goToShop(corner1+2*spacing, corner2+2*spacing, 3/4*spacing, 3/4*spacing, fShop[0]);
                    goToShop(corner1, corner2+3*spacing, 3/4*spacing, 3/4*spacing, fShop[1]);
                    goToShop(corner1+spacing, corner2+3*spacing, 3/4*spacing, 3/4*spacing, fShop[2]);
                    goToShop(corner1+2*spacing, corner2+3*spacing, 3/4*spacing, 3/4*spacing, fShop[3]);
                }
            }
        }
        else if (UIoption == 2) {
            for(let row = 0; row < 3; row++) {
                for(let col = 0; col < 4; col++) {
                    button(corner1+row*spacing, corner2 + col*spacing, spacing * 3 / 4, spacing * 3 / 4);
                    if(Math.abs(corner1+row*spacing- downX) < spacing / 2 && Math.abs(corner2 +col*spacing - downY) < spacing / 2) {
                        if (row + col*3 < 4) {
                            mouthNum = row + col*3;
                        }
                        else if (row + 3*col == 4 && lifetimeKills >= 200) {
                            mouthNum = 4;
                        }
                        else if (row + 3*col == 5 && lifetimeKills >= 500) {
                            mouthNum = 5;
                        }
                        else if (row + 3*col == 6 && lifetimeKills >= 500) {
                            mouthNum = 6;
                        }
                        else if (row + 3*col == 7 && lifetimeKills >= 1000) {
                            mouthNum = 7;
                        }
                        else if (row + 3*col > 7 && mShop[row+3*col - 8] == 1) {
                            mouthNum = row+3*col;
                        }
                    }
                    mouth(corner1+row*spacing, corner2 + col*spacing, row + col*3);
                    rejected(corner1+spacing, corner2+spacing, 3/4*spacing, 3/4*spacing, 200);
                    rejected(corner1+2*spacing, corner2+spacing, 3/4*spacing, 3/4*spacing, 500);
                    rejected(corner1, corner2+2*spacing, 3/4*spacing, 3/4*spacing, 1000);
                    rejected(corner1+spacing, corner2+2*spacing, 3/4*spacing, 3/4*spacing, 2000);
                    goToShop(corner1+2*spacing, corner2+2*spacing, 3/4*spacing, 3/4*spacing, mShop[0]);
                    goToShop(corner1, corner2+3*spacing, 3/4*spacing, 3/4*spacing, mShop[1]);
                    goToShop(corner1+spacing, corner2+3*spacing, 3/4*spacing, 3/4*spacing, mShop[2]);
                    goToShop(corner1+2*spacing, corner2+3*spacing, 3/4*spacing, 3/4*spacing, mShop[3]);
                }
            }
        }
        else if (UIoption == 3) {
            for(let row = 0; row < 3; row++) {
                for(let col = 0; col < 5; col++) {
                    button(corner1+row*spacing, corner2 + col*spacing, spacing * 3 / 4, spacing * 3 / 4);
                    if(Math.abs(corner1+row*spacing - downX) < spacing / 2 && Math.abs(corner2 +col*spacing - downY) < spacing / 2) {
                        if (row + 3*col < 4) {
                            color = row + 3 * col;
                        }
                        else if (row + 3 * col == 4 && lifetimeKills >= 200) {
                            color = 4
                        }
                        else if (row + 3 * col == 5 && lifetimeKills >= 200) {
                            color = 5
                        }
                        else if (row + 3 * col == 6 && lifetimeKills >= 200) {
                            color = 6
                        }
                        else if (row + 3 * col == 7 && lifetimeKills >= 500) {
                            color = 7
                        }
                        else if (row + 3 * col == 8 && lifetimeKills >= 500) {
                            color = 8
                        }
                        else if (row + 3 * col == 9 && lifetimeKills >= 1000) {
                            color = 9
                        }
                        else if (row + 3 * col == 10 && lifetimeKills >= 1500) {
                            color = 10
                        }
                        else if (row + 3 * col == 11 && cShop[0] == 1) {
                            color = 11
                        }
                        else if (row + 3 * col == 12 && cShop[1] == 1) {
                            color = 12
                        }
                        else if (row + 3 * col == 13 && cShop[2] == 1) {
                            color = 13
                        }
                        else if (row + 3 * col == 14) {color = 14; counter++; downX = 10000; downY = 10000}
                    }
                    colorCircle(corner1+row*spacing, corner2+col*spacing, row + 3 * col);
                    rejected(corner1+spacing, corner2+spacing, 3/4*spacing, 3/4*spacing, 200);
                    rejected(corner1+2*spacing, corner2+spacing, 3/4*spacing, 3/4*spacing, 200);
                    rejected(corner1, corner2+2*spacing, 3/4*spacing, 3/4*spacing, 200);
                    rejected(corner1+spacing, corner2+2*spacing, 3/4*spacing, 3/4*spacing, 500);
                    rejected(corner1+2*spacing, corner2+2*spacing, 3/4*spacing, 3/4*spacing, 500);
                    rejected(corner1, corner2+3*spacing, 3/4*spacing, 3/4*spacing, 1000);
                    rejected(corner1+spacing, corner2+3*spacing, 3/4*spacing, 3/4*spacing, 1500);
                    goToShop(corner1+2*spacing, corner2+3*spacing, 3/4*spacing, 3/4*spacing, cShop[0]);
                    goToShop(corner1, corner2+4*spacing, 3/4*spacing, 3/4*spacing, cShop[1]);
                    goToShop(corner1+spacing, corner2+4*spacing, 3/4*spacing, 3/4*spacing, cShop[2]);
                }
            }
        }
        else if (UIoption == 4) {
            for(let row = 0; row < 5; row++) {
                for(let col = 0; col < 3; col++) {
                    aRend(corner1+150+500*col, corner2+100+110*row, row+col*5);
                }
            }
        }
        else if (UIoption == 5) {
            let first = 4, second = 4;
            UIText(corner1 + 2 * spacing, corner2 - 5, "Hover to see prices");
            for(let row = 0; row < first; row++) {
                button(corner1+row*spacing, corner2 + 50, spacing * 3 / 4, spacing * 3 / 4);
                face(corner1+row*spacing, corner2 + 50, row+8);
                goToShop(corner1+row*spacing, corner2 + 50, 3/4*spacing, 3/4*spacing, fShop[row]);
                if(Math.abs(corner1+row*spacing - downX) < spacing / 2 && Math.abs(corner2 + 50 - downY) < spacing / 2) {
                    if (fShop[row] == 0 && coins >= store[row]) {
                        fShop[row] = 1;
                        faceNum = row+8;
                        coins = coins - store[row];
                    }
                }
            }
            for(let row = 0; row < first; row++) {
                if(Math.abs(corner1+row*spacing - mouseX) < spacing / 2 && Math.abs(corner2 + 50 - mouseY) < spacing / 2 && fShop[row] == 0) {
                    hoverText(mouseX, mouseY, 15, store[row].toString());
                }
            }
            for(let row = 0; row < second; row++) {
                button(corner1+row*spacing, corner2 + 50 + spacing, spacing * 3 / 4, spacing * 3 / 4);
                mouth(corner1+row*spacing, corner2 + 50 + spacing, row+8);
                goToShop(corner1+row*spacing, corner2 + 50 + spacing, 3/4*spacing, 3/4*spacing, mShop[row]);
                if(Math.abs(corner1+row*spacing - downX) < spacing / 2 && Math.abs(corner2 + 50 + spacing - downY) < spacing / 2) {
                    if (mShop[row] == 0 && coins >= store[row+first]) {
                        mShop[row] = 1;
                        mouthNum = row+8;
                        coins = coins - store[row+first];
                    }
                }
            }
            for(let row = 0; row < second; row++) {
                if(Math.abs(corner1+row*spacing - mouseX) < spacing / 2 && Math.abs(corner2 + 50 + spacing - mouseY) < spacing / 2 && cShop[row] == 0) {
                    hoverText(mouseX, mouseY, 15, store[row+first].toString());
                }
            }
            for(let row = 0; row < 3; row++) {
                button(corner1+row*spacing, corner2 + 50 + 2*spacing, spacing * 3 / 4, spacing * 3 / 4);
                colorCircle(corner1+row*spacing, corner2 + 50 + 2*spacing, row+11);
                goToShop(corner1+row*spacing, corner2 + 50 + 2*spacing, 3/4*spacing, 3/4*spacing, cShop[row]);
                if(Math.abs(corner1+row*spacing - downX) < spacing / 2 && Math.abs(corner2 + 50 + 2*spacing - downY) < spacing / 2) {
                    if (cShop[row] == 0 && coins >= store[row+first+second]) {
                        cShop[row] = 1;
                        color = row+11;
                        coins = coins - store[row+first+second];
                    }
                }
            }
            for(let row = 0; row < 3; row++) {
                if(Math.abs(corner1+row*spacing - mouseX) < spacing / 2 && Math.abs(corner2 + 50 + 2*spacing - mouseY) < spacing / 2 && cShop[row] == 0) {
                    hoverText(mouseX, mouseY, 15, store[row+first+second].toString());
                }
            }
        }
        if (UIoption != 4) {
            kills(corner1 + space * spacing, corner2 + 2 * spacing / 3, "Kills this round: " + (killCount), 15);
            kills(corner1 + space * spacing, corner2 + spacing, "Kills total: " + (lifetimeKills), 15);
            kills(corner1 + space * spacing, corner2 + 4 *spacing / 3, "Coins earned: " + (Math.round(killCount * killCount * 3 / 4 - 2 + 2^(finalScore/500000)*250).toString()), 15);
        }
        achieveBG(corner1 + (space + 0.2) * spacing + coins.toString().length * 12.5, corner2, (spacing + coins.toString().length * 25), spacing * 3/4);
        diepCoins(corner1 + 20 + coins.toString().length * 25 + space * spacing, corner2, 25);
        kills(corner1 - 15 + space * spacing, corner2 - 20, coins.toString(), 45);
    }

    function squareTank(X, Y) {
        let tankInner = "rgb(" + tankRed + "," + tankGreen + "," + tankBlue;
        let tankOuter = "rgb(" + tankRed*3/4 + "," + tankGreen*3/4 + "," + tankBlue*3/4;
        let angle = -Math.atan((mouseY - Y) / (mouseX - X));
        if (mouseX - X >= 0) {angle = (Math.PI + angle) % (2 * Math.PI)}
        ctx.strokeStyle = tankOuter + ")";
        ctx.fillStyle = tankInner + ")";
        ctx.beginPath();
        ctx.moveTo(X + width * Math.cos(angle) + width * Math.sin(angle), Y - width * Math.sin(angle) + width * Math.cos(angle));
        ctx.lineTo(X + width * Math.cos(angle + Math.PI / 2) + width * Math.sin(angle + Math.PI / 2), Y - width * Math.sin(angle + Math.PI / 2) + width * Math.cos(angle + Math.PI / 2));
        ctx.lineTo(X + width * Math.cos(angle + Math.PI) + width * Math.sin(angle + Math.PI), Y - width * Math.sin(angle + Math.PI) + width * Math.cos(angle + Math.PI));
        ctx.lineTo(X + width * Math.cos(angle + 3 * Math.PI / 2) + width * Math.sin(angle + 3 * Math.PI / 2), Y - width * Math.sin(angle + 3 * Math.PI / 2) + width * Math.cos(angle + 3 * Math.PI / 2));
        ctx.lineTo(X + width * Math.cos(angle) + width * Math.sin(angle), Y - width * Math.sin(angle) + width * Math.cos(angle));
        ctx.closePath();
        ctx.stroke();
        ctx.fill();
        face(X, Y, faceNum);
        mouth(X, Y, mouthNum);
    }
    function circleTank(X, Y) {
        let tankInner = "rgb(" + tankRed + "," + tankGreen + "," + tankBlue;
        let tankOuter = "rgb(" + tankRed*3/4 + "," + tankGreen*3/4 + "," + tankBlue*3/4;
        ctx.fillStyle = tankOuter + ")";
        ctx.beginPath();
        ctx.arc(X, Y, width * 7 / 6, 0, 2*Math.PI);
        ctx.closePath();
        ctx.fill();
        ctx.fillStyle = tankInner + ")";
        ctx.beginPath();
        ctx.arc(X, Y, width, 0, 2*Math.PI);
        ctx.closePath();
        ctx.fill();
        face(X, Y, faceNum);
        mouth(X, Y, mouthNum);
    }
    function invisCircleTank(X, Y) {
        let tankInner = "rgb(" + tankRed + "," + tankGreen + "," + tankBlue;
        let tankOuter = "rgb(" + tankRed*3/4 + "," + tankGreen*3/4 + "," + tankBlue*3/4;
        ctx.fillStyle = tankOuter + "," + invis / 255 + ")"
        ctx.beginPath();
        ctx.arc(X, Y, width * 7 / 6, 0, 2*Math.PI);
        ctx.closePath();
        ctx.fill();
        ctx.fillStyle = tankInner + "," + invis / 255 + ")"
        ctx.beginPath();
        ctx.arc(X, Y, width, 0, 2*Math.PI);
        ctx.closePath();
        ctx.fill();
        face(X, Y, faceNum);
        mouth(X, Y, mouthNum);
    }
    function face(X, Y, choice) {
        let left = (-Math.atan((mouseY - Y + width / 8) / (mouseX - X + width / 2)) + 2 * Math.PI) % (2 * Math.PI);
        let right = (-Math.atan((mouseY - Y + width / 8) / (mouseX - X - width / 2)) + 2 * Math.PI) % (2 * Math.PI);
        if (mouseX - X - width / 2 >= 0) {right = (Math.PI + right) % (2 * Math.PI)}
        if (mouseX - X + width / 2 >= 0) {left = (Math.PI + left) % (2 * Math.PI)}
        if (choice == 0) {
            ctx.fillStyle = '#030303';
            ctx.beginPath();
            ctx.arc(X - width / 2, Y - width / 8, width / 3, 0, Math.PI * 2);
            ctx.fill();
            ctx.beginPath();
            ctx.arc(X + width / 2, Y - width / 8, width / 3, 0, Math.PI * 2);
            ctx.fill();
            ctx.fillStyle = '#FBFBFB';
            ctx.beginPath();
            ctx.ellipse(X - width / 2 - width / 3 * Math.cos(left), Y - width / 8 + width / 2.7 * Math.sin(left), width / 9, width / 24, 0, 0, 2*Math.PI);
            ctx.fill();
            ctx.beginPath();
            ctx.ellipse(X + width / 2 - width / 3 * Math.cos(right), Y - width / 8 + width / 2.7 * Math.sin(right), width / 9, width / 24, 0, 0, 2*Math.PI);
            ctx.fill();
            ctx.strokeStyle = '#88888860';
            ctx.lineWidth = width / 16;
            ctx.beginPath();
            ctx.arc(X - width / 2, Y - width / 8, width / 5, Math.PI / 2, Math.PI);
            ctx.stroke();
            ctx.beginPath();
            ctx.arc(X + width / 2, Y - width / 8, width / 5, Math.PI / 2, Math.PI);
            ctx.stroke();
        }
        else if (choice == 1) {
            ctx.fillStyle = '#030303';
            ctx.beginPath();
            ctx.arc(X - width / 2, Y - width / 8, width / 3, 0, 5 * Math.PI / 4);
            ctx.fill();
            ctx.beginPath();
            ctx.arc(X + width / 2, Y - width / 8, width / 3, 7 * Math.PI / 4, Math.PI);
            ctx.fill();
            ctx.fillStyle = '#FBFBFB';
            if (left <= Math.PI || left >= 7 * Math.PI / 4) {
                ctx.beginPath();
                ctx.ellipse(X - width / 2 - width / 3 * Math.cos(left), Y - width / 8 + width / 2.7 * Math.sin(left), width / 9, width / 24, 0, 0, 2*Math.PI);
                ctx.fill();
            }
            else {
                ctx.beginPath();
                ctx.ellipse(X - width / 2 - width / 3 * (Math.sin(Math.PI / 8) / Math.sin(15 * Math.PI / 8 - left)) * Math.cos(left), Y - width / 8 + width / 2.7 * (Math.sin(Math.PI / 8) / Math.sin(15 * Math.PI / 8 - left)) * Math.sin(left), width / 9, width / 24, 0, 0, 2*Math.PI);
                ctx.fill();
            }
            if (right <= 5 * Math.PI / 4 && right >= 0) {
                ctx.beginPath();
                ctx.ellipse(X + width / 2 - width / 3 * Math.cos(right), Y - width / 8 + width / 2.7 * Math.sin(right), width / 9, width / 24, 0, 0, 2*Math.PI);
                ctx.fill();
            }
            else {
                ctx.beginPath();
                ctx.ellipse(X + width / 2 - width / 3 * (Math.sin(Math.PI / 8) / Math.sin(right - 9 * Math.PI / 8)) * Math.cos(right), Y - width / 8 + width / 2.7 * (Math.sin(Math.PI / 8) / Math.sin(right - 9 * Math.PI / 8)) * Math.sin(right), width / 9, width / 24, 0, 0, 2*Math.PI);
                ctx.fill();
            }
        }
        else if (choice == 2) {
            ctx.fillStyle = '#030303';
            ctx.beginPath();
            ctx.arc(X + width / 2, Y - width / 8, width / 3, 11 / 6 * Math.PI, 7 / 6 * Math.PI);
            ctx.fill();
            ctx.beginPath();
            ctx.arc(X - width / 2, Y - width / 8, width / 3, 11 / 6 * Math.PI, 7 / 6 * Math.PI);
            ctx.fill();
            ctx.fillStyle = '#FBFBFB';
            if (!(left > 7 * Math.PI / 6 && left < 11 * Math.PI / 6)) {
                ctx.beginPath();
                ctx.ellipse(X - width / 2 - width / 3 * Math.cos(left), Y - width / 8 + width / 2.7 * Math.sin(left), width / 9, width / 24, 0, 0, 2*Math.PI);
                ctx.fill();
            }
            else {
                ctx.beginPath();
                ctx.ellipse(X - width / 2 - width / 3 * Math.tan(left - 3 * Math.PI / 2) * 1/2, Y - width / 8 - width / 2.7 * 1/2, width / 9, width / 24, 0, 0, 2*Math.PI);
                ctx.fill();
            }
            if (!(right > 7 * Math.PI / 6 && right < 11 * Math.PI / 6)) {
                ctx.beginPath();
                ctx.ellipse(X + width / 2 - width / 3 * Math.cos(right), Y - width / 8 + width / 2.7 * Math.sin(right), width / 9, width / 24, 0, 0, 2*Math.PI);
                ctx.fill();
            }
            else {
                ctx.beginPath();
                ctx.ellipse(X + width / 2 - width / 3 * Math.tan(right - 3 * Math.PI / 2) * 1/2, Y - width / 8 - width / 2.7 * 1/2, width / 9, width / 24, 0, 0, 2*Math.PI);
                ctx.fill();
            }
        }
        else if (choice == 3) {
            ctx.fillStyle = '#030303';
            ctx.beginPath();
            ctx.arc(X + width / 2, Y - width / 8, width / 3, 0, 5 * Math.PI / 4);
            ctx.fill();
            ctx.beginPath();
            ctx.arc(X - width / 2, Y - width / 8, width / 3, 7 * Math.PI / 4, Math.PI);
            ctx.fill();
            ctx.fillStyle = '#FBFBFB';
            if (left >= 0 && left <= 5 * Math.PI / 4) {
                ctx.beginPath();
                ctx.ellipse(X - width / 2 - width / 3 * Math.cos(left), Y - width / 8 + width / 2.7 * Math.sin(left), width / 9, width / 24, 0, 0, 2*Math.PI);
                ctx.fill();
            }
            else {
                ctx.beginPath();
                ctx.ellipse(X - width / 2 + width / 3 * (Math.sin(Math.PI / 8) / Math.sin(9 * Math.PI / 8 - left)) * Math.cos(left), Y - width / 8 - width / 2.7 * (Math.sin(Math.PI / 8) / Math.sin(9 * Math.PI / 8 - left)) * Math.sin(left), width / 9, width / 24, 0, 0, 2*Math.PI);
                ctx.fill();
            }
            if (!(right >= Math.PI && right <= 7 * Math.PI / 4)) {
                ctx.beginPath();
                ctx.ellipse(X + width / 2 - width / 3 * Math.cos(right), Y - width / 8 + width / 2.7 * Math.sin(right), width / 9, width / 24, 0, 0, 2*Math.PI);
                ctx.fill();
            }
            else {
                ctx.beginPath();
                ctx.ellipse(X + width / 2 + width / 3 * (Math.sin(Math.PI / 8) / Math.sin(right - 15 * Math.PI / 8)) * Math.cos(right), Y - width / 8 - width / 2.7 * (Math.sin(Math.PI / 8) / Math.sin(right - 15 * Math.PI / 8)) * Math.sin(right), width / 9, width / 24, 0, 0, 2*Math.PI);
                ctx.fill();
            }
        }
        else if (choice == 4) {
            ctx.strokeStyle = '#030303';
            ctx.lineWidth = width / 10;
            ctx.beginPath();
            ctx.moveTo(X - 2 * width / 3, Y - width / 12);
            ctx.lineTo(X - width / 6, Y - width / 12);
            ctx.closePath();
            ctx.stroke();
            ctx.beginPath();
            ctx.moveTo(X + 2 * width / 3, Y - width / 12);
            ctx.lineTo(X + width / 6, Y - width / 12);
            ctx.closePath();
            ctx.stroke();
        }
        else if (choice == 5) {
            ctx.strokeStyle = '#030303';
            ctx.lineWidth = width / 10;
            ctx.beginPath();
            ctx.moveTo(X - 2 * width / 3, Y - width / 2);
            ctx.lineTo(X - 2 * width / 3, Y - width / 6);
            ctx.arc(X - 5 / 12 * width, Y - width / 6, width / 4, Math.PI, 0, true);
            ctx.lineTo(X - width / 6, Y - width / 2);
            ctx.stroke();
            ctx.beginPath();
            ctx.moveTo(X + 2 * width / 3, Y - width / 2);
            ctx.lineTo(X + 2 * width / 3, Y - width / 6);
            ctx.arc(X + 5 / 12 * width, Y - width / 6, width / 4, 0, Math.PI, false);
            ctx.lineTo(X + width / 6, Y - width / 2);
            ctx.stroke();
        }
        else if (choice == 6) {
            ctx.strokeStyle = '#030303';
            ctx.lineWidth = width / 10;
            ctx.beginPath();
            ctx.moveTo(X - 2/3 * width, Y - 5 * width / 12);
            ctx.lineTo(X - 1/4 * width, Y - width / 6);
            ctx.lineTo(X - 2/3 * width, Y + 1/12 * width);
            ctx.stroke();
            ctx.beginPath();
            ctx.moveTo(X + 2/3 * width, Y - 5 * width / 12);
            ctx.lineTo(X + 1/4 * width, Y - width / 6);
            ctx.lineTo(X + 2/3 * width, Y + 1/12 * width);
            ctx.stroke();
        }
        else if (choice == 7) {
            ctx.strokeStyle = '#030303';
            ctx.lineWidth = width / 5;
            ctx.beginPath();
            ctx.moveTo(X - 3/4 * width, Y - width / 6);
            ctx.lineTo(X - 1/4 * width, Y - width / 6);
            ctx.stroke();
            ctx.beginPath();
            ctx.moveTo(X + 3/4 * width, Y - width / 6);
            ctx.lineTo(X + 1/4 * width, Y - width / 6);
            ctx.stroke();
            ctx.fillStyle = '#030303';
            ctx.beginPath();
            ctx.ellipse(X - Math.max(Math.min(X - mouseX, 5/8 * width), 3/8 * width), Y + width / 12, width / 6, width * 0.3, 0, 0, 2*Math.PI);
            ctx.ellipse(X + Math.max(Math.min(mouseX - X, 5/8 * width), 3/8 * width), Y + width / 12, width / 6, width * 0.3, 0, 0, 2*Math.PI);
            ctx.fill();
        }
        else if (choice == 8) {
            ctx.strokeStyle = '#030303';
            ctx.lineWidth = width / 10;
            ctx.beginPath();
            ctx.moveTo(X - 3/4 * width, Y - width / 6);
            ctx.lineTo(X - 1/4 * width, Y - width / 4);
            ctx.stroke();
            ctx.beginPath();
            ctx.moveTo(X + 3/4 * width, Y - width / 6);
            ctx.lineTo(X + 1/4 * width, Y - width / 4);
            ctx.stroke();
        }
        else if (choice == 9) {
            ctx.fillStyle = '#030303';
            ctx.beginPath();
            ctx.arc(X - width / 2, Y - width / 8, width / 3, 0, Math.PI * 2);
            ctx.fill();
            ctx.beginPath();
            ctx.arc(X + width / 2, Y - width / 8, width / 3, 0, Math.PI * 2);
            ctx.fill();
            ctx.fillStyle = '#FBFBFB';
            ctx.beginPath();
            ctx.ellipse(X - width / 2 - width / 3 * Math.cos(left), Y - width / 8+Math.sin(0.3)*width/3, width / 9, width / 24, 0, 0, 2*Math.PI);
            ctx.fill();
            ctx.beginPath();
            ctx.ellipse(X + width / 2 - width / 3 * Math.cos(right), Y - width / 8 + Math.sin(0.3)*width/3, width / 9, width / 24, 0, 0, 2*Math.PI);
            ctx.fill();
            ctx.fillStyle = '#444444';
            ctx.beginPath();
            ctx.arc(X - width / 2, Y - width / 8, width / 3, 0.3+0.2, (Math.PI - 0.3 - 0.2) % (2 * Math.PI));
            ctx.fill();
            ctx.beginPath();
            ctx.arc(X - width / 2, Y - width / 8, width / 3, 0.3-0.2, (Math.PI - 0.3 + 0.2) % (2 * Math.PI), true);
            ctx.fill();
            ctx.beginPath();
            ctx.arc(X + width / 2, Y - width / 8, width / 3, 0.3+0.2 , (Math.PI - 0.3 - 0.2) % (2 * Math.PI));
            ctx.fill();
            ctx.beginPath();
            ctx.arc(X + width / 2, Y - width / 8, width / 3, 0.3-0.2 , (Math.PI - 0.3 + 0.2) % (2 * Math.PI), true);
            ctx.fill();
        }
        else if (choice == 10) {
            ctx.strokeStyle = '#030303';
            ctx.fillStyle = '#FFFFFF';
            ctx.lineWidth = width / 10;
            ctx.beginPath();
            ctx.ellipse(X - width / 2 - 1.5 * Math.cos(left), Y - width / 8 + 1.5 * Math.sin(left), width / 4, width / 3, 0 , 0, Math.PI * 2);
            ctx.stroke();
            ctx.fill();
            ctx.beginPath();
            ctx.ellipse(X + width / 2 - 1.5 * Math.cos(right), Y - width / 8 + 1.5 * Math.sin(right), width / 4, width / 3, 0, 0, Math.PI * 2);
            ctx.stroke();
            ctx.fill();
        }
        else if (choice == 11) {
            ctx.strokeStyle = '#000000';
            ctx.lineWidth = width / 15;
            ctx.beginPath();
            ctx.moveTo(X - width / 1.05, Y - width / 4);
            ctx.lineTo(X + width / 1.05, Y - width / 4);
            ctx.stroke();
            ctx.fillStyle = '#030303';
            ctx.beginPath();
            ctx.arc(X - width / 2, Y - width / 8, width / 3, 11 / 6 * Math.PI, 7 / 6 * Math.PI);
            ctx.fill();
            ctx.arc(X + width / 2, Y - width / 8, width / 3, 11 / 6 * Math.PI, 7 / 6 * Math.PI);
            ctx.fill();
        }
    }

    function mouth(X, Y, choice) {
        if (choice == 0) {
            ctx.strokeStyle = '#030303';
            ctx.lineWidth = width / 12;
            ctx.beginPath();
            ctx.moveTo(X - width / 15, Y + width / 4);
            ctx.lineTo(X + width / 15, Y + width / 4);
            ctx.stroke();
        }
        else if (choice == 1) {
            ctx.strokeStyle = '#030303';
            ctx.lineWidth = width / 20;
            ctx.beginPath();
            ctx.arc(X, Y + width / 4, width / 9, 0, Math.PI);
            ctx.stroke();
            ctx.fillStyle = '#030303';
            ctx.beginPath();
            ctx.arc(X, Y + width / 4, width / 9, 0, Math.PI);
            ctx.fill();
        }
        else if (choice == 2) {
            ctx.strokeStyle = '#030303';
            ctx.lineWidth = width / 20;
            ctx.beginPath();
            ctx.arc(X, Y + width / 4 + width / 9, width / 9, 0, Math.PI, true);
            ctx.stroke();
            ctx.fillStyle = '#030303';
            ctx.beginPath();
            ctx.arc(X, Y + width / 4+ width / 9, width / 9, 0, Math.PI, true);
            ctx.fill();
        }
        else if (choice == 3) {
            ctx.strokeStyle = '#030303';
            ctx.lineWidth = width / 16;
            ctx.beginPath();
            ctx.arc(X + width / 12, Y + width / 4, width / 12, 0, Math.PI);
            ctx.stroke();
            ctx.beginPath();
            ctx.arc(X - width / 12, Y + width / 4, width / 12, 0, Math.PI);
            ctx.stroke();
        }
        else if (choice == 4) {
            ctx.strokeStyle = '#030303';
            ctx.lineWidth = width / 12;
            ctx.beginPath();
            ctx.moveTo(X - width / 8, Y + width / 4);
            ctx.lineTo(X, Y + width / 8);
            ctx.lineTo(X + width / 8, Y + width / 4);
            ctx.stroke();
        }
        else if (choice == 5) {
            ctx.strokeStyle = '#030303';
            ctx.lineWidth = width / 20;
            ctx.beginPath();
            ctx.arc(X, Y + width / 8, width / 6, Math.PI / 6, 5 * Math.PI / 6);
            ctx.stroke();
        }
        else if (choice == 6) {
            ctx.strokeStyle = '#030303';
            ctx.lineWidth = width / 20;
            ctx.beginPath();
            ctx.arc(X, Y + width / 3, width / 6, -Math.PI / 6, -5 * Math.PI / 6, true);
            ctx.stroke();
        }
        else if (choice == 7) {
            ctx.strokeStyle = '#030303';
            ctx.lineWidth = width / 16;
            ctx.beginPath();
            ctx.arc(X + width / 12, Y + width / 4, width / 12, 0, Math.PI);
            ctx.stroke();
            ctx.beginPath();
            ctx.arc(X - width / 12, Y + width / 4, width / 12, 0, Math.PI);
            ctx.stroke();
            ctx.beginPath();
            ctx.arc(X, Y + width / 3, width / 12, 0, Math.PI);
            ctx.stroke();
        }
        else if (choice == 8) {
            ctx.fillStyle = '#030303';
            ctx.beginPath();
            ctx.ellipse(X, Y+width / 4, width / 6, width /8,0, 0, Math.PI * 2);
            ctx.fill();
        }
        else if (choice == 9) {
            ctx.strokeStyle = '#030303';
            ctx.lineWidth = width / 12;
            ctx.beginPath();
            ctx.moveTo(X - width / 12, Y + width / 4);
            ctx.lineTo(X, Y + width / 8);
            ctx.lineTo(X + width / 12, Y + width / 4);
            ctx.closePath();
            ctx.stroke();
        }
        else if (choice == 10) {
            ctx.strokeStyle = '#030303';
            ctx.lineWidth = width / 12;
            ctx.beginPath();
            ctx.moveTo(X - width / 8, Y + width / 4);
            ctx.lineTo(X + width / 8, Y + width / 4);
            ctx.stroke();
        }
        else if (choice == 11) {
            ctx.strokeStyle = '#030303';
            ctx.lineWidth = width / 16;
            ctx.beginPath();
            ctx.arc(X + width / 12, Y + width / 4, width / 12, 0, Math.PI);
            ctx.stroke();
            ctx.beginPath();
            ctx.arc(X - width / 12, Y + width / 4, width / 12, 0, Math.PI);
            ctx.stroke();
            ctx.beginPath();
            ctx.arc(X, Y + width / 3, width / 12, 0, Math.PI);
            ctx.stroke();
        }
    }
    function diepCoins(X, Y, radius) {
        ctx.fillStyle = '#FFE86999';
        ctx.strokeStyle = '#BBAE4999';
        ctx.lineWidth = radius / 7;
        ctx.beginPath();
        ctx.arc(X, Y, radius * 15/14, 0, 2 * Math.PI);
        ctx.stroke();
        ctx.beginPath();
        ctx.arc(X, Y, radius, 0, 2 * Math.PI);
        ctx.fill();
        ctx.beginPath();
        ctx.arc(X, Y, radius * 0.6, 0, 2 * Math.PI);
        ctx.stroke();
        ctx.beginPath();
        ctx.moveTo(X + radius * 0.2 * Math.cos(5 * Math.PI / 4), Y + radius * 0.2 * Math.sin(5 * Math.PI / 4))
        ctx.lineTo(X + radius * 0.2 * Math.cos(5 * Math.PI / 4) - radius * 0.8 * Math.sin(5 * Math.PI / 4), Y + radius * 0.2 * Math.sin(5 * Math.PI / 4) + radius * 0.8 * Math.sin(5 * Math.PI / 4));
        ctx.lineTo(X - radius * 0.2 * Math.cos(5 * Math.PI / 4) - radius * 0.8 * Math.sin(5 * Math.PI / 4), Y - radius * 0.2 * Math.sin(5 * Math.PI / 4) + radius * 0.8 * Math.sin(5 * Math.PI / 4));
        ctx.lineTo(X - radius * 0.2 * Math.cos(5 * Math.PI / 4), Y - radius * 0.2 * Math.sin(5 * Math.PI / 4))
        ctx.stroke();
        ctx.fillStyle = '#FFE869';
        ctx.beginPath();
        ctx.arc(X, Y, radius*(0.6-1/14), 0, 2 * Math.PI);
        ctx.fill();
    }
    function hoverText(X, Y, size, content) {
        ctx.font = `${25}px Ubuntu`;
		ctx.lineWidth = (25 / 5.0);
        ctx.textAlign = "left";
        ctx.strokeStyle = "#505050";
		ctx.strokeText(content, X, Y-25*2/3);
		ctx.fillStyle = "#EEEEEE";
		ctx.fillText(content, X, Y-25*2/3);
        diepCoins(X + content.length*50/3 + 5, Y - 25, 13);
    }
    function rejected(X, Y, length, width, needed) {
        if (lifetimeKills >= needed) return;
        if ((Math.abs(mouseX - X) < length / 2 && Math.abs(mouseY - Y) < width / 2)) {
            ctx.fillStyle = '#44444408'
            ctx.beginPath();
            ctx.fillRect(X - length/2 - width / 7, Y - width / 2 - width / 7, length + 2 * width / 7, 9 * width / 7);
        }
        else {
            ctx.fillStyle = '#44444408'
            ctx.beginPath();
            ctx.fillRect(X - length/2 - width/14, Y - 4*width/7, length+width/7, 8*width/7);
        }
        ctx.font = `${15}px Ubuntu`;
		ctx.lineWidth = (15 / 5.0);
        ctx.textAlign = "center";
        ctx.strokeStyle = "#505050";
		ctx.strokeText(lifetimeKills + "/"+needed, X, Y+35);
		ctx.fillStyle = "#EEEEEE";
		ctx.fillText(lifetimeKills + "/"+needed, X, Y+35);
    }
    function goToShop(X, Y, length, width, yes) {
        if (yes == 1) {
            ctx.font = `${15}px Ubuntu`;
            ctx.lineWidth = (15 / 5.0);
            ctx.textAlign = "center";
            ctx.strokeStyle = "#505050";
            ctx.strokeText("Bought", X, Y+35);
            ctx.fillStyle = "#EEEEEE";
            ctx.fillText("Bought", X, Y+35);
            return;
        }
        if ((Math.abs(mouseX - X) < length / 2 && Math.abs(mouseY - Y) < width / 2)) {
            ctx.fillStyle = '#44444410'
            ctx.beginPath();
            ctx.fillRect(X - length/2 - width / 7, Y - width / 2 - width / 7, length + 2 * width / 7, 9 * width / 7);
        }
        else {
            ctx.fillStyle = '#44444410'
            ctx.beginPath();
            ctx.fillRect(X - length/2 - width/14, Y - 4*width/7, length+width/7, 8*width/7);
        }
        ctx.font = `${15}px Ubuntu`;
		ctx.lineWidth = (15 / 5.0);
        ctx.textAlign = "center";
        ctx.strokeStyle = "#505050";
		ctx.strokeText("Go to shop", X, Y+35);
		ctx.fillStyle = "#EEEEEE";
		ctx.fillText("Go to shop", X, Y+35);
    }
    function button(X, Y, length, width) {
        if ((Math.abs(mouseX - X) < length / 2 && Math.abs(mouseY - Y) < width / 2)) {
            ctx.strokeStyle = '#757575';
            ctx.fillStyle = '#999999'
            ctx.lineWidth = 2 * width / 7;
            ctx.beginPath();
            ctx.strokeRect(X - length/2 - width/14, Y - 4*width/7, length+width/7, 8*width/7);
            ctx.fillRect(X - length/2 - width / 7, Y - width / 2 - width / 7, length + 2 * width / 7, 9 * width / 7);
        }
        else {
            ctx.fillStyle = '#757575';
            ctx.beginPath();
            ctx.fillRect(X - length/2 - width / 7, Y - width / 2 - width / 7, length + 2 * width / 7, 9 * width / 7);
            ctx.fillStyle = '#999999';
            ctx.beginPath();
            ctx.fillRect(X - length/2 - width/14, Y - 4*width/7, length+width/7, 8*width/7);
        }
        if ((Math.abs(downX - X) < length / 2 && Math.abs(downY - Y) < width / 2)) {
            return true;
        }
    }
    function shinyGoldButtons(X, Y, length, width, kills) {
        let re, gr, bl, shine = 0;
        if (kills < 200) {
            re = 160; gr = 160; bl = 160;
        }
        else if (kills < 500) {
            re = 155; gr = 75; bl = 10;
        }
        else if (kills < 1500) {
            re = 92; gr = 96; bl = 96;
        }
        else if (kills < 5000) {
            re = 218; gr = 165; bl = 0;
            shine = 2;
        }
        else {
            re = 5; gr = 180; bl = 196;
            shine = 4;
        }
        if ((Math.abs(mouseX - X) < length / 2 && Math.abs(mouseY - Y) < width / 2)) {
            ctx.fillStyle = 'rgb(' + re*1.25 + ',' + gr*1.25 + ',' + bl*1.25 + ')';
            ctx.strokeStyle = 'rgb(' + re*15/16 + ',' + gr*15/16 + ',' + bl*15/16 + ')';
            ctx.lineWidth = 2 * width / 7;
            ctx.beginPath();
            ctx.strokeRect(X - length/2 - width/14, Y - 4*width/7, length+width/7, 8*width/7);
            ctx.fillRect(X - length/2 - width / 7, Y - width / 2 - width / 7, length + 2 * width / 7, 9 * width / 7);
            if (shine > 0) {
                ctx.strokeStyle = '#D9D9D9D0';
                ctx.lineWidth = width / 15;
                for (let n = 0; n < shine; n++) {
                    ctx.beginPath();
                    ctx.moveTo(X + 0.45 * length * Math.cos(2 * Math.PI / shine * n) + 0.55 * width * Math.sin(2 * Math.PI / shine * n), Y + 0.45 * length * Math.sin(2 * Math.PI / shine * n) - 0.55 * width * Math.cos(2 * Math.PI / shine * n));
                    ctx.lineTo(X + 0.55 * length * Math.cos(2 * Math.PI / shine * n) + 0.55 * width * Math.sin(2 * Math.PI / shine * n), Y + 0.55 * length * Math.sin(2 * Math.PI / shine * n) - 0.55 * width * Math.cos(2 * Math.PI / shine * n));
                    ctx.lineTo(X + 0.55 * length * Math.cos(2 * Math.PI / shine * n) + 0.45 * width * Math.sin(2 * Math.PI / shine * n), Y + 0.55 * length * Math.sin(2 * Math.PI / shine * n) - 0.45 * width * Math.cos(2 * Math.PI / shine * n));
                    ctx.stroke();
                }
            }
        }
        else {
            ctx.fillStyle = 'rgb(' + re*15/16 + ',' + gr*15/16 + ',' + bl*15/16 + ')';
            ctx.beginPath();
            ctx.fillRect(X - length/2 - width / 7, Y - width / 2 - width / 7, length + 2 * width / 7, 9 * width / 7);
            ctx.fillStyle = 'rgb(' + re*1.25 + ',' + gr*1.25 + ',' + bl*1.25 + ')';
            ctx.beginPath();
            ctx.fillRect(X - length/2 - width/14, Y - 4*width/7, length+width/7, 8*width/7);
            if (shine > 0) {
                ctx.strokeStyle = '#D9D9D9D0';
                ctx.lineWidth = width / 15;
                for (let n = 0; n < shine; n++) {
                    ctx.beginPath();
                    ctx.moveTo(X + 0.4 * length * Math.cos(2 * Math.PI / shine * n) + 0.5 * width * Math.sin(2 * Math.PI / shine * n), Y + 0.4 * length * Math.sin(2 * Math.PI / shine * n) - 0.5 * width * Math.cos(2 * Math.PI / shine * n));
                    ctx.lineTo(X + 0.5 * length * Math.cos(2 * Math.PI / shine * n) + 0.5 * width * Math.sin(2 * Math.PI / shine * n), Y + 0.5 * length * Math.sin(2 * Math.PI / shine * n) - 0.5 * width * Math.cos(2 * Math.PI / shine * n));
                    ctx.lineTo(X + 0.5 * length * Math.cos(2 * Math.PI / shine * n) + 0.4 * width * Math.sin(2 * Math.PI / shine * n), Y + 0.5 * length * Math.sin(2 * Math.PI / shine * n) - 0.4 * width * Math.cos(2 * Math.PI / shine * n));
                    ctx.stroke();
                }
            }
        }
    }
    if (color==0) {
        tankRed = 0; tankGreen = 177; tankBlue = 222;
    } else if (color == 1) {
        tankRed = 0; tankGreen = 225; tankBlue = 110;
    } else if (color == 2) {
        tankRed = 191; tankGreen = 127; tankBlue = 245;
    } else if (color == 3) {
        tankRed = 241; tankGreen = 78; tankBlue = 84;
    } else if (color == 4) {
        if (lifetimeKills > 100) {
            tankRed = 255; tankGreen = 232; tankBlue = 101;
        }
    } else if (color == 5) {
        if (lifetimeKills > 200) {
            tankRed = 198; tankGreen = 198; tankBlue = 198;
        }
    } else if (color == 6) {
        tankRed = 32; tankGreen = 149; tankBlue = 143;
    } else if (color == 7) {
        tankRed = 255; tankGreen = 171; tankBlue = 255;
    } else if (color == 8) {
        tankRed = 0; tankGreen = 225; tankBlue = 193;
    } else if (color == 9) {
        tankRed = 171; tankGreen = 205; tankBlue = 239;
    } else if (color == 10) {
        tankRed = rRed; tankGreen = rGreen; tankBlue = rBlue;
    } else if (color == 11) {
        tankRed = 254; tankGreen = 153; tankBlue = 21;
    } else if (color == 12) {
        tankRed = 239; tankGreen = 52; tankBlue = 222;
    } else if (color == 13) {
        tankRed = 60; tankGreen = 60; tankBlue = 60;
    }
    function colorCircle(X, Y, choice) {
        if(choice==0) {
            z = 0; x = 177; c = 222;
        } else if (choice == 1) {
            z = 0; x = 225; c = 110;
        } else if (choice == 2) {
            z = 191; x = 127; c = 245;
        } else if (choice == 3) {
            z = 241; x = 78; c = 84;
        } else if (choice == 4) {
            z = 255; x = 232; c = 101;
        } else if (choice == 5) {
            z = 198; x = 198; c = 198;
        } else if (choice == 6) {
            z = 32; x = 149; c = 143;
        } else if (choice == 7) {
            z = 255; x = 171; c = 255;
        } else if (choice == 8) {
            z = 0; x = 225; c = 193;
        } else if (choice == 9) {
            z = 171; x = 205; c = 239;
        } else if (choice == 10) {
            z = rRed; x = rGreen; c = rBlue;
        } else if (choice == 11) {
            z = 254; x = 153; c = 21;
        } else if (choice == 12) {
            z = 239; x = 52; c = 222;
        } else if (choice == 13) {
            z = 60; x = 60; c = 60;
        } else if (choice == 14) {
            z = 241; x = 78; c = 84;
            let fill = "rgb(" + z + "," + x + "," + c;
            let stroke = "rgb(" + z*3/4 + "," + x*3/4 + "," + c*3/4;
            ctx.strokeStyle = stroke;
            ctx.lineWidth = 5 * width / 7;
            ctx.beginPath();
            ctx.moveTo(X - 14 * width / 8, Y + 10 * width / 8);
            ctx.lineTo(X - 10 * width / 8, Y + 14 * width / 8);
            ctx.lineTo(X + 14 * width / 8, Y - 10 * width / 8);
            ctx.lineTo(X + 10 * width / 8, Y - 14 * width / 8);
            ctx.closePath();
            ctx.stroke();
            ctx.beginPath();
            ctx.moveTo(X + 14 * width / 8, Y + 10 * width / 8);
            ctx.lineTo(X + 10 * width / 8, Y + 14 * width / 8);
            ctx.lineTo(X - 14 * width / 8, Y - 10 * width / 8);
            ctx.lineTo(X - 10 * width / 8, Y - 14 * width / 8);
            ctx.closePath();
            ctx.stroke();
            ctx.fillStyle = fill;
            ctx.beginPath();
            ctx.moveTo(X - 14 * width / 8, Y + 10 * width / 8);
            ctx.lineTo(X - 10 * width / 8, Y + 14 * width / 8);
            ctx.lineTo(X + 14 * width / 8, Y - 10 * width / 8);
            ctx.lineTo(X + 10 * width / 8, Y - 14 * width / 8);
            ctx.closePath();
            ctx.fill();
            ctx.beginPath();
            ctx.moveTo(X + 14 * width / 8, Y + 10 * width / 8);
            ctx.lineTo(X + 10 * width / 8, Y + 14 * width / 8);
            ctx.lineTo(X - 14 * width / 8, Y - 10 * width / 8);
            ctx.lineTo(X - 10 * width / 8, Y - 14 * width / 8);
            ctx.closePath();
            ctx.fill();
            return;
        }
        let fill = "rgb(" + z + "," + x + "," + c;
        let stroke = "rgb(" + z*3/4 + "," + x*3/4 + "," + c*3/4;
        ctx.strokeStyle = stroke;
        ctx.lineWidth = 10;
        ctx.beginPath();
        ctx.arc(X, Y, 25, 0, 2 * Math.PI);
        ctx.stroke();
        ctx.fillStyle = fill;
        ctx.beginPath();
        ctx.arc(X, Y, 25, 0, 2 * Math.PI);
        ctx.fill();
    }
    function UIText(X, Y, content) {
        ctx.font = `${30}px Ubuntu`;
		ctx.lineWidth = (30 / 5.0);
        ctx.textAlign = "center";
        ctx.strokeStyle = "#505050";
		ctx.strokeText(content, X, Y);
		ctx.fillStyle = "#EEEEEE";
		ctx.fillText(content, X, Y);
    }
    function kill(X, Y, content) {
        ctx.font = `${15}px Ubuntu`;
		ctx.lineWidth = (15 / 5.0);
        ctx.textAlign = "center";
        ctx.strokeStyle = "#505050";
		ctx.strokeText(content + " kills", X, Y + width * 9 / 4);
		ctx.fillStyle = "#EEEEEE";
		ctx.fillText(content + " kills", X, Y + width * 9 / 4);
    }
    function kills(X, Y, content, fontSize) {
        ctx.font = `${fontSize}px Ubuntu`;
		ctx.lineWidth = (fontSize / 5.0);
        ctx.textAlign = "left";
        ctx.strokeStyle = "#505050";
		ctx.strokeText(content, X, Y + width * 9 / 4);
		ctx.fillStyle = "#EEEEEE";
		ctx.fillText(content, X, Y + width * 9 / 4);
    }
    function achievement() {
        if(achievements[0] == 0 && lifetimeKills >= 500) {
            achieveBG(960, 270, 400, 80);
            name(960, 260, 'Achievement Unlocked', 35);
            name(960, 300, 'Starting Off', 30);
            setTimeout(() => {achievements[0] = 1;}, 2000);
        }
        if(achievements[1] == 0 && bronze.length > 0) {
             achieveBG(960, 270, 400, 80);
            name(960, 260, 'Achievement Unlocked', 35);
            name(960, 300, '3rd Place', 30);
            setTimeout(() => {achievements[1] = 1;}, 2000);
        }
        if(achievements[2] == 0 && silver.length > 0) {
            achieveBG(960, 270, 400, 80);
            name(960, 260, 'Achievement Unlocked', 35);
            name(960, 300, 'Finalist', 30);
            setTimeout(() => {achievements[2] = 1;}, 2000);
        }
        if(achievements[3] == 0 && gold.length > 0) {
            achieveBG(960, 270, 400, 80);
            name(960, 260, 'Achievement Unlocked', 35);
            name(960, 300, 'Got the Gold', 30);
            setTimeout(() => {achievements[3] = 1;}, 2000);
        }
        if(achievements[4] == 0 && diamond.length > 0) {
            achieveBG(960, 270, 400, 80);
            name(960, 260, 'Achievement Unlocked', 35);
            name(960, 300, 'SHIIINY', 30);
            setTimeout(() => {achievements[4] = 1;}, 2000);
        }
        if(achievements[5] == 0 && bronze.length > 9) {
            achieveBG(960, 270, 400, 80);
            name(960, 260, 'Achievement Unlocked', 35);
            name(960, 300, 'Generalist', 30);
            setTimeout(() => {achievements[5] = 1;}, 2000);
        }
        if(achievements[6] == 0 && silver.length > 9) {
            achieveBG(960, 270, 400, 80);
            name(960, 260, 'Achievement Unlocked', 35);
            name(960, 300, 'Tryhard', 30);
            setTimeout(() => {achievements[6] = 1;}, 2000);
        }
        if(achievements[7] == 0 && gold.length > 9) {
            achieveBG(960, 270, 400, 80);
            name(960, 260, 'Achievement Unlocked', 35);
            name(960, 300, 'Actually OP', 30);
            setTimeout(() => {achievements[7] = 1;}, 2000);
        }
        if(achievements[8] == 0 && diamond.length > 9) {
            achieveBG(960, 270, 400, 80);
            name(960, 260, 'Achievement Unlocked', 35);
            name(960, 300, 'Did You Cheat?', 30);
            setTimeout(() => {achievements[8] = 1;}, 2000);
        }
        if(achievements[9] == 0 && killCount >= 100) {
            achieveBG(960, 270, 400, 80);
            name(960, 260, 'Achievement Unlocked', 35);
            name(960, 300, 'Rampage', 30);
            setTimeout(() => {achievements[9] = 1;}, 2000);
        }
        if(achievements[10] == 0 && lifetimeKills >= 10000) {
            achieveBG(960, 270, 400, 80);
            name(960, 260, 'Achievement Unlocked', 35);
            name(960, 300, 'Dedicated', 30);
            setTimeout(() => {achievements[10] = 1;}, 2000);
        }
        if(achievements[11] == 0 && score > 1000000 && unsafeWindow.localStorage.gamemode != 'sandbox') {
            achieveBG(960, 270, 400, 80);
            name(960, 260, 'Achievement Unlocked', 35);
            name(960, 300, 'Dedicated v2', 30);
            setTimeout(() => {achievements[11] = 1;}, 2000);
        }
        if(achievements[12] == 0 && bronze.length > 27) {
            achieveBG(960, 270, 400, 80);
            name(960, 260, 'Achievement Unlocked', 35);
            name(960, 300, 'Go Outside', 30);
            setTimeout(() => {achievements[12] = 1;}, 2000);
        }
        if(achievements[13] == 0 && killList[4] > 500) {
            achieveBG(960, 270, 400, 80);
            name(960, 260, 'Achievement Unlocked', 35);
            name(960, 300, 'Troll', 30);
            setTimeout(() => {achievements[13] = 1;}, 2000);
        }
        if(achievements[14] == 0 && tank == 28) {
            achieveBG(960, 270, 400, 80);
            name(960, 260, 'Achievement Unlocked', 35);
            name(960, 300, 'Fat Overprot', 30);
            setTimeout(() => {achievements[14] = 1;}, 2000);
        }
    }
    function achieveBG(X, Y, length, width) {
        ctx.strokeStyle = '#75757580';
        ctx.fillStyle = '#99999980'
        ctx.lineWidth = 5;
        ctx.beginPath();
        ctx.strokeRect(X - length/2 - width/14, Y - 4*width/7, length+width/7, 8*width/7);
        ctx.fillRect(X - length/2 - width / 7, Y - width / 2 - width / 7, length + 2 * width / 7, 9 * width / 7);
    }
    function name(X, Y, content, fontSize) {
        ctx.font = `${fontSize}px Ubuntu`;
		ctx.lineWidth = (fontSize / 5.0);
        ctx.textAlign = "center";
        ctx.strokeStyle = "#000000";
		ctx.strokeText(content, X, Y);
		ctx.fillStyle = "#FFFFFF";
		ctx.fillText(content, X, Y);
    }
    achievement();
    drawTank(X,Y, tank);
    directory();
}


const canvas = document.createElement('canvas');
canvas.style.position = "fixed"
canvas.style.inset = "0"
canvas.style.zIndex = "9999999"
canvas.style.pointerEvents = "none"
document.body.appendChild(canvas)
const ctx = canvas.getContext('2d');
const rewards = [200, 500, 750, 2000, 2500, 2000, 5000, 10000, 15000, 500, 750, 1500, 5000, 1, 69];
const store = [5000, 7500, 7500, 10000, 2500, 5000, 7500, 10000, 5000, 7500, 10000];

const tankList = ['Overlord', 'Quad', 'Octo', 'Tri trapper', 'Mega', 'Spread', 'Penta', 'Booster', 'Hybrid', 'Annihilator', 'Manager', 'Factory', 'Necromancer', 'Predator', 'Rocketeer', 'Landmine', 'Fighter', 'Triplet', 'Triple Twin', 'Overtrapper', 'Battleship', 'Streamliner', 'Gunner Trapper', 'Auto 5', 'Sprayer', 'Ranger', 'Stalker', 'Skimmer'];
var a = 0, b = 1, killname = '', killprev = '', killCount = 0, killList = [], lifetimeKills = 0, counter = 0, skipList = [], achievements = [];
var fShop = [];
var mShop = [];
var cShop = [];
var round = 0, finalScore = 0;
var tankRed = 0, tankGreen = 177, tankBlue = 222, z,x,c, rRed = 0 , rGreen = 0, rBlue = 0;
var color = 0, cycle = 0, score = -1;
var bronze = [], silver = [], gold = [], diamond = [];
var X = 60, Y = 60;
var coins;
var save = unsafeWindow.localStorage;
var tank = 0, tankNum = 0, faceNum = 0, map = 0, mouthNum = 0, UIoption = 0, space = 7;
var mouseX = 0, mouseY = 0, downX, downY, angle = 0, autorotation = 0, invis = 255, hex;
if (unsafeWindow.localStorage.getItem('totalkills') >= 0) {
    lifetimeKills = unsafeWindow.localStorage.getItem('totalkills');
}
if (unsafeWindow.localStorage.getItem("diepcoins") > 0) {
    coins = parseInt(unsafeWindow.localStorage.getItem("diepcoins"));
}
else {coins = 0}
for (let t = 0; t < 5; t++) {
    if (unsafeWindow.localStorage.getItem("f"+t) > 0) {
        fShop[t] = unsafeWindow.localStorage.getItem("f"+t);
    }
    else {fShop[t] = 0}
    if (unsafeWindow.localStorage.getItem("m"+t) > 0) {
        mShop[t] = unsafeWindow.localStorage.getItem("m"+t);
    }
    else {mShop[t] = 0}
    if (unsafeWindow.localStorage.getItem("c"+t) > 0) {
        cShop[t] = unsafeWindow.localStorage.getItem("c"+t);
    }
    else {cShop[t] = 0}
}
for (let t = 0; t < 28; t++) {
    if (unsafeWindow.localStorage.getItem("tank"+t) > 0) {
        killList[t] = unsafeWindow.localStorage.getItem("tank"+t);
    }
    else {killList[t] = 0}
}
for (let t = 0; t < 15; t++) {
    if (unsafeWindow.localStorage.getItem("ach"+t) != null) {
        achievements[t] = parseInt(unsafeWindow.localStorage.getItem("ach"+t));
    }
    else {achievements[t] = 0}
}

function renderFrame() {
    window.requestAnimationFrame(renderFrame)
    canvas.width  = window.innerWidth;
    canvas.height  = window.innerHeight;
    ctx.clearRect(0, 0, canvas.width, canvas.height);
    if (score >= 0 && unsafeWindow.localStorage.gamemode != 'sandbox') {finalScore = score; round = -2 + 2^(finalScore/500000)*250;}
        autorotation = (autorotation + Math.PI / 150) % (4 * Math.PI);
        if (!(score >= 0)) {
            invis = Math.max(0, invis - 0.5);
            hex = invis.toString(16);
            if (invis < 16) {
                hex = "0" + hex;
            }
            hex = hex.substring(0,2);
        }
        rRed = Math.max(0, Math.cos(cycle * 2 * Math.PI / 768)*255);
        rGreen = Math.max(0, Math.cos(cycle * 2 * Math.PI / 768 + 4 * Math.PI / 3)*255);
        rBlue = Math.max(0, Math.cos(cycle * 2 * Math.PI / 768 + 2 * Math.PI / 3)*255);
        cycle = (cycle + 2) % 768
        tinyTanks();
}
renderFrame()

document.addEventListener('mousemove', (event) => {
    mouseX = event.clientX * devicePixelRatio;
    mouseY = event.clientY * devicePixelRatio;
});
document.addEventListener('mousedown', (e) => {
    downX = mouseX;
    downY = mouseY;
});

document.addEventListener("keydown", function(e) {
    if (e.which === 88) { // x
        map = 1 - map;
    }
    if (e.keyCode === 65 || e.keyCode === 68 || e.keyCode === 83 || e.keyCode === 87) { // movement
        invis = Math.min(255, invis+24)
    }
});

CanvasRenderingContext2D.prototype.fillText = new Proxy(CanvasRenderingContext2D.prototype.fillText, {
    apply(fillRect, ctx, [text, x, y, ...blah]) {
        if(text.startsWith("Lvl")) {
            for (let n = 0; n < 28; n++) {
                if (text.includes(tankList[n])) {
                    tankNum = n;
                }
            }
        }

        if (text.startsWith("You've killed ") && unsafeWindow.localStorage.gamemode != 'sandbox') {
            killname = text;
            if(skipList.indexOf(killname) == -1) {
                lifetimeKills++; killCount++; killList[tankNum]++; skipList += killname;setTimeout(() => {skipList = []}, 75000)
            }
        }
        if (text.startsWith("Score:")) {
            score = parseFloat(text.slice(7).replace(',', ''));
        }
        fillRect.call(ctx, text, x, y, ...blah);
    }
});
setInterval(() => {
    for (let t = 0; t < 28; t++) {
        unsafeWindow.localStorage.setItem("tank"+t, killList[t]);
        if (killList[t] >= 200 && bronze.indexOf(t) == -1) {
            bronze.push(t);
        }
        if (killList[t] >= 500 && silver.indexOf(t) == -1) {
            silver.push(t);
        }
        if (killList[t] >= 1500 && gold.indexOf(t) == -1) {
            gold.push(t);
        }
        if (killList[t] >= 5000 && diamond.indexOf(t) == -1) {
            diamond.push(t);
        }
    }
    for (let t = 0; t < 15; t++) {
        unsafeWindow.localStorage.setItem("ach"+t, parseInt(achievements[t]));

    }
    for (let t = 0; t < 5; t++) {
        unsafeWindow.localStorage.setItem("f"+t,fShop[t]);
        unsafeWindow.localStorage.setItem("m"+t,mShop[t]);
        unsafeWindow.localStorage.setItem("c"+t,cShop[t]);
    }
    unsafeWindow.localStorage.setItem('totalkills', lifetimeKills);
    unsafeWindow.localStorage.setItem("diepcoins", coins);
        if(achievements[0] == 0 && lifetimeKills >= 500) {
            coins = coins + rewards[0]
        }
        if(achievements[1] == 0 && bronze.length > 0) {
            coins = coins + rewards[1]
        }
        if(achievements[2] == 0 && silver.length > 0) {
            coins = coins + rewards[2]
        }
        if(achievements[3] == 0 && gold.length > 0) {
            coins = coins + rewards[3]
        }
        if(achievements[4] == 0 && diamond.length > 0) {
            coins = coins + rewards[4]
        }
        if(achievements[5] == 0 && bronze.length > 9) {
            coins = coins + rewards[5]
        }
        if(achievements[6] == 0 && silver.length > 9) {
            coins = coins + rewards[6]
        }
        if(achievements[7] == 0 && gold.length > 9) {
            coins = coins + rewards[7]
        }
        if(achievements[8] == 0 && diamond.length > 9) {
            coins = coins + rewards[8]
        }
        if(achievements[9] == 0 && killCount >= 100) {
            coins = coins + rewards[9]
        }
        if(achievements[10] == 0 && lifetimeKills >= 10000) {
            coins = coins + rewards[10]
        }
        if(achievements[11] == 0 && score > 1000000 && unsafeWindow.localStorage.gamemode != 'sandbox') {
            coins = coins + rewards[11]
        }
        if(achievements[12] == 0 && bronze.length > 27) {
            coins = coins + rewards[12]
        }
        if(achievements[13] == 0 && killList[4] > 500) {
            coins = coins + rewards[13]
        }
        if(achievements[14] == 0 && tank == 28) {
            coins = coins + rewards[14]
        }
}, 2000);