Calculating on screen X, Y from world coords
#1

Hey, I'm trying to figure out how this would be possible to do, but I have no idea.

I have a map created of textdraws and then red marker, which should display position on the map according to world X Y coordinates.

Does anybody have idea how could I calculate marker position by world X Y?

On screen red marker positions are here X=426.500000 and Y=317.200000
Reply
#2

You need to find out the width and height of your scaled map. Then divide those values by 6000 to get the scaled value of 1 meter, e.g. if you map is 600 pixels wide then 1 meter corresponds to 0.1 pixel. Once you have that value you take the actual world coordinates, add 3000 (because the game map reaches from -3000 to 3000 but the scaled map reaches 0 to 6000) and then you multiply those values with the baseline value of 0.1.
Reply
#3

Okay, tried to make it as you said, but sadly point is being shown far away from where it should be.

pawn Код:
new
    Float:scalex = 243.6 / 6000, //243.6 is the width
    Float:scaley = 264.0 / 6000, //264 is the height
    Float:screenx = MDC_g_sPlayer[playerid][E_MDC_LOOKUP_ACTIVE_ADRESS_POS][0] + 3000, //Real world X + 3000
    Float:screeny = MDC_g_sPlayer[playerid][E_MDC_LOOKUP_ACTIVE_ADRESS_POS][1] + 3000 //Real world Y + 3000
;
                       
MDC_g_sPlayer[playerid][E_MDC_TEXTDRAW][33] = CreatePlayerTextDraw(playerid, screenx * scalex, screeny * scaley, "hud:radar_waypoint");
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)