<commit_before>myGame = new game(document.getElementById("game"));
Interval = null;


function startDriving(roadLength){

	driverCam = new camera();
	driverCam.ZoomInToFitWithOf = 700;
	driverCam.focusPosition = setting.BOTTOM;
	driverScene = new scene(driverCam)
	
	
	driverScene.pullLeft = function(){
		player.move = new vector2D(-0.25, -0.5)
		//player.position.add(new vector2D(-100, 0))
	}
	driverScene.pullRight = function(){
		player.move = new vector2D(0.25, -0.5)
		//player.position.add(new vector2D(100, 0))
	}
	
	driverScene.pullDown = function(){
		player.move = new vector2D(0, -0.5)
	}
	
	driverScene.pullUp = function(){
		player.move = new vector2D(0, -0.5)
	}
	
	
	
	myGame.addScene(driverScene);
	
	IceImage = new Image();
	IceImage.src = "./ice.png";
	
	RoadImage = new Image();
	RoadImage.src = "./road.png"
	
	road = new gBackground();
	road.size = new vector2D(600, 100);
	road.color = "blue";
	road.image = RoadImage;
	road.fixHeight = false;
	road.position = new vector2D(-300, -800);
	driverScene.addGPObject(road);
	
	iceDistance = 800;
	neededIce 	= Math.ceil(roadLength/iceDistance);

	IceBlock = new Array();
	
	for(i = 0; i <= neededIce; i++){
		IceBlock[i] = new gpObject();
		IceBlock[i].size = new vector2D(100, 100);
		IceBlock[i].color = "blue";
		IceBlock[i].tag = "gameover"
		IceBlock[i].image = IceImage;
		IceBlock[i].fixHeight = false;
		x = Math.round(Math.random()*600-300);
		y = Math.round(Math.random()*300) - 800;
		IceBlock[i].position = new vector2D(x , -i*800 + y);
		driverScene.addGPObject(IceBlock[i]);
	}


	//the finish line
	WinLine = new gpObject();
	WinLine.size = new vector2D(700, 100);
	WinLine.color = "blue";
	WinLine.tag = "gameover"
	WinLine.color = "green";
	WinLine.onCollide = function(ele){
		if(ele == player){
			alert("win");
			driverScene.drop();
			startDriving(5000)
		}
	}
	WinLine.position = new vector2D(-350 , -roadLength);
	driverScene.addGPObject(WinLine);

	
	
	player = new gpObject();
	player.size = new vector2D(100, 100);
	player.onCollide = function(ele){
		if(ele.tag == "gameover"){
			alert("gameover");
			driverScene.drop();
			startDriving(3000)
		}
	}
	player.position = new vector2D(-50, 0);
	PlayerImage = new Image();
	PlayerImage.src = "./player.png"
	player.image= PlayerImage;
	player.fixHeight = false;<commit_msg>add border<commit_after>myGame = new game(document.getElementById("game"));
Interval = null;

//loading the Images
PlayerImage = new Image();
PlayerImage.src = "./player.png"
	
IceImage = new Image();
IceImage.src = "./ice.png";
	
RoadImage = new Image();
RoadImage.src = "./road.png"


function startDriving(roadLength){

	driverCam = new camera();
	driverCam.ZoomInToFitWithOf = 700;
	driverCam.focusPosition = setting.BOTTOM;
	driverScene = new scene(driverCam)
	
	
	driverScene.pullLeft = function(){
		player.move = new vector2D(-0.25, -0.5)
		//player.position.add(new vector2D(-100, 0))
	}
	driverScene.pullRight = function(){
		player.move = new vector2D(0.25, -0.5)
		//player.position.add(new vector2D(100, 0))
	}
	
	driverScene.pullDown = function(){
		player.move = new vector2D(0, -0.5)
	}
	
	driverScene.pullUp = function(){
		player.move = new vector2D(0, -0.5)
	}
	
	
	
	myGame.addScene(driverScene);
	
	
	road = new gBackground();
	road.size = new vector2D(600, 100);
	road.color = "blue";
	road.image = RoadImage;
	road.fixHeight = false;
	road.position = new vector2D(-300, -800);
	driverScene.addGPObject(road);
	
	iceDistance = 800;
	neededIce 	= Math.ceil(roadLength/iceDistance);

	IceBlock = new Array();
	
	for(i = 0; i <= neededIce; i++){
		IceBlock[i] = new gpObject();
		IceBlock[i].size = new vector2D(100, 100);
		IceBlock[i].color = "blue";
		IceBlock[i].tag = "gameover"
		IceBlock[i].image = IceImage;
		IceBlock[i].fixHeight = false;
		x = Math.round(Math.random()*600-300);
		y = Math.round(Math.random()*300) - 800;
		IceBlock[i].position = new vector2D(x , -i*800 + y);
		driverScene.addGPObject(IceBlock[i]);
	}


	//the finish line
	WinLine = new gpObject();
	WinLine.size = new vector2D(700, 100);
	WinLine.color = "blue";
	WinLine.tag = "gameover"
	WinLine.color = "green";
	WinLine.onCollide = function(ele){
		if(ele == player){
			alert("win");
			driverScene.drop();
			startDriving(5000)
		}
	}
	WinLine.position = new vector2D(-350 , -roadLength);
	driverScene.addGPObject(WinLine);


	//Borders -> not let the Player out of the screen

	looseLeftBorder = new gpObject();
	looseLeftBorder.size = new vector2D(100, roadLength +500);
	looseLeftBorder.tag = "gameover"
	looseLeftBorder.color = "red";
	looseLeftBorder.onCollide = function(ele){
		if(ele == player){
			alert("gameover");
			driverScene.drop();
			startDriving(3000)
		}
	}
	looseLeftBorder.position = new vector2D(-450 , -roadLength);
	driverScene.addGPObject(looseLeftBorder);

	looseRightBorder = new gpObject();
	looseRightBorder.size = new vector2D(100, roadLength +500);
	looseRightBorder.tag = "gameover"
	looseRightBorder.color = "red";
	looseRightBorder.onCollide = function(ele){
		if(ele == player){
			alert("gameover");
			driverScene.drop();
			startDriving(3000)
		}
	}
	looseRightBorder.position = new vector2D(350 , -roadLength);
	driverScene.addGPObject(looseRightBorder);

	
	
	player = new gpObject();
	player.size = new vector2D(100, 100);
	player.onCollide = function(ele){
		if(ele.tag == "gameover"){
			alert("gameover");
			driverScene.drop();
			startDriving(3000)
		}
	}
	player.position = new vector2D(-50, 0);
	player.image= PlayerImage;
	player.fixHeight = false;
{'fraction_non_alphanumeric': 0.15954364360738862, 'fraction_numerical': 0.04310032596885187, 'mean_word_length': 4.109158186864015, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, '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': '4245642', 'n_tokens_mistral': 2322, 'n_tokens_neox': 1995, 'n_words': 398}