diff options
Diffstat (limited to 'gamemode/client/healthbar.lua')
| -rw-r--r-- | gamemode/client/healthbar.lua | 58 |
1 files changed, 52 insertions, 6 deletions
diff --git a/gamemode/client/healthbar.lua b/gamemode/client/healthbar.lua index d9a050c..67a3090 100644 --- a/gamemode/client/healthbar.lua +++ b/gamemode/client/healthbar.lua @@ -35,9 +35,14 @@ function draw.DrawElipse(x,y,radius,elong,rotation) surface.DrawPoly( cir ) end +local width,height = ScrW(),ScrH() +local padding = height / 32 +local barheight = height / 16 +local bubbles = {} local blobs = {} local lastpos = 0 -local delpoint = ScrH() +local bubbleradius = height/64 +local delpoint = height hook.Add( "Tick", "Hudpaintbloodtick",function() for k,v in pairs(blobs) do if v.y > delpoint then @@ -51,15 +56,32 @@ hook.Add( "Tick", "Hudpaintbloodtick",function() } end end + for k,v in pairs(bubbles) do + if v.y < height - padding - barheight -bubbleradius then + bubbles[k] = nil + else + local subheight = v.y - (1.5 + math.sin((v.y/4) + (v.x*10)))/5 + bubbles[k].y = subheight + end + end end) local lasthealth -local width,height = ScrW(),ScrH() -local padding = height / 32 -local barheight = height / 16 local obarlength = width / 4 local barlength = obarlength local xs,ys = padding,height - padding - barheight +local bubblespawnrate,bubblespawnchance = 1,0.7 + +timer.Create("Healthbar_bubble_timer",bubblespawnrate,0,function() + if math.random() < bubblespawnchance then + local newbubble = { + ["x"] = math.random(xs + bubbleradius,barlength-bubbleradius), + ["y"] = height - padding + bubbleradius + } + table.insert(bubbles,newbubble) + end +end) + hook.Add( "HUDPaint", "HUD_DrawHealth", function() --Spawn a bunch of blobs if our health has changed @@ -87,14 +109,38 @@ hook.Add( "HUDPaint", "HUD_DrawHealth", function() end lasthealth = health end - --Draw the current health thing + --Background surface.SetDrawColor(100,100,100,100) surface.DrawRect( xs, ys, obarlength, barheight) + --Foreground surface.SetDrawColor( 150, 0, 0, 255 ) surface.DrawRect( xs, ys, barlength, barheight ) + --Heighlighting/shadows + local heighlightheight = barheight/3 + for k = 1, heighlightheight do + local perc = Lerp(k/heighlightheight,100,0) + surface.SetDrawColor( 150+perc, perc, perc, 255) + surface.DrawRect( xs, ys+k, barlength, 1) + end + for k = 1, heighlightheight do + local perc = Lerp(k/heighlightheight,0,100) + surface.SetDrawColor( 150 - perc, 0, 0, 255) + surface.DrawRect(xs, ys+k+(2*heighlightheight), barlength, 1) + end + + --Draw bubbles + render.SetScissorRect( xs, ys, xs + barlength, ys + barheight, true ) -- Enable the rect + surface.SetDrawColor(250,150,150,10) + for k,v in pairs(bubbles) do + surface.DrawCircle(v.x,v.y,bubbleradius,250,150,150,30) + draw.DrawElipse(v.x,v.y,bubbleradius,1,0) + end + render.SetScissorRect( 0, 0, 0, 0, false ) -- Disable after you are done + --Draw the animation for blobs + surface.SetDrawColor(150,0,0,255) for k,v in pairs(blobs) do --Elongation is based on velocity local elong = (v.yv^2 + v.xv^2)^0.5 @@ -102,6 +148,6 @@ hook.Add( "HUDPaint", "HUD_DrawHealth", function() elong = math.Clamp(elong,1,3) --Rotation is also based on velcotiy local rot = math.deg(math.atan(v.yv/v.xv)) - draw.DrawElipse(v.x,v.y,10/elong,elong,rot) + draw.DrawElipse(v.x,v.y,10/elong,elong, rot) end end ) |
