function Player(position, canvas) {
  this.worldWidth = canvas.width;
  this.worldHeight = canvas.height;
  this.state = "idle";
  this.id="player";
  this.position = {
    x: position.x,
    y: position.y
  };
  this.velocity = {
    x: 0,
    y: 0
  }
  this.angle = 0;
  this.radius  = 12;
  this.thrusting = false;
  this.steerLeft = false;
  this.steerRight = false;
  this.fire = false;
  this.color="white";
  this.index=0;
  this.tick=0;
  this.invulnerable = false;
  this.invulnerableCounter = 0;
  this.warpCounter = 0;

  var self = this;
  window.onkeydown = function(event) {
    switch(event.key) {
		
      case 'ArrowUp': // up
      case 'w':
        self.thrusting = true;
        break;
      case 'ArrowLeft': // left
      case 'a':
        self.steerLeft = true;
        break;
      case 'ArrowRight': // right
      case 'd':
        self.steerRight = true;
        break;
	  case 'Enter':
		self.fire = true;
		break;
	  case 'r':
		if(self.warpCounter<=0){
			
			self.invulnerable=true;
			self.invulnerableCounter=150;
			self.warpCounter=1000;
			self.position={x: Math.random() *self.worldWidth, y: Math.random() *self.worldHeight};
		}
		break;
    }
  }

  window.onkeyup = function(event) {
    switch(event.key) {
      case 'ArrowUp': // up
      case 'w':
        self.thrusting = false;
        break;
      case 'ArrowLeft': // left
      case 'a':
        self.steerLeft = false;
        break;
      case 'ArrowRight': // right
      case 'd':
        self.steerRight = false;
        break;
	  
    }
  }
}
/**
 * @constructor Player
 * Creates a new player object
 * @param {Postition} position object specifying an x and y
 */
@constructor Player
Creates a new player object
@param {Postition} position object specifying an x and y
@constructor Player Creates a new player object @param { Postition } position object specifying an x and y
function Player(position, canvas) {
  this.worldWidth = canvas.width;
  this.worldHeight = canvas.height;
  this.state = "idle";
  this.id="player";
  this.position = {
    x: position.x,
    y: position.y
  };
  this.velocity = {
    x: 0,
    y: 0
  }
  this.angle = 0;
  this.radius  = 12;
  this.thrusting = false;
  this.steerLeft = false;
  this.steerRight = false;
  this.fire = false;
  this.color="white";
  this.index=0;
  this.tick=0;
  this.invulnerable = false;
  this.invulnerableCounter = 0;
  this.warpCounter = 0;
  var self = this;
  window.onkeydown = function(event) {
    switch(event.key) {
      case 'ArrowUp': 
      case 'w':
        self.thrusting = true;
        break;
      case 'ArrowLeft': 
      case 'a':
        self.steerLeft = true;
        break;
      case 'ArrowRight': 
      case 'd':
        self.steerRight = true;
        break;
	  case 'Enter':
		self.fire = true;
		break;
	  case 'r':
		if(self.warpCounter<=0){
			self.invulnerable=true;
			self.invulnerableCounter=150;
			self.warpCounter=1000;
			self.position={x: Math.random() *self.worldWidth, y: Math.random() *self.worldHeight};
		}
		break;
    }
  }
  window.onkeyup = function(event) {
    switch(event.key) {
      case 'ArrowUp': 
      case 'w':
        self.thrusting = false;
        break;
      case 'ArrowLeft': 
      case 'a':
        self.steerLeft = false;
        break;
      case 'ArrowRight': 
      case 'd':
        self.steerRight = false;
        break;
    }
  }
}
function Player ( position , canvas ) { this . worldWidth = canvas . width ; this . worldHeight = canvas . height ; this . state = "idle" ; this . id = "player" ; this . position = { x : position . x , y : position . y } ; this . velocity = { x : 0 , y : 0 } this . angle = 0 ; this . radius = 12 ; this . thrusting = false ; this . steerLeft = false ; this . steerRight = false ; this . fire = false ; this . color = "white" ; this . index = 0 ; this . tick = 0 ; this . invulnerable = false ; this . invulnerableCounter = 0 ; this . warpCounter = 0 ; var self = this ; window . onkeydown = function ( event ) { switch ( event . key ) { case 'ArrowUp' : case 'w' : self . thrusting = true ; break ; case 'ArrowLeft' : case 'a' : self . steerLeft = true ; break ; case 'ArrowRight' : case 'd' : self . steerRight = true ; break ; case 'Enter' : self . fire = true ; break ; case 'r' : if ( self . warpCounter <= 0 ) { self . invulnerable = true ; self . invulnerableCounter = 150 ; self . warpCounter = 1000 ; self . position = { x : Math . random ( ) * self . worldWidth , y : Math . random ( ) * self . worldHeight } ; } break ; } } window . onkeyup = function ( event ) { switch ( event . key ) { case 'ArrowUp' : case 'w' : self . thrusting = false ; break ; case 'ArrowLeft' : case 'a' : self . steerLeft = false ; break ; case 'ArrowRight' : case 'd' : self . steerRight = false ; break ; } } }
@constructor Player
 Creates a new player object
 @param {Postition} position object specifying an x and y
@constructor Player Creates a new player object @param { Postition } position object specifying an x and y
// up // left // right // up // left // right