<commit_before>var canvas = document.getElementById("canvas");
canvas.width = 400;
canvas.height = 400;
var ctx = canvas.getContext("2d");

var clearCanvas = function(){
	ctx.fillStyle = "black";
	ctx.fillRect(0, 0, canvas.width, canvas.height);
}

function Platform(x, y, width, height){
	this.x = x;
	this.y = y;
	this.width = width; 
	this.height = height;
}
Platform.prototype.color = "red";

Platform.prototype.draw = function(){
	ctx.fillStyle = this.color;
	ctx.fillRect(this.x, this.y, this.width, this.height);
}

var platform = new Platform(150, 300, 200, 20);
var moveDir = 1;
setInterval(function(){
	platform.x += 10 * moveDir;
	if(platform.x + platform.width > 400)
		moveDir *= -1;
	if(platform.x < 0)
		moveDir *= -1;
	clearCanvas();
	platform.draw();
}, 100);<commit_msg>Moved update code to update function.<commit_after>var canvas = document.getElementById("canvas");
canvas.width = 400;
canvas.height = 400;
var ctx = canvas.getContext("2d");

var clearCanvas = function(){
	ctx.fillStyle = "black";
	ctx.fillRect(0, 0, canvas.width, canvas.height);
}

function Platform(x, y, width, height){
	this.x = x;
	this.y = y;
	this.width = width; 
	this.height = height;
}
Platform.prototype.color = "red";

Platform.prototype.draw = function(){
	ctx.fillStyle = this.color;
	ctx.fillRect(this.x, this.y, this.width, this.height);
}

Platform.prototype.update = function(){
	this.x += 10 * moveDir;
	if(this.x + this.width > canvas.width)
		moveDir *= -1;
	if(this.x < 0)
		moveDir *= -1;
}

var platform = new Platform(150, 300, 200, 20);
var moveDir = 1;
setInterval(function(){
	platform.update();
	clearCanvas();
	platform.draw();
}, 100);
{'fraction_non_alphanumeric': 0.1721014492753623, 'fraction_numerical': 0.03683574879227053, 'mean_word_length': 4.37987012987013, 'pattern_counts': {'":': 0, '<': 5, '<?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': '1235938', 'n_tokens_mistral': 642, 'n_tokens_neox': 586, 'n_words': 143}