<commit_before>Class.makeClass(Critter, function Player(x, y, width, height) {
	this.init();

	this.x = x;
	this.y = y;
	this.width = width;
	this.height = height;

	this.r = 220;
	this.b = 220;
});

Player.prototype.findTouching = function() {
	var self = this;
	var bb = this.getBounds();
	return game.mobs.filter(function(el) {
		return el.getBounds().intersects(bb);
	});
}

Player.prototype.update = function() {
	if (keysHeld.space) {
		var touching = this.findTouching();
		if (touching.length) {
			var self = this;
			var grabbed = touching.filter(function(el) { return el.grabbedBy == self; }); 

			if (grabbed.length) {
				var critters = touching.filter(function(el) { return el instanceof Critter; });
				if (critters.length) {
					critters[0].eat(grabbed[0]);
				}
			} else {
				var berries = touching.filter(function(el) { return el instanceof Berry; });
				if (berries.length) {
					berries[0].grabbedBy = this;
				}
			}
		}
		// treat space as a press-then-release key (probably breaking abstraction, but, eh. game jam)
		keysHeld.space = false;
	}

	var x = 0;
	var y = 0;
	if (keysHeld.left) {
		x -= 1;
	}
	if (keysHeld.right) {
		x += 1;
	}

	this.accelerate(x, y);

	this.move();
}
<commit_msg>Add basic shape-shifting (copy width/height from other)<commit_after>Class.makeClass(Critter, function Player(x, y, width, height) {
	this.init();

	this.x = x;
	this.y = y;
	this.width = width;
	this.height = height;

	this.r = 220;
	this.b = 220;
});

Player.prototype.findTouching = function() {
	var self = this;
	var bb = this.getBounds();
	return game.mobs.filter(function(el) {
		return el.getBounds().intersects(bb);
	});
}

Player.prototype.shapeshift = function(critter) {
	this.width = critter.width;
	this.height = critter.height;
}

Player.prototype.update = function() {
	if (keysHeld.g) {
		var touching = this.findTouching();
		if (touching.length) {
			var self = this;
			var grabbed = touching.filter(function(el) { return el.grabbedBy == self; }); 

			if (grabbed.length) {
				var critters = touching.filter(function(el) { return el instanceof Critter; });
				if (critters.length) {
					critters[0].eat(grabbed[0]);
				}
			} else {
				var berries = touching.filter(function(el) { return el instanceof Berry; });
				if (berries.length) {
					berries[0].grabbedBy = this;
				}
			}
		}
		// treat this as a press-then-release key (probably breaking abstraction, but, eh. game jam)
		keysHeld.g = false;
	}
	if (keysHeld.t) {
		var critters = this.findTouching().filter(function(el) { return el instanceof Critter; });
		if (critters.length) {
			this.shapeshift(critters[0]);
		}
		// treat this as a press-then-release key (probably breaking abstraction, but, eh. game jam)
		keysHeld.t = false;
	}

	var x = 0;
	var y = 0;
	if (keysHeld.left) {
		x -= 1;
	}
	if (keysHeld.right) {
		x += 1;
	}

	this.accelerate(x, y);

	this.move();
}

{'fraction_non_alphanumeric': 0.15560165975103735, 'fraction_numerical': 0.00933609958506224, 'mean_word_length': 3.2732644017725256, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1717729', 'n_tokens_mistral': 1216, 'n_tokens_neox': 1066, 'n_words': 249}