

/*---------------------------------------------------------
   Name: Initialize
---------------------------------------------------------*/
function ENT:Initialize()
	
	// We don't draw a model, we draw a golf ball sprite
	self.BallMaterial = Material( "gamemodes/crazygolf/golfball" )
	self.Entity:SetCollisionBounds( Vector( -16, -16, -16 ), Vector( 16, 16, 16 ) )
	
	local i = math.random( 0, 3 )
	
	if ( i == 0 ) then
		self.Color = Color( 255, 0, 0, 255 )
	elseif ( i == 1 ) then
		self.Color = Color( 0, 255, 0, 255 )
	elseif ( i == 2 ) then
		self.Color = Color( 255, 255, 0, 255 )
	else
		self.Color = Color( 0, 0, 255, 255 )
	end
	
	Msg("Initialize Test Ball\n")
	
end


/*---------------------------------------------------------
   Name: DrawPre
---------------------------------------------------------*/
function ENT:Draw()
	
	local pos = self.Entity:GetPos()
	local vel = self.Entity:GetVelocity()
		
	render.SetMaterial( self.BallMaterial )
	
	local lcolor = render.GetLightColor( pos ) * 2
	lcolor.x = mathx.Clamp( lcolor.x, 0, 1 )
	lcolor.y = mathx.Clamp( lcolor.y, 0, 1 )
	lcolor.z = mathx.Clamp( lcolor.z, 0, 1 )
//	lcolor:Normalize()
		
	// Fake motion blur
	for i=1,10 do
		local col = Color( self.Color.r*lcolor.x, self.Color.g*lcolor.y, self.Color.b*lcolor.z, 200/i )
		render.DrawSprite( pos + vel*(i*-0.005), 32, 32, col )
	end
		
	render.DrawSprite( pos, 32, 32, Color( self.Color.r*lcolor.x, self.Color.g*lcolor.y, self.Color.b*lcolor.z, self.Color.a ) )
	


end

include('shared.lua')