<commit_before>//creates a player entity and uses an image and creates deminsions of player
game.PlayerEntity = me.Entity.extend({
	init: function(x, y, settings){
		this._super(me.Entity, 'init', [x, y, {
			//calls image of entity we want to use
			image:"player",
			width: 64,
			height: 64,
			spritewidth: "64",
			spriteheight: "64",
			//creates a function that defines where entity can move
			getShape: function(){
				return(new me.Rect(0, 0, 64, 64)).toPolygon();

			}
		}]);
		//sets characters velocity on x and y axis
		this.body.setVelocity(5, 20);
		//keep track of which direction your character is going
		this.facing = "right";
		//follows player with screen so we can see him
		me.game.viewport.follow(this.pos, me.game.viewport.AXIS.BOTH);

		//adds animation when character is idle
		this.renderable.addAnimation("idle", [78]);
		//adds animation as character walks
		this.renderable.addAnimation("walk", [117, 118, 119, 120, 121, 122, 123, 124, 125], 80);
		//sets character image when we start game
		this.renderable.setCurrentAnimation("idle");
		//adds animations for attacking
		this.renderable.addAnimation("attack", [65, 66, 67, 68, 70, 71, 72], 80);

	},

	update: function(delta){
		//adds if/else so that the caharacter will mve when key is pressed
		if (me.input.isKeyPressed("right")) {
			//adds to the postition of x by the velocity defined above in 
			//setVelocity() and multiplying it by me.timer.tick
			//me.timer.tick makes the movement smooth
			this.body.vel.x += this.body.accel.x * me.timer.tick;
			//keep track of which direction your character is going
			this.facing = "right";
			//flips walking animation
			this.flipX(true);

		}else if (me.input.isKeyPressed("left")){
			this.body.vel.x -= this.body.accel.x * me.timer.tick;
			//keep track of which direction your character is going
			this.facing = "left";
			//flips blayer back so it is facing left
			this.flipX(false);
		}else{
			//makes it so that character stops moving when key is not pressed
			this.body.vel.x = 0;
		}

		if (me.input.isKeyPressed("jump") && !this.body.jumping && !this.body.falling) {
			this.body.jumping = true;
			this.body.vel.y -= this.body.accel.y * me.timer.tick;
		};

		if(me.input.isKeyPressed("attack")){
			if(!this.renderable.isCurrentAnimation("attack")){
				//sets current animation to attack and once that is over goes back to idle animation
				this.renderable.setCurrentAnimation("attack", "idle");
				//makes it so next time sequence is started we begin
				//from the first animation not the one we left off at
				this.renderable.setAnimationFrame();
			}

		}
	//makes is so player does not stat out walking
	else if(this.body.vel.x !== 0){
		//if statement that makes character walk
		if (!this.renderable.isCurrentAnimation("walk")) {
			//lets program use every walk animation
			this.renderable.setCurrentAnimation("walk");
		}
		//player stops walking when key is not presseed
	}else{
		this.renderable.setCurrentAnimation("idle");
	}
		if(me.input.isKeyPressed("attack")){
			if(!this.renderable.isCurrentAnimation("attack")){
				//sets current animation to attack and once that is over goes back to idle animation
				this.renderable.setCurrentAnimation("attack", "idle");
				//makes it so next time sequence is started we begin
				//from the first animation not the one we left off at
				this.renderable.setAnimationFrame();
			}

		}

		//passing perameter into function with info about player condition
		me.collision.check(this, true, this.collideHandler.bind(this), true);
		//shows updated position on screen
		this.body.update(delta);
		//lets animation update on fly
		this._super(me.Entity, "update", [delta]);
		return true;
	},

	collideHandler: function(response){
		if(response.b.type==='EnemyBaseEntity'){
			var ydif = this.pos.y - response.b.pos.y;
			var xdif = this.pos.x - response.b.pos.x;
			//keeps player from glitching into the base from the left
			if(xdif>-50 && this.facing==='right' && (xdif<0)){
				//stops player velocity
				this.body.vel.x = 0;
				//pushes player back
				this.pos.x = this.pos.x -1;
			//keeps player from glitching into the base from the right
			}else if(xdif<60 && this.facing==='left' && (xdif>0)){
				//stops player velocity<commit_msg>video 16 code and comment<commit_after>//creates a player entity and uses an image and creates deminsions of player
game.PlayerEntity = me.Entity.extend({
	init: function(x, y, settings){
		this._super(me.Entity, 'init', [x, y, {
			//calls image of entity we want to use
			image:"player",
			width: 64,
			height: 64,
			spritewidth: "64",
			spriteheight: "64",
			//creates a function that defines where entity can move
			getShape: function(){
				return(new me.Rect(0, 0, 64, 64)).toPolygon();

			}
		}]);
		//sets characters velocity on x and y axis
		this.body.setVelocity(5, 20);
		//keep track of which direction your character is going
		this.facing = "right";
		//follows player with screen so we can see him
		me.game.viewport.follow(this.pos, me.game.viewport.AXIS.BOTH);

		//adds animation when character is idle
		this.renderable.addAnimation("idle", [78]);
		//adds animation as character walks
		this.renderable.addAnimation("walk", [117, 118, 119, 120, 121, 122, 123, 124, 125], 80);
		//sets character image when we start game
		this.renderable.setCurrentAnimation("idle");
		//adds animations for attacking
		this.renderable.addAnimation("attack", [65, 66, 67, 68, 70, 71, 72], 80);

	},

	update: function(delta){
		//adds if/else so that the caharacter will mve when key is pressed
		if (me.input.isKeyPressed("right")) {
			//adds to the postition of x by the velocity defined above in 
			//setVelocity() and multiplying it by me.timer.tick
			//me.timer.tick makes the movement smooth
			this.body.vel.x += this.body.accel.x * me.timer.tick;
			//keep track of which direction your character is going
			this.facing = "right";
			//flips walking animation
			this.flipX(true);

		}else if (me.input.isKeyPressed("left")){
			this.body.vel.x -= this.body.accel.x * me.timer.tick;
			//keep track of which direction your character is going
			this.facing = "left";
			//flips blayer back so it is facing left
			this.flipX(false);
		}else{
			//makes it so that character stops moving when key is not pressed
			this.body.vel.x = 0;
		}

		if (me.input.isKeyPressed("jump") && !this.body.jumping && !this.body.falling) {
			this.body.jumping = true;
			this.body.vel.y -= this.body.accel.y * me.timer.tick;
		};

		if(me.input.isKeyPressed("attack")){
			if(!this.renderable.isCurrentAnimation("attack")){
				//sets current animation to attack and once that is over goes back to idle animation
				this.renderable.setCurrentAnimation("attack", "idle");
				//makes it so next time sequence is started we begin
				//from the first animation not the one we left off at
				this.renderable.setAnimationFrame();
			}

		}
	//makes is so player does not stat out walking
	else if(this.body.vel.x !== 0){
		//if statement that makes character walk
		if (!this.renderable.isCurrentAnimation("walk")) {
			//lets program use every walk animation
			this.renderable.setCurrentAnimation("walk");
		}
		//player stops walking when key is not presseed
	}else{
		this.renderable.setCurrentAnimation("idle");
	}
		if(me.input.isKeyPressed("attack")){
			if(!this.renderable.isCurrentAnimation("attack")){
				//sets current animation to attack and once that is over goes back to idle animation
				this.renderable.setCurrentAnimation("attack", "idle");
				//makes it so next time sequence is started we begin
				//from the first animation not the one we left off at
				this.renderable.setAnimationFrame();
			}

		}

		//passing perameter into function with info about player condition
		me.collision.check(this, true, this.collideHandler.bind(this), true);
		//shows updated position on screen
		this.body.update(delta);
		//lets animation update on fly
		this._super(me.Entity, "update", [delta]);
		return true;
	},

	collideHandler: function(response){
		if(response.b.type==='EnemyBaseEntity'){
			var ydif = this.pos.y - response.b.pos.y;
			var xdif = this.pos.x - response.b.pos.x;
			//keeps player from glitching into the base from the left
			if (ydif<-40 && xdif< 50 && xdif>-35) {
				this.body.falling= false;
				this.body.vel.y = -1;
			}
			else if(xdif>-50 && this.facing==='right' && (xdif<0)){
				//stops player velocity
				this.body.vel.x = 0;
				//pushes player back
				this.pos.x = this.pos.x -1;
			//keeps player from glitching into the base from the right
			}else if(xdif<60 && this.facing==='left' && (xdif>0)){
				//stops player velocity
{'fraction_non_alphanumeric': 0.1297515886770653, 'fraction_numerical': 0.018139803581744655, 'mean_word_length': 3.380566801619433, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7022579', 'n_tokens_mistral': 3289, 'n_tokens_neox': 2752, 'n_words': 893}