Jump to content

Calculating dxDraws


Wei

Recommended Posts

I am scripting for like realy long time, and I still don't understand how to calculate dx draws for all resolutions ?

like i want a reactangle at 300 300 300 300 at my resolution (1024/768). How would I make that player wich has bigger resolution would have in same place? (it would be more than 300)

Thanks,

Wei

Link to comment

in fact, the question is stated incorrectly. The player will have the rectangle at 300,300 with any resolution, but if you mean you want to scale it, you could easily do it like that:

local sx,sy = 300,300 -- Your size 
local px,py = 300,300 -- Your position 
local x,y = guiGetScreenSize() -- Get the resolution of the player 
local scale = y/768 -- Scale to your screen height (Divide by some smaller value to make it scale more, divide by bigger value to scale less) I divided it by your screen height so the scale is 1 for you and it changes for other players depending on their resolution. 
sx,sy = sx*scale,sy*scale -- Calculate the absolute size depending on the resolution. 
px,py = px*scale,py*scale -- Calculate the position as well. 

I suggest to always scale by the screen height as it is never bigger than the screen width, so the image/rectangle/whatever won't get out of the box.

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...