rendered paste bodyfunction GM:DrawSpeedo( player, size )
local melon = player:GetNetworkedEntity(MELON)
local height = ScrH()
local size = size * 0.7
if !melon:IsValid() then return end
local speed = mathx.Clamp( math.abs( melon:GetVelocity():Length() ) / 1500, 0, 1 )
local distance = speed/180
self.Distance = self.Distance + distance
//Make the speed an average of the last few frames (stops the needle jumping around so much)
table.insert(self.OldSpeed,1,speed)
self.OldSpeed[17] = nil
speed = 0
for _,v in pairs(self.OldSpeed) do
speed = speed + v
end
speed = speed * 0.0625
//Draw stuff
//Odeometer background
surface.SetDrawColor( 0, 0, 0, 255 )
surface.DrawRect( ( height / 8 ) - ( size / 4 ) + 4, height - ( size/2 ) - 4, size/2, size/4 )
//Odeometer text
distance = string.format("%07.1f", self.Distance)
local align = draw.TEXT_ALIGN_RIGHT
draw.SimpleText( distance, "OdeometerText", 4 + (size * 0.65), height - ( size * 0.35375 ) - 4, Color( 255, 255, 255, 200), align )
//Dial
surface.SetDrawColor( 255, 255, 255, 255 )
surface.SetTexture( self.textures[ "Dial" ] )
surface.DrawTexturedRect( 4, height - size - 4, size, size )
//Needle shadow
surface.SetDrawColor( 32, 32, 32, 100 )
surface.SetTexture( self.textures[ "Needle" ] )
surface.DrawTexturedRectRotated( ( size / 2 ) + (size / 48), height - ( size / 2 ) - 4 + (size / 48), size / 32, size, 120 - speed * 250 )
//Needle
surface.SetDrawColor( 200, 100, 0, 255 )
surface.DrawTexturedRectRotated( ( size / 2 ) + 4, height - ( size / 2 ) - 4, size / 32, size, 120 - speed * 250 )
end