<commit_before>var canvas, ctx, w, h;

var colorful = true;

var colordef = {
		sky: "#4d79ff",
		skyday: "#4d79ff",
		skynight: "#241c52",
		ground: "#00b300",
		body: "#ed00ed",
		stick: "#ff66ff"
}

var color = {
		sky: "#4d79ff",
		skyday: "#4d79ff",
		skynight: "#241c52",
		ground: "#00b300",
		body: "#ed00ed",
		stick: "#ff66ff"
}

var cloudSpeed = 1;
var cloudSize = 100;
var cloudSpeedDef = 1.5;
var cloudSpeedMin = 0.2;
var cloudCnt = 5;

function moveCloud() {
	var left = this.x<-cloudSize
	var right = this.x>this.w*2+cloudSize
	if(left||right) {
		this.y = (this.h/2-20-this.h/(1.75*50)-10)*Math.random()-10
		this.speed = Math.random()*(cloudSpeedDef-cloudSpeedMin)+cloudSpeedMin
		if(left) {
			this.x = this.w+cloudSize // to right
		} else {
			this.x = -cloudSize; // to left
		}
//		this.x = (this.x+this.w)%this.w;
	}
	
	this.x+=this.speed*cloudSpeed;
}

function renderCloud() {
	ctx.shadowBlur=7;
	ctx.shadowColor="black";
	ctx.font = cloudSize+"px FontAwesome";
	ctx.globalAlpha="0.7"
	ctx.fillStyle = "#ffffff";
	ctx.textAlign = "center";
	ctx.fillText("\uf0c2", this.x-cloudSize/2, this.y)
	ctx.shadowBlur=0;
	ctx.globalAlpha="1"
}

function Cloud(x, y, speed, w, h) {
	this.x = x;
	this.y = y;
	this.w = w;
	this.h = h;
	this.speed = speed;
	this.update = moveCloud;
	this.render = renderCloud;
}

var clouds = [];

function initRender() {
	clouds = [];
	for(var i = 0; i < cloudCnt; i++) {
		clouds.push(new Cloud(Math.random()*w, (h/2-20-h/(1.75*50)-10)*Math.random()-10, Math.random()*(cloudSpeedDef-cloudSpeedMin)+cloudSpeedMin, w, h))
	}
	
	lastpx = w/50/2;
}

// Animation loop

speed = 60*5
//speed = 1/speed
var lastTime;
var maxSubSteps = 5; // Max physics ticks per render frame
var fixedDeltaTime = 1 / speed; // Physics "tick" delta time
function animate(time) {
	if(!pause) {
		requestAnimationFrame(animate);
	}
	// Get the elapsed time since last frame, in seconds
	var deltaTime = lastTime ? (time - lastTime) / 1000 : 0;
	lastTime = time;
	// Make sure the time delta is not too big (can happen if user switches
	// browser tab)
	deltaTime = Math.min(1 / 10, deltaTime);
	// Move physics bodies forward in time
	world.step(fixedDeltaTime, deltaTime, maxSubSteps);
	// Render scene
	if(!tutorialm) {
		render();
	} else {
		rendertut()
	}
}

var xscroll = 0
var yscroll = 0

var endscore = 0


//from http://stackoverflow.com/a/11293378
function lerp(a, b, u) {
    return (1 - u) * a + u * b;
};


//from http://stackoverflow.com/a/5624139
function componentToHex(c) {
    var hex = c.toString(16);
    return hex.length == 1 ? "0" + hex : hex;
}

function rgbToHex(r, g, b) {
    return "#" + componentToHex(r) + componentToHex(g) + componentToHex(b);
}

function hexToRgb(hex) {
    var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
    return result ? {
        r: parseInt(result[1], 16),
        g: parseInt(result[2], 16),
        b: parseInt(result[3], 16)
    } : null;
}

