package  
{
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import interfaces.IGameObject;
	
	/**
	 * ...
	 * @author Fiodar Paulavets
	 */
	public class Brush extends Sprite implements IGameObject 
	{		
		private var _speed: Number;
		public var front: Boolean;
		
		public function Brush() 
		{			
			var clip: MovieClip;
			var r: uint = Math.round(Math.random() * 4);
			var ky: Number = Math.random();
			if (ky >= 0.8)
				front = true;
			else
				front = false;
			switch (r)
			{
				case 0: clip = new Brush1Clip(); break;
				case 1: clip = new Brush2Clip(); break;
				case 2: clip = new Brush3Clip(); break;
				case 3: clip = new Brush4Clip(); break;
				case 4: clip = new Brush5Clip(); break;
			}
			if (!front)
				clip.scaleX = clip.scaleY = 0.4 + Math.random() * 0.6;
			else
				clip.scaleX = clip.scaleY = 0.8 + Math.random() * 0.5;
			addChild(clip);
			
			x = Game.screenWidth + Math.random() * 70;
			y = 390 + ky * 110;
			if (front)
				y = Game.screenHeight - clip.height + Math.random() * clip.height / 2;
			
			_speed = 70;
			_speed = _speed / 2 * (1 + ky);
		}
		
		/* INTERFACE interfaces.IGameObject */
		
		public function Update(dt:Number):void 
		{
			x -= _speed * dt;
			
			if (x + width < 0)
				if (!front)
					World.world.backBrushes.remove(this);
				else
					World.world.frontBrushes.remove(this);
		}
		
	}

}