Jump to content

custom radar with dxDrawImageSection


JeViCo

Recommended Posts

Hello everyone! How can i make minimap using custom image?

I made something like this:

local radarX, radarY, radarWidth, radarHeight = 120, 420, 258, 128
local x, y = getElementPosition(localPlayer)
local mapsize = 3072
--print(x)
dxDrawImageSection(radarX, radarY, radarWidth, radarHeight, x/6000, y/-6000, 270, 270, "files/radar_map.jpg")

I know that gta sa's map size is 6000x6000 and my image resolution is 3072x3072. I can't understand what to do right now

Link to comment
  • Discord Moderators

Its -3072 - 3072, so its 3072*2 so its 6144.
And please, create a texture for the radar with dxCreateTexture with textureFormat = "dxt3", otherwise the radar itself, just to draw the image will eat 8-10-% CPU.
 

function getMapCoordsFromWorldCoords(x, y, imgSize)
    imgSize = imgSize or 3072
    return ((x + 3072) / 6144) * imgSize, (-(y - 3072) / 6144) * imgSize
end

With this function you can get the 2D coords on the map from world position.
For zoom you need to make the image smaller(zoom in) or bigger(zoom out).
I hope I helped you :)

If it returns inaccurate positions use this function instead:
 

function getMapCoordsFromWorldCoords(x, y, imgSize)
    imgSize = imgSize or 3072
    return ((x + 3000) / 6000) * imgSize, (-(y - 3000) / 6000) * imgSize
end

The way I did it was, that I got the position from this function, then i subbed usize/2, vsize/2.
So i got the U and V.
The size'll be usize and vsize.
I have a lot of hard work, and time in figuring this out, so, I'll not tell every "secret". 
Think a little bit. :)

Edited by Pirulax
  • Thanks 1
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...