function render() {
	var px = pogo.frame.body.position[0]
	if(px>secwidth) {
//		console.log("Sec #2")
	}
	
	if(px-w/50/2>secwidth) {
		removeSection(sectionA)
		removeSection(sectionB)
		sectionA=changenum(sectionB, 0, 1)
		sectionB=changenum(generateSection(), 1, 0);
//		console.log(pogo.frame.body.position[0]/secwidth)
		pogo.frame.body.position[0]-=secwidth
		pogo.stick.body.position[0]-=secwidth
//		console.log(pogo.frame.body.position[0]/secwidth)
//		console.log("Sec #1")
		addSection(sectionA)
		addSection(sectionB)
		score+=secwidth
	}
	
	if(pogo.frame.body.position[0]<0) {
		gameOver = true;
		leftplay = false;
		pogo.frame.body.position[0]=Math.max(pogo.frame.body.position[0], -2)
		pogo.frame.body.position[1]=Math.max(pogo.frame.body.position[1], -5)
	}
	// Clear the canvas
	ctx.clearRect(0, 0, w, h);
	
	if(colorful) {
		ctx.fillStyle = color.sky;
	} else {
		ctx.fillStyle = "#FFFFFF"
	}
	
	ctx.fillRect(0,0,w,h);
	ctx.fill()
	
	
	// Transform the canvas
	// Note that we need to flip the y axis since Canvas pixel coordinates
	// goes from top to bottom, while physics does the opposite.
	var xdelta = (pogo.frame.body.position[0]+xscroll)*50%secwidth<commit_msg>make it possible to generate when backtracking<commit_after>var canvas, ctx, w, h;

var colorful = true;

var colordef = {
		sky: "#4d79ff",
		skyday: "#4d79ff",
		skynight: "#241c52",
		ground: "#00b300",
		body: "#ed00ed",
		stick: "#ff66ff"
}

var color = {
		sky: "#4d79ff",
		skyday: "#4d79ff",
		skynight: "#241c52",
		ground: "#00b300",
		body: "#ed00ed",
		stick: "#ff66ff"
}

var cloudSpeed = 1;
var cloudSize = 100;
var cloudSpeedDef = 1.5;
var cloudSpeedMin = 0.2;
var cloudCnt = 5;

function moveCloud() {
	var left = this.x<-cloudSize
	var right = this.x>this.w*2+cloudSize
	if(left||right) {
		this.y = (this.h/2-20-this.h/(1.75*50)-10)*Math.random()-10
		this.speed = Math.random()*(cloudSpeedDef-cloudSpeedMin)+cloudSpeedMin
		if(left) {
			this.x = this.w+cloudSize // to right
		} else {
			this.x = -cloudSize; // to left
		}
//		this.x = (this.x+this.w)%this.w;
	}
	
	this.x+=this.speed*cloudSpeed;
}

function renderCloud() {
	ctx.shadowBlur=7;
	ctx.shadowColor="black";
	ctx.font = cloudSize+"px FontAwesome";
	ctx.globalAlpha="0.7"
	ctx.fillStyle = "#ffffff";
	ctx.textAlign = "center";
	ctx.fillText("\uf0c2", this.x-cloudSize/2, this.y)
	ctx.shadowBlur=0;
	ctx.globalAlpha="1"
}

function Cloud(x, y, speed, w, h) {
	this.x = x;
	this.y = y;
	this.w = w;
	this.h = h;
	this.speed = speed;
	this.update = moveCloud;
	this.render = renderCloud;
}

var clouds = [];

function initRender() {
	clouds = [];
	for(var i = 0; i < cloudCnt; i++) {
		clouds.push(new Cloud(Math.random()*w, (h/2-20-h/(1.75*50)-10)*Math.random()-10, Math.random()*(cloudSpeedDef-cloudSpeedMin)+cloudSpeedMin, w, h))
	}
	
	lastpx = w/50/2;
}

// Animation loop

speed = 60*5
//speed = 1/speed
var lastTime;
var maxSubSteps = 5; // Max physics ticks per render frame
var fixedDeltaTime = 1 / speed; // Physics "tick" delta time
function animate(time) {
	if(!pause) {
		requestAnimationFrame(animate);
	}
	// Get the elapsed time since last frame, in seconds
	var deltaTime = lastTime ? (time - lastTime) / 1000 : 0;
	lastTime = time;
	// Make sure the time delta is not too big (can happen if user switches
	// browser tab)
	deltaTime = Math.min(1 / 10, deltaTime);
	// Move physics bodies forward in time
	world.step(fixedDeltaTime, deltaTime, maxSubSteps);
	// Render scene
	if(!tutorialm) {
		render();
	} else {
		rendertut()
	}
}

var xscroll = 0
var yscroll = 0

var endscore = 0


//from http://stackoverflow.com/a/11293378
function lerp(a, b, u) {
    return (1 - u) * a + u * b;
};


//from http://stackoverflow.com/a/5624139
function componentToHex(c) {
    var hex = c.toString(16);
    return hex.length == 1 ? "0" + hex : hex;
}

function rgbToHex(r, g, b) {
    return "#" + componentToHex(r) + componentToHex(g) + componentToHex(b);
}

function hexToRgb(hex) {
    var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
    return result ? {
        r: parseInt(result[1], 16),
        g: parseInt(result[2], 16),
        b: parseInt(result[3], 16)
    } : null;
}

function render() {
	var px = pogo.frame.body.position[0]
	if(px>secwidth) {
//		console.log("Sec #2")
	}
	
	if(px-w/50/2>secwidth) {
		removeSection(sectionA)
		removeSection(sectionB)
		sectionA=changenum(sectionB, 0, 1)
		sectionB=changenum(generateSection(), 1, 0);
//		console.log(pogo.frame.body.position[0]/secwidth)
		pogo.frame.body.position[0]-=secwidth
		pogo.stick.body.position[0]-=secwidth
//		console.log(pogo.frame.body.position[0]/secwidth)
//		console.log("Sec #1")
		addSection(sectionA)
		addSection(sectionB)
		score+=secwidth
	}
	
	if(px<w/50/2&&secnum>2) {
		removeSection(sectionA)
		removeSection(sectionB)
		secnum-=2
		sectionB=changenum(sectionA, 1, 0)
		sectionA=generateSection()
//		console.log(pogo.frame.body.position[0]/secwidth)
		pogo.frame.body.position[0]+=secwidth
		pogo.stick.body.position[0]+=secwidth
//		console.log(pogo.frame.body.position[0]/secwidth)
//		console.log("Sec #1")
		addSection(sectionA)
		addSection(sectionB)
		score-=secwidth
	}
	
	if(pogo.frame.body.position[0]<0) {
		gameOver = true;
		leftplay = false;
		pogo.frame.body.position[0]=Math.max(pogo.frame.body.position[0], -2)
		pogo.frame.body.position[1]=Math.max(pogo.frame.body.position[1], -5)
	}
	// Clear the canvas
	ctx.clearRect(0, 0, w, h);
	
	if(colorful) {
		ctx.fillStyle = color.sky;
	} else {
		ctx.fillStyle = "#FFFFFF"
	}
	
	ctx.fillRect(0,0,w,h);
	ctx.fill()
	
	
	// Transform the canvas
	// Note that we need to flip the y axis since Canvas pixel coordinates
	// goes from top to bottom, while physics does the opposite.
	var xdelta = (pogo.frame.body.position[0]+xscroll)*50%secwidth
{'fraction_non_alphanumeric': 0.17461952168440326, 'fraction_numerical': 0.038906053324178964, 'mean_word_length': 3.583114840062926, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, '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': '7620408', 'n_tokens_mistral': 3799, 'n_tokens_neox': 3490, 'n_words': 728}