<commit_before>var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update });
var enemy;

function preload() {
  game.load.image('floor', 'assets/floor.png');
  game.load.image('enemy', 'assets/enemy.png');
}

function create() {
  game.add.sprite(0, 0, 'floor');
  enemy = game.add.sprite(0, 0, 'enemy');
  enemy.anchor.x = enemy.anchor.y = 0.5
  startTravel();
}

function update() {

}

function startTravel() {
	setTimeout(function(){
		var orig = generateOrigPoint(enemy);
		var dest = generateDestPoint(enemy, orig);
		var time = getRandomInt(1500, 2500);
		enemy.x = orig.x;
		enemy.y = orig.y;

		var tween = game.add.tween(enemy).to({x: dest.x, y: dest.y}, time, Phaser.Easing.None, true);
		tween.onComplete.add(startTravel, this);
	}, 500);
}

function generateOrigPoint(target){
	var point = {};
	if (Math.random() >= 0.5){
		point.x = getRandomInt(-target.width, (game.width + target.width));
		point.y = (Math.random() >= 0.5) ? -target.height : (game.height + target.height);
	} else {
		point.y = getRandomInt(-target.height, (game.height + target.height));
		point.x = (Math.random() >= 0.5) ? -target.width : (game.width + target.width);
	}
	return point;
}

function generateDestPoint(target, orig){
	var point = {};
	point.x = 0;
	point.y = 0;
	return point;
}

function getRandomInt(min, max) {
  return Math.floor(Math.random() * (max - min + 1)) + min;
}<commit_msg>monster crossing the screen randomly<commit_after>var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update });
var enemy;

function preload() {
	game.load.image('floor', 'assets/floor.png');
	game.load.image('enemy', 'assets/enemy.png');
}

function create() {
	game.add.sprite(0, 0, 'floor');
	enemy = game.add.sprite(-150, -150, 'enemy');
	enemy.anchor.x = enemy.anchor.y = 0.5;
	enemy.inputEnabled = true;
	enemy.events.onInputDown.add(enemyClick, this);
	startTravel();
}

function update() {

}

function enemyClick(target){
	if (target.movTween.isPaused){
		target.movTween.resume();
	} else {
		target.movTween.pause();
	}
}

function startTravel() {
	setTimeout(function(){
		var orig = generateOrigPoint(enemy);
		var dest = generateDestPoint(enemy, orig);
		var time = getRandomInt(2000, 2500);
		enemy.x = orig.x;
		enemy.y = orig.y;

		enemy.movTween = game.add.tween(enemy).to({x: dest.x, y: dest.y}, time, Phaser.Easing.None, true);
		enemy.movTween.onComplete.add(startTravel, this);
	}, 500);
}

function generateOrigPoint(target){
	var point = {x:0, y:0, loc:0};
	point.loc = Math.floor(Math.random() * 4);
	return generatePoint(point, target, point.loc);
}

function generateDestPoint(target, orig){
	var point = {x:0, y:0, loc:0, locName:null};
	do {
		point.loc = Math.floor(Math.random() * 4);
	} while (point.loc == orig.loc);
	return generatePoint(point, target, point.loc);
}

function generatePoint(point, target, loc){
	if (point.loc <= 1){
		point.x = getRandomInt(target.width, game.width - target.width);
		point.y = (point.loc == 0)? -target.height : game.height + target.height;
	} else {
		point.x = (point.loc == 2)? -target.width : game.width + target.width;
		point.y = getRandomInt(target.height, game.height - target.height);
	}
	return point;
}

function getRandomInt(min, max) {
	return Math.floor(Math.random() * (max - min + 1)) + min;
}
{'fraction_non_alphanumeric': 0.18149360309431717, 'fraction_numerical': 0.021124665278191016, 'mean_word_length': 4.204334365325077, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 6, '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': '2514915', 'n_tokens_mistral': 1335, 'n_tokens_neox': 1253, 'n_words': 267}