//----------------------------------------------------
function Player(px, py, pid, pDivReference){
//----------------------------------------------------
	this.base=ScreenObject;
	this.base(px,py,"player",pid,32,32,pDivReference,"man.gif");

	this.status=1;
	this.lives=0;
	this.score=0;
	
	this.xspeed = 15;
	this.yspeed = 15;
	this.xvelocity = 0;
	this.yvelocity = 0;
	
	this.xdir = 0;
	this.ydir = 0;
	this.facing = kRight;
	this.oldXdir = 0;
	this.oldYdir = 0;
	
 	this.counter1 = 0;
	this.threshold1 = 0;
	this.threshold2 = 0;
	
	this.init();
	
	this.move = function(){
		if(this.xdir!=this.oldXdir&&this.xdir!=0){this.xvelocity=0-this.xvelocity;};
		if(this.ydir!=this.oldYdir){this.yvelocity=10;};
		if(this.xvelocity>this.xspeed){this.xvelocity=this.xspeed};
		if(this.yvelocity<0){this.ydir=0;this.yvelocity=0;}	
		
		switch(this.xdir){
			case kRight: 
				this.x+=this.xvelocity;
				this.xvelocity+=3;
				this.drawFilter="";
				break;
			case kLeft: 
				this.x+=0-this.xvelocity;
				this.xvelocity+=3;
				this.drawFilter="flipH();";
				break;

		}
		switch(this.ydir){
			case kUp: 
				this.y-=this.yvelocity;
				this.yvelocity--;
				break;
			case kDown: 
				this.y+=this.yvelocity;
				this.yvelocity--;
				break;

		}
		if(this.xdir==0)if(this.xvelocity>0){this.x+=this.xvelocity-=2;}
		this.oldXdir = this.xdir;
		this.oldYdir = this.ydir;
		
		//area bounds checking
		if(this.x<3)this.x=3;
		if(this.x>TheGame.screenWidth)this.x=TheGame.screenWidth;
		if(this.y<0-this.height)this.y=0-this.height;
		if(this.y>TheGame.screenHeight)this.y=TheGame.screenHeight;
	}	
	
	this.stop = function(){
		this.x=(0-this.height*2);
		this.y=(0-this.width*2);
		this.status=2;
	}
	
	this.remove = function(){
		this.stop();
		this.draw();
		this.reset();
	}
	
	this.reset=function(){
		this.counter1=0;
		this.facing=kRight;
		this.xvelocity=0;
		this.yvelocity=0;
		this.xdir=0;
		this.ydir=0;
		this.oldXdir=0;
		this.oldYdir=0;
	}
	
	this.update = function(){
		switch(this.status){
			case 1:
				this.move();
				this.draw();
				break;
			case 2:
				if(++this.counter1==15){
					this.status=1;
					TheGame.status=2;
				}
				break;
		}
		
	}
	
	this.checkCol = function(pGroupController){
		for(pColCount=0;pColCount<pGroupController.group.length;pColCount++){
				if(pGroupController.group[pColCount].status!=0){
						if(Collision(pGroupController.group[pColCount], this)){
							TheGame.Explosion1.x = this.x;
							TheGame.Explosion1.y = this.y;
							TheGame.Explosion1.status=1;
							pGroupController.group[pColCount].remove();
							this.score-=50;
							this.lives++;
							this.remove();
						}
					
				}
		}
	
	}
}
//Player.prototype = new ScreenObject;

