🎉 欢迎访问GreasyFork.Org 镜像站!本镜像站由公众号【爱吃馍】搭建,用于分享脚本。联系邮箱📮

Greasy fork 爱吃馍镜像

Diep.io Bullet Tracker (Enhanced)

Tracks and visualizes bullets in Diep.io for collision detection

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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         Diep.io Bullet Tracker (Enhanced)
// @namespace    http://tampermonkey.net/
// @version      1.2
// @description  Tracks and visualizes bullets in Diep.io for collision detection
// @author       King's Group
// @author       David Bett
// @match        *://diep.io/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // Create canvas overlay
    const canvas = document.createElement('canvas');
    canvas.style.position = 'absolute';
    canvas.style.top = '0';
    canvas.style.left = '0';
    canvas.style.pointerEvents = 'none';
    canvas.style.zIndex = '9999';
    document.body.appendChild(canvas);
    const ctx = canvas.getContext('2d');

    function resizeCanvas() {
        canvas.width = window.innerWidth;
        canvas.height = window.innerHeight;
    }
    window.addEventListener('resize', resizeCanvas);
    resizeCanvas();

    // Function to detect if a bullet is near the player
    function isBulletNearPlayer(bullet, player, threshold = 100) {
        const dx = bullet.x - player.x;
        const dy = bullet.y - player.y;
        const distance = Math.sqrt(dx * dx + dy * dy);
        return distance < threshold;
    }

    // Main drawing function
    function draw() {
        ctx.clearRect(0, 0, canvas.width, canvas.height);

        // Accessing game variables
        const player = window.player; // Assuming 'window.player' holds the player's position
        const bullets = window.bullets; // Assuming 'window.bullets' is an array of bullet objects

        if (!player || !bullets) return;

        // Draw safe zone around player
        ctx.strokeStyle = 'green';
        ctx.lineWidth = 2;
        ctx.beginPath();
        ctx.arc(player.x, player.y, 50, 0, Math.PI * 2);
        ctx.stroke();

        // Draw bullets
        bullets.forEach(bullet => {
            // Check if bullet is near the player
            const isNear = isBulletNearPlayer(bullet, player);

            ctx.fillStyle = isNear ? 'red' : 'white';
            ctx.beginPath();
            ctx.arc(bullet.x, bullet.y, 5, 0, Math.PI * 2);
            ctx.fill();

            // Update bullet position
            bullet.x += bullet.dx;
            bullet.y += bullet.dy;
        });

        requestAnimationFrame(draw);
    }

    draw();
})();