First HUD !

Hello Guys , Yesterday I Finish 80% My First Hud for my FIRST ! GameMode But I Detect The Most BIG Bug Ever :frowning:

I Invite a Friend to Check My Hud … and he said: ( its weird , ) and i said: oO ? really ? well and i notice something:

My Computer Screen Picture:

My Friend Computer Screen Picture:
( i do not include the RoundedBox , so do not talk about this , just talk about the large of the hud … and why is not center )

Sorry for my bad spelling :slight_smile:

You’re positioning HUD stuff based on your screen resolution. You should make it relative to the screen’s resolution using ScrW() and ScrH().

an example of how i can use

ScrW() and ScrH()


Say your resolution was 1600x900

Instead of using 1600 and 900 in your code, you would use ScrW() and ScrH(). They would return 1600 and 900, or whatever resolution is currently running

[lua]-- Old:
surface.DrawRect(0, 0, 1600, 900) – Big square on the entire screen on 1600x900 res

– New:
surface.DrawRect(0, 0, ScrW(), ScrH()) – Big square on the entire screen on any res

an example of my code its going to be like:

draw.RoundedBox(8, 4, 2, ScrW(), ScrH(), Color(150,150,150,255)) -- ( White Background )
draw.RoundedBox(8, 8, 5, ScrW(), ScrH() Color(50,50,50,255)) -- ( Black Background )

and example of how i can put this with ScrW() and ScrH() ? Thanks :slight_smile:

For the 1430, I assume that’s the entire width subtracted by 4? So you could do ScrW() - 4.

but also if i put:

draw.RoundedBox(8, 4, 2, ScrW(), ScrH(), Color(150,150,150,255)) – ( White Background )
draw.RoundedBox(8, 8, 5, ScrW(), ScrH() Color(50,50,50,255)) – ( Black Background )

get all my screen ScrW & ScrH but if i want to substract like 100 to align for my screen , its not going to be aligned to other user screen. like if i put ScrW()-50 ( Its going to be for the user screen and mine’s but if in mine’s looks good in a user who have a little Screen , its going to be little or glitched

ScrW() * 0.5

[editline]30th July 2012[/editline]

Wait what? If you want something to be relevant to the person, just divide/multiply the ScrW()/ScrH() function.

draw.RoundedBox(8, 8, 5, (ScrW()-18), (ScrH()*0.1-76), Color(50,50,50,255)) – Black Bar
this is the same for everybody ?

If you want it to be centered, then you just subtract double of your margin.

[lua]draw.Roundedbox(8, 4, 2, ScrW(), ScrH(), Color(150, 150, 150, 255))[/lua]

4 margin to the left = subtract 8 from ScrW()
2 margin to the top = subtract 4 from ScrH()

Keep in mind though if you’re trying to replicate the bar at the top of your screen you don’t need to use all of ScrH(). That should be relative to the size of the font you use. Looks like you’d need to replace ScrH() with 20 or so.

Edit: You need to do something different than (ScrH()*.1-76). Given an extreme case of 640x480, 10% of that is 48 - 76 gives you a negative number.

Can you help me to code the hud :S i have been trying this for 09485034 hours lol u.u

i just need to finish my hud , and then i code some functions for the gamemode , but the hud is really annoying for me =S

if you can help me with the hud ! =)

add me STEAM_0:0:20370318


I’ll help you. I won’t be available until later tomorrow though.

You add me.

I know it’s nit picky but please turn on Anisotropic Filtering when taking screenshots

Question: now i code my lines using ScrW() + ScrH() but i want to ask something really important for me:

If i want to make this using global values ( i mean to fit all the user’s screen’s )

well… when i code the main bar i use values like:

    draw.RoundedBox(4, 0, 0,(ScrW()*0.999), (ScrH()*0.024), Color(150,150,150,255))

( as you can see , i use values in: 0,0 ( paste to the wall of the screen ) , but how i can put a global value like ScrW or ScrH , to center the " hud " like on the picture that i POST ?

Thanks !