(function(window){	function Spaceship(image)	{		this.image	= image;		this.initialize();	}	Spaceship.prototype = new Container();		Spaceship.prototype.bullit	= new Shape();		Spaceship.prototype.maxVelocity		= 15;		Spaceship.prototype.vX				= 0; 	// Velocity (in/de)crement		Spaceship.prototype.acceleration	= 1;		Spaceship.prototype.boundry			= null;	// Rectangle "within the Spaceship can move"		Spaceship.prototype.offset			= new Point();		Spaceship.prototype.reloadDelay	= 500;		Spaceship.prototype.reloading	= false;		Spaceship.prototype.reloadTimer	= null;		Spaceship.prototype.width		= 0;		Spaceship.prototype.height		= 0;		Spaceship.prototype.bullitColor	= '#9ad900';	// TODO: some color picking stuff...?!		Spaceship.prototype.shipColor	= '#000';		// Signals		Spaceship.prototype.shotFired	= new signals.Signal();		Spaceship.prototype.hit			= new signals.Signal();		// Constructor:		Spaceship.prototype.Container_initialize = Spaceship.prototype.initialize;	// Unique to avoid overiding base class		/**		* INIT METHODS		*/		Spaceship.prototype.initialize = function()		{			this.Container_initialize();			this.addChild(new Bitmap(this.image));			this.width		= this.image.width;			this.height		= this.image.height;			this.boundry	= new Rectangle(0, 0, Registry.get('STAGE_WIDTH') - this.width, this.height);			this.drawBullit();			this.addChild(this.bullit);		}		Spaceship.prototype.drawBullit = function()		{			this.bullit.x	= this.width * 0.92; // TODO: Quickfix, 'cause we know the i-dot is 92% to the right... ;)			this.bullit.graphics.clear();			this.bullit.graphics.beginFill(this.bullitColor);			this.bullit.graphics.drawCircle(-3,3,6);			this.bullit.graphics.endFill();		}		/**		* MOVEMENT METHODS		*/		Spaceship.prototype.moveLeft = function()		{			this.vX	= Math.max(this.vX - this.acceleration, -this.maxVelocity);			this.move();		}		Spaceship.prototype.moveRight = function()		{			this.vX	= Math.min(this.vX + this.acceleration, this.maxVelocity);			this.move();		}		Spaceship.prototype.slowDownAndBreak = function()		{			if(this.vX > 0)			{				this.vX	= Math.max(this.vX - this.acceleration, 0);				this.move();			}			else if(this.vX < 0)			{				this.vX	= Math.min(this.vX + this.acceleration, 0);				this.move();			}		}		Spaceship.prototype.move = function()		{			var _x	= this.x + this.vX;			if(_x < 0)			{				this.vX	= 0;				this.x	= 0;			}			else if(_x > this.boundry.width)			{				this.vX	= 0;				this.x	= this.boundry.width;			}			else			{				this.x	= _x;			}		}		/**		* SHOOTING METHODS		*/		Spaceship.prototype.shoot = function()		{			if(this.reloading === false)			{				this.bullit.graphics.clear();				this.shotFired.dispatch();				this.reload();			}		}		Spaceship.prototype.reload = function()		{			this.reloading	= true;			if(!this.reloadTimer)			{				var _this			= this;				this.reloadTimer	= new Timer(this.reloadDelay, 1);				this.reloadTimer.TIMER.add(function() { _this.onReloadCompleted(); });			}			this.reloadTimer.reset();			this.reloadTimer.start();		}		Spaceship.prototype.onReloadCompleted = function()		{			this.reloading	= false;			this.drawBullit();		}		/**		* DESTROY METHODS		*/		Spaceship.prototype.disable = function()		{			this.shotFired.removeAll();			this.hit.removeAll();			if(this.reloadTimer)			{				this.reloadTimer.dispose();				this.reloadTimer	= null;			}			this.drawBullit();		}		/**		* HITTEST METHODS		*/		Spaceship.prototype.checkForHit = function(bullit)		{			if(bullit && bullit.x >= this.x && bullit.x <= this.x + this.width && bullit.y >= this.y && bullit.y <= this.y + this.height) this.hit.dispatch(bullit);		}		/**		* RESET METHODS		*/		Spaceship.prototype.reset = function()		{			this.visible	= true;			this.x			= this.offset.x;			this.y			= this.offset.y;			this.reloading	= false;		}		/**		* SETTERS/GETTERS		*/		Spaceship.prototype.bullitPosition = function()		{			return this.bullit.x;		}	window.Spaceship = Spaceship;}(window));
