<commit_before>window.onload = function() {
	Crafty.init(600,500);
	Crafty.canvas.init();
	
	Crafty.sprite(64, "images/sprite.png", {
		red: [0,0],
		yellow: [1,0],
		empty: [2,0]
	});
	
	var turn = 0, //turn based
		board = [],
		COLUMN_FULL = -2,
		EMPTY = -1,
		YELLOW = 0,
		RED = 1; 
	
	Crafty.scene("game", function() {
		
		//generate board
		for(var i = 0; i < 7; i++) {
			board[i] = []; //init board
			for(var j = 0; j < 6; j++) {
				Crafty.e("2D, Canvas, empty").attr({x: i * 64, y: j * 64 + 100, z: 2});
				board[i][j] = EMPTY; //set it to empty
			}
		}
		
		Crafty.c("piece", {
			init: function() {
				this.z = 3;
				this.requires("Mouse, Gravity, Draggable");
				this.bind("StopDrag", function() {
					console.log("STOP");
					var column = Math.round(this._x / 64);
					this.x = column * 64;
					this.gravity("stopper");
					this.unbind("MouseDown");
					
					reset(column);
				});
			}
		});
		
		var current;
		function reset(column) {
			var row = findEmptyRow(column);
			if(row !== COLUMN_FULL && column >= 0 && column < 7) {
				board[column][row] = turn;
				
				if(checkFour(column,row)) {
					win(turn);
					return;
				}
				
				turn ^= 1; //alternate turns
				current = Crafty.e("2D, Canvas, piece, stopper,"+(turn ? "red" : "yellow")).attr({x: 495, y: 420});
			} else {
				//dont' place
				current.destroy();
				current = Crafty.e("2D, Canvas, piece, stopper,"+(turn ? "red" : "yellow")).attr({x: 495, y: 420});
			}
		}
		current = Crafty.e("2D, Canvas, piece, stopper, yellow").attr({x: 495, y: 420});
		
		var ground = Crafty.e("2D, stopper").attr({y: Crafty.viewport.height - 16, w: Crafty.viewport.width, h: 20 });
		var bg = Crafty.e("2D, Canvas, Image").image("images/bg.png").attr({z: -1});
	});
	
	Crafty.scene("win", function() {
		var bg = Crafty.e("2D, DOM, Image").image("images/win.png", "no-repeat").attr({w: 600, h: 500, z: -1});
		Crafty.e("2D, DOM, Text").attr({x: 220, y: 200}).text(turn ? "RED" : "YELLOW").font("30pt Arial");
	});
	
	function win(turn) {
		Crafty.scene("win");
	}
	
	Crafty.scene("game");//start the game
	function findEmptyRow(column) {
		if(!board[column]) return;<commit_msg>fixed connnet4.js. .font() is not available anymore. Changed to .css()<commit_after>window.onload = function() {
	Crafty.init(600,500);
	Crafty.canvas.init();
	
	Crafty.sprite(64, "images/sprite.png", {
		red: [0,0],
		yellow: [1,0],
		empty: [2,0]
	});
	
	var turn = 0, //turn based
		board = [],
		COLUMN_FULL = -2,
		EMPTY = -1,
		YELLOW = 0,
		RED = 1; 
	
	Crafty.scene("game", function() {
		
		//generate board
		for(var i = 0; i < 7; i++) {
			board[i] = []; //init board
			for(var j = 0; j < 6; j++) {
				Crafty.e("2D, Canvas, empty").attr({x: i * 64, y: j * 64 + 100, z: 2});
				board[i][j] = EMPTY; //set it to empty
			}
		}
		
		Crafty.c("piece", {
			init: function() {
				this.z = 3;
				this.requires("Mouse, Gravity, Draggable");
				this.bind("StopDrag", function() {
					console.log("STOP");
					var column = Math.round(this._x / 64);
					this.x = column * 64;
					this.gravity("stopper");
					this.unbind("MouseDown");
					
					reset(column);
				});
			}
		});
		
		var current;
		function reset(column) {
			var row = findEmptyRow(column);
			if(row !== COLUMN_FULL && column >= 0 && column < 7) {
				board[column][row] = turn;
				
				if(checkFour(column,row)) {
					win(turn);
					return;
				}
				
				turn ^= 1; //alternate turns
				current = Crafty.e("2D, Canvas, piece, stopper,"+(turn ? "red" : "yellow")).attr({x: 495, y: 420});
			} else {
				//dont' place
				current.destroy();
				current = Crafty.e("2D, Canvas, piece, stopper,"+(turn ? "red" : "yellow")).attr({x: 495, y: 420});
			}
		}
		current = Crafty.e("2D, Canvas, piece, stopper, yellow").attr({x: 495, y: 420});
		
		var ground = Crafty.e("2D, stopper").attr({y: Crafty.viewport.height - 16, w: Crafty.viewport.width, h: 20 });
		var bg = Crafty.e("2D, Canvas, Image").image("images/bg.png").attr({z: -1});
	});
	
	Crafty.scene("win", function() {
		var bg = Crafty.e("2D, DOM, Image").image("images/win.png", "no-repeat").attr({w: 600, h: 500, z: -1});
		//Crafty.e("2D, DOM, Text").attr({x: 220, y: 200}).text(turn ? "RED" : "YELLOW").font("30pt Arial");
		Crafty.e("2D, DOM, Text").attr({x: 220, y: 200}).text(turn ? "RED" : "YELLOW").css({
        "font-family": "Arial"
        , "font-size": "30pt"
      });
	});
	
	function win(turn) {
		Crafty.scene("win");
	}
	
	Crafty.scene("game");//start the game
	function findEmptyRow(column) {
		if(!board[column]) return;
{'fraction_non_alphanumeric': 0.22017139090309823, 'fraction_numerical': 0.03955174686882004, 'mean_word_length': 2.9005998286203942, 'pattern_counts': {'":': 2, '<': 9, '<?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': '3484910', 'n_tokens_mistral': 2236, 'n_tokens_neox': 1764, 'n_words': 392}