AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   player origin / map width / map height (https://forums.alliedmods.net/showthread.php?t=9653)

lady_in_red 01-26-2005 09:24

player origin / map width / map height
 
ok my script gets this :

get_user_origin(player[i],pos,0)

i get the x,y,z coord for the player in the pos array, but i need to map this values to a 1024x768 image (or any other size) ... but im confused geting negative values for y ... plz help me map the coord in game with the cood on image(x,y) :cry:

Twilight Suzuka 01-26-2005 15:21

Well, you need to use a coordinate plane for your image. You do this by declaring an arbitrary place in the picture 0,0. It should be the exact middle of the picture you want. Lets say the REAL value is 400,300, for an 800 by 600 image.

Now, this could be like a constant;
new const fakecenter_x = 400
new const fakecenter_y = 300

Ok, so you have the exact center, and your fake center, stored into a constant.

Now its relatively easy to do calculations for this picture!
lets say you want to map the dot (100,-100)
Well, you do all you have to do to send the dot, and the coordinates for where you would send it are as follows:
new send_x = fakecenter_x + 100
new send_y = fakecenter_y + (-100)

Then, send_x and send_y are where the dot should be in the picture.

Why does this work? Since the fakecenter is really the actual center, subtracting or adding to it will work as if it was a cartisian grid, just like HL.

You'll have to work out how to do Z's though.... Dont ask me on that one.

So, essentially, this is what you'll have to do:

// globals
new const fakecenter_x = 400
new const fakecenter_y = 300

public grid_it(x,y){
x += fakecenter_x
y += fakecenter_y
return 1;
}

and that should change the HL origins into something you can use with an image.
change the constants for different image sizes.


All times are GMT -4. The time now is 19:22.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.