HUD help

Alright so when I was working on the Hud for a gamemode I ran into a problem when the health or armor = 0 it looks like this

I want to know how to fix it so it doesn’t look like that when you have no armor.




function hud() 
local health = LocalPlayer():Health()
local armor = LocalPlayer():Armor() 
	draw.RoundedBox(15,0,ScrH() - 220,650,220,Color(0,102,0))
	surface.SetDrawColor( 255, 255, 255, 255 )
	
	// Health
	draw.RoundedBox(15, ScrW() - 1200, ScrH() - 80,100 * 1.8, 30, Color( 250, 0, 0, 100 ) )
	draw.RoundedBox(15,ScrW() - 1200,ScrH() - 80,health * 1.8,30,Color(255,0,0))
	draw.DrawText( "Health", "TargetID", ScrW() - 1120, ScrH() - 75, Color( 0, 0, 0, 250 ), TEXT_ALIGN_CENTER )
	
	//Armor
	draw.RoundedBox(15, ScrW() - 900, ScrH() - 80,100 * 1.8, 30, Color( 0, 0, 250, 100 ) )
	draw.RoundedBox(15,ScrW() - 900,ScrH() - 80,armor,30,Color(0,0,250))
	draw.DrawText( "Armor", "TargetID", ScrW() - 720, ScrH() - 75, Color( 0, 0, 0, 250 ), TEXT_ALIGN_CENTER )
	
end 
hook.Add("HUDPaint", "thehud", hud) 




Check if the players health and armor is less than or equal to 0, then draw the rounded boxes.

I think it’s doing that because the RoundedBox has corners that are simply images, so when the size of the box is low, the images overlap and look really weird. The easiest solution would probably be to just check if the player’s armor is less than 0, and if it is, don’t draw that box.

[editline]17th April 2016[/editline]

ninja’d

[editline]17th April 2016[/editline]

Or you could reduce the amount of edge-roundedness depending on how little armor/health the player has

[editline]17th April 2016[/editline]

You might also want to center your text a little better, which you could do by dividing the box’s width and height by 2 and adding that to the text coordinates

Ya, the box is too rounded