<commit_before>var mobs = [];

var mobSize = 40;

function Mob(x, y, color) {
	this.x = x;
	this.y = y;
	this.color = color;
	if (Math.random() * 2 < 1) {
		this.left = true;
	}
}

Mob.prototype.draw = function() {
	ctx.beginPath();
	if (this.left) {
		ctx.moveTo(this.x + mobSize, this.y);
		ctx.lineTo(this.x + mobSize, this.y + mobSize);
		ctx.lineTo(this.x, this. y + mobSize / 2);
		ctx.lineTo(this.x + mobSize, this.y);
	} else {
		ctx.moveTo(this.x, this.y);
		ctx.lineTo(this.x, this.y + mobSize);
		ctx.lineTo(this.x + mobSize, this. y + mobSize / 2);
		ctx.lineTo(this.x, this.y);
	}
	ctx.fillStyle = this.color;
	ctx.fill();
}

Mob.prototype.sim = function() {
	if (this.sufferAttack()) {
		console.log("Stopping mob sim");
		return false;
	}
	
	this.attackPlayer();
	
	return true;
}

Mob.prototype.sufferAttack = function() {
	if (player.attackBall) {
		var pcenter = player.getCenter();
		var rad = player.attackBall.radius;
		// had to look up the geometry for this circle and rectangle thing- http://stackoverflow.com/a/1879223
		var nearX = Math.max(this.x, Math.min(pcenter.x, this.x + mobSize));
		var nearY = Math.max(this.y, Math.min(pcenter.y, this.y + mobSize));
		if (pcenter.dist(new Point(nearX, nearY)) <= rad) {
			if (this.color.interactsWith(player.attackBall.color)) {
				return true;
			}
		}
	}
	return false;
}

Mob.prototype.attackPlayer = function() {
	if (this.x < player.x + player.width && this.x + mobSize > player.x && this.y < player.y + player.height && this.y + mobSize > player.y) {
		if (this.color.interactsWith(player.getColor())) {
			lost = true;
			clearInterval(gameLoop);
		}
	}
}
<commit_msg>Make the enemies able to move<commit_after>var mobs = [];

var mobSize = 40;
var mobSpeed = 2;

function Mob(x, y, color) {
	this.x = x;
	this.y = y;
	this.color = color;
	if (Math.random() * 2 < 1) {
		this.left = true;
	}
}

Mob.prototype.draw = function() {
	ctx.beginPath();
	if (this.left) {
		ctx.moveTo(this.x + mobSize, this.y);
		ctx.lineTo(this.x + mobSize, this.y + mobSize);
		ctx.lineTo(this.x, this. y + mobSize / 2);
		ctx.lineTo(this.x + mobSize, this.y);
	} else {
		ctx.moveTo(this.x, this.y);
		ctx.lineTo(this.x, this.y + mobSize);
		ctx.lineTo(this.x + mobSize, this. y + mobSize / 2);
		ctx.lineTo(this.x, this.y);
	}
	ctx.fillStyle = this.color;
	ctx.fill();
}

Mob.prototype.sim = function() {
	if (this.sufferAttack()) {
		console.log("Stopping mob sim");
		return false;
	}
	
	// move towards the player, and flip around if you've passed the player
	if (this.left) {
		if (this.x + mobSize > player.x) {
			this.x -= mobSpeed;
		} else {
			this.left = false;
		}
	} else {
		if (this.x < player.x + player.width) {
			this.x += mobSpeed;
		} else {
			this.left = true;
		}
	}
	
	this.attackPlayer();
	
	return true;
}

Mob.prototype.sufferAttack = function() {
	if (player.attackBall) {
		var pcenter = player.getCenter();
		var rad = player.attackBall.radius;
		// had to look up the geometry for this circle and rectangle thing- http://stackoverflow.com/a/1879223
		var nearX = Math.max(this.x, Math.min(pcenter.x, this.x + mobSize));
		var nearY = Math.max(this.y, Math.min(pcenter.y, this.y + mobSize));
		if (pcenter.dist(new Point(nearX, nearY)) <= rad) {
			if (this.color.interactsWith(player.attackBall.color)) {
				return true;
			}
		}
	}
	return false;
}

Mob.prototype.attackPlayer = function() {
	if (this.x < player.x + player.width && this.x + mobSize > player.x && this.y < player.y + player.height && this.y + mobSize > player.y) {
		if (this.color.interactsWith(player.getColor())) {
			lost = true;
			clearInterval(gameLoop);
		}
	}
}

{'fraction_non_alphanumeric': 0.17125550660792951, 'fraction_numerical': 0.007433920704845815, 'mean_word_length': 3.180667433831991, 'pattern_counts': {'":': 0, '<': 12, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5337797', 'n_tokens_mistral': 1556, 'n_tokens_neox': 1425, 'n_words': 313}