<commit_before>/* -----

	game object
		
	------			*/

	/************************************************************************************/
	/*																												*/
	/*		a player entity																					*/
	/*																												*/
	/************************************************************************************/
	var PlayerEntity = me.ObjectEntity.extend(
	{	
		init: function(x, y, settings)
		{
			// call the constructor
			this.parent(x, y , settings);
			
			// walking & jumping speed
			this.setVelocity(2, 13);
			
			this.setFriction(0.2,0);
			
			// update the hit box
			this.updateColRect(12,8, -1,0);
			
			this.dying = false;
		
			// set the display around our position
			me.game.viewport.follow(this.pos, me.game.viewport.AXIS.HORIZONTAL);
					
			// enable the keyboard
			// walk
			me.input.bindKey(me.input.KEY.LEFT,	 "left");
			me.input.bindKey(me.input.KEY.RIGHT, "right");
			// jump
			me.input.bindKey(me.input.KEY.X,	"jump", true);
			// go left & right
			me.input.bindKey(me.input.KEY.UP,	"up");
			me.input.bindKey(me.input.KEY.DOWN,	"down");

			// walking animatin
			this.addAnimation ("walk",  [0,1,2,3]);
			// climbing animatin
			this.addAnimation ("climb", [4,5,6,7]);
			
			// set default one
			this.setCurrentAnimation("walk");
			
		},
		
		/* -----

			update the player pos
			
		------			*/
		update : function ()
		{
			
			var doClimb = false;
			
			if (me.input.isKeyPressed('left'))
			{
				this.doWalk(true);
			}
			else if (me.input.isKeyPressed('right'))
			{
				this.doWalk(false);
			}
					
			if (me.input.isKeyPressed('up'))
			{
				doClimb = this.doClimb(true);
			}
			else if (me.input.isKeyPressed('down'))
			{
				doClimb = this.doClimb(false);
			}
			
			if (me.input.isKeyPressed('jump'))
			{	
				if (this.doJump()) 
				{
					me.audio.play("jump", false);
				}
				
			}
			
			// check for collision with environment
			var env_res = this.updateMovement();
			
			if (this.onladder)
			{
				// cancel residual y vel
				this.vel.y = 0;
				
				// make sure we have the right animation
				if ((doClimb || this.jumping) && this.isCurrentAnimation("walk"))
					this.setCurrentAnimation("climb");
			} 
			else if (this.isCurrentAnimation("climb"))
			{
				this.setCurrentAnimation("walk");
			}

							
			// check for collision with sthg
			var res = me.game.collide(this);
			
			if (res)
			{
				if (res.type == me.game.ENEMY_OBJECT)
				{
				   if ((res.y>0) && !this.jumping)
				   {
					  this.forceJump();
				   }
				   else
				   {
					  this.die();
				   }
				}
				else if (res.type == "spikeobject")
				{
				   this.forceJump();
				   this.die();
				}
			}
			
			if (this.vel.x!=0 || this.vel.y!=0 || (this.onladder && doClimb) || this.isFlickering())
			{
				this.parent();
				return true;
				
			}
			return false;
		},

		
		/* -----

			manage "diyng"
			
		------			*/
		die : function ()
		{
			if (!this.flickering)<commit_msg>Fixed inconstant type value between Tiled and Entity code, as it's now case sensitive (following ticket #41)<commit_after>/* -----

	game object
		
	------			*/

	/************************************************************************************/
	/*																					*/
	/*		a player entity																*/
	/*																					*/
	/************************************************************************************/
	var PlayerEntity = me.ObjectEntity.extend(
	{	
		init: function(x, y, settings)
		{
			// call the constructor
			this.parent(x, y , settings);
			
			// walking & jumping speed
			this.setVelocity(2, 13);
			
			this.setFriction(0.2,0);
			
			// update the hit box
			this.updateColRect(12,8, -1,0);
			
			this.dying = false;
		
			// set the display around our position
			me.game.viewport.follow(this.pos, me.game.viewport.AXIS.HORIZONTAL);
					
			// enable the keyboard
			// walk
			me.input.bindKey(me.input.KEY.LEFT,	 "left");
			me.input.bindKey(me.input.KEY.RIGHT, "right");
			// jump
			me.input.bindKey(me.input.KEY.X,	"jump", true);
			// go left & right
			me.input.bindKey(me.input.KEY.UP,	"up");
			me.input.bindKey(me.input.KEY.DOWN,	"down");

			// walking animatin
			this.addAnimation ("walk",  [0,1,2,3]);
			// climbing animatin
			this.addAnimation ("climb", [4,5,6,7]);
			
			// set default one
			this.setCurrentAnimation("walk");
			
		},
		
		/* -----

			update the player pos
			
		------			*/
		update : function ()
		{
			
			var doClimb = false;
			
			if (me.input.isKeyPressed('left'))
			{
				this.doWalk(true);
			}
			else if (me.input.isKeyPressed('right'))
			{
				this.doWalk(false);
			}
					
			if (me.input.isKeyPressed('up'))
			{
				doClimb = this.doClimb(true);
			}
			else if (me.input.isKeyPressed('down'))
			{
				doClimb = this.doClimb(false);
			}
			
			if (me.input.isKeyPressed('jump'))
			{	
				if (this.doJump()) 
				{
					me.audio.play("jump", false);
				}
				
			}
			
			// check for collision with environment
			var env_res = this.updateMovement();
			
			if (this.onladder)
			{
				// cancel residual y vel
				this.vel.y = 0;
				
				// make sure we have the right animation
				if ((doClimb || this.jumping) && this.isCurrentAnimation("walk"))
					this.setCurrentAnimation("climb");
			} 
			else if (this.isCurrentAnimation("climb"))
			{
				this.setCurrentAnimation("walk");
			}

							
			// check for collision with sthg
			var res = me.game.collide(this);
			
			if (res)
			{
				if (res.obj.type == me.game.ENEMY_OBJECT)
				{
				   if ((res.y>0) && !this.jumping)
				   {
					  this.forceJump();
				   }
				   else
				   {
					  this.die();
				   }
				}
				else if (res.obj.type == "spikeObject")
				{
				   this.forceJump();
				   this.die();
				}
			}
			
			if (this.vel.x!=0 || this.vel.y!=0 || (this.onladder && doClimb) || this.isFlickering())
			{
				this.parent();
				return true;
				
			}
			return false;
		},

		
		/* -----

			manage "diyng"
			
		------			*/
		die : function ()
		{
			if (!this.flickering)
{'fraction_non_alphanumeric': 0.21400198609731877, 'fraction_numerical': 0.007944389275074478, 'mean_word_length': 1.9709931170108161, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4772777', 'n_tokens_mistral': 2786, 'n_tokens_neox': 2060, 'n_words': 373}