HUD Item Placement

I am working with hud elements and mass confused about how you get them to look relatively the same on different resolutions, I am sure it is simple to do but I am having a hard time understanding it fully.

Here is what I am working on, I am having trouble with the placement of the main ammo box, it always seems to be 1 pixel off no matter what I try. Do I need to make all the numbers multiples of eachother to achieve perfection? It also seems to shrink alot on lower resolutions :frowning:
[lua]
function PaintHUD( )
//Check Player Status
if LocalPlayer():Alive() && LocalPlayer():IsValid() then
//Draw Main Box Area
draw.RoundedBox( 0, 4, ( ScrH() - 92 ), ( ScrW() / 7 ) - 1, 88, Color( 0, 0, 0, 200 ) )

	//Draw Main Health Box
	draw.RoundedBox( 0, 8, ( ScrH() - 88 ), ( ScrW() / 15 ), 80, Color( 130, 130, 130, 210 ) )
	
	//Draw Main Ammo Box
	draw.RoundedBox( 0, ( ScrW() / 13 ) - 1, ( ScrH() - 88 ), ( ScrW() / 15 ), 80, Color( 130, 130, 130, 210 ) )
	
	//Draw Main Health Text
	draw.SimpleText( "Health", "ScoreboardText", ScrW() / 44, (ScrH() - 85 ), Color(255, 255, 255, 255) )
	
	//Draw Main Ammo Text
	draw.SimpleText( "Ammo", "ScoreboardText", ( ScrW() / 11 ) + 4, (ScrH() - 85 ), Color(255, 255, 255, 255) )
end

end
hook.Add(“HUDPaint”,“PaintHUD”, PaintHUD )
[/lua]

You’ve got the right idea by using ScrW() and ScrH(). Honestly, getting it to look just right is a matter of guess and check (you get the feel for it after HUD-ing a lot). You don’t need multiples, just good placement.

Thanks for the tips, after messing with it some more I found out that removing more than half of the scrH and scrW calculations actually made it alot easier to position using hard coded numbers.

Consider using G.CreateClientConVar and G.GetConVarNumber to make realtime adjustments to your HUD when designing.

Ehh, I just do this:

  1. Open console
  2. lua_openscript_cl <your script>
  3. Look at it, see what you need to change
  4. Alt-tab to NP++, edit, save, alt-tab to gmod
  5. tilde -> up arrow -> enter -> tilde -> step 3

I do the same entoros but I bound it to a key for fast access, working in window mode helps alot too :smiley: