game coord conversion to be display on map

Modding school: Learn it from the masters
Post Reply
victorsmits
Posts: 1
Joined: 03 May 2020 09:41

03 May 2020 09:55

high everyone, I am trying to make a map like ets2map.com for a private ETS RP competition, I successfully found the map (download the tiles from the game) but now I am trying to localize the player on the map via the tracker we developed, the issue that I encounter is that I am not able to transform game coord into screen coord to be displayed. does anyone have an idea how to do that?

I already try to use the transformation available on ETS forum but it is not working as the map he is using is too old.
there is the code I try

Code: Select all


    const EU = {
        x: 24864.00284,
        y: 41034.36648
    }

    const UK = {
        x: 10226,
        y: 9826
    }

    // Based on http://forum.scssoft.com/viewtopic.php?f=41&t=186779
    function calculatePixelCoordinate(x, y, pointsPerPixel, x0, y0) {
        return [
            (x / pointsPerPixel + x0) | 0,
            (y / pointsPerPixel + y0) | 0
        ];
    }

    function calculatePixelCoordinateEu(x, y) {
        return calculatePixelCoordinate(x, y, 7.278, EU.x, EU.y);
    }

    function calculatePixelCoordinateUk(x, y) {
        return calculatePixelCoordinate(x, y, 9.69522, UK.x, UK.y);
    }

    function game_coord_to_pixels(x, y) {
        // http://forum.scssoft.com/viewtopic.php?p=402836#p402836
        if (x < -31812 && y < -5618) {
            return calculatePixelCoordinateUk(x, y);
        } else {
            return calculatePixelCoordinateEu(x, y);
        }
    }

Thank you :D



Post Reply

Return to “ProMods Academy”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 1 guest