<commit_before>var framework;
var player;

var canvas;
var ctx;
var width;
var height;
var aG = 0;   // gravity acceleration (set in onload)

var minY, maxY = 0;

var bgImage;

var bgSpeed = -100;
var prevtime = 0;

var collisionCount = 0;


function Player(options, context, framework) {
	DrawableObject.call(this, options, context, framework);
}
Player.prototype = new DrawableObject({}, null, null);
Player.prototype.draw = function () {
	// this._ctx.fillStyle = "black";
	// this._ctx.fillRect(this._coordinates.x, this._coordinates.y, 30, 30);
	this._ctx.beginPath();
	this._ctx.fillStyle = "black";
	this._ctx.arc(this._coordinates.x, this._coordinates.y, this._measures.radius, 0, 2*Math.PI);
	this._ctx.fill();

	// Changing the position
	if (this._coordinates.y > maxY) {
		this._coordinates.y = maxY;
		this.stop();
	}
	if (this._coordinates.y < minY) {
		this._coordinates.y = minY;
		this.stop();
	}
};

function Background(options, context, framework) {
	DrawableObject.call(this, options, context, framework);
}
Background.prototype = new DrawableObject({}, null, null);
Background.prototype.draw = function () {
	var scaled_width = bgImage.width * (height / bgImage.height);

	this._ctx.globalAlpha = 0.3;
	this._ctx.drawImage(bgImage, this._coordinates.x, 0, scaled_width, height);
	this._ctx.drawImage(bgImage, this._coordinates.x + scaled_width, 0, scaled_width, height);
	if (Math.abs(this._coordinates.x) >= scaled_width) {
		this._coordinates.x = 0;
	}
	this._ctx.globalAlpha = 1;
};

function Brick(options, context, framework) {
	DrawableObject.call(this, options, context, framework);
}
Brick.prototype = new DrawableObject({}, null, null);
Brick.prototype.draw = function () {
	// this._ctx.fillStyle = "red";
	// this._ctx.fillRect(this._coordinates.x, this._coordinates.y, 30, 30);
	this._ctx.beginPath();
	this._ctx.fillStyle = "red";
	this._ctx.arc(this._coordinates.x, this._coordinates.y, this._measures.radius, 0, 2*Math.PI);
	this._ctx.fill();
}

var drawFrame = function (time) {
	// Respond to inputs
	document.querySelector("#fps span").innerHTML = framework.getFPS();
	if (framework.getInputState().up) {
		text = "up";
		player.setAcceleration({y: aG * -3});
	} else {
		text = "nothing";
		player.setAcceleration({y: aG});
	}
	document.querySelector("#inputStates span").innerHTML = text;
	document.querySelector("#collisionCount span").innerHTML = collisionCount;

	// Create the bricks
	if (time - prevtime > 1000) {
		prevtime = time;
		bricks.push(new Brick({
			x: width + 20,
			y: Math.floor((Math.random() * height) + 1),
			speedX: bgSpeed
		}, ctx, framework));
	}

	// Draw the thing
	// Clear the canvas
	ctx.clearRect(0, 0, width, height);

	// Draw the background
	background.drawFrame();

	// Draw the player
	player.drawFrame();

	// Draw the brick
	bricks.forEach(function (brick) {
		if (!brick.collided && brick.isCollidingWith(player)) {
			collisionCount++;
			brick.collided = true;
		}
		brick.drawFrame();
	});
}

window.onload = function init() {
	canvas = document.querySelector("#screamy");
	ctx = canvas.getContext('2d');
	width = canvas.width;
	height = canvas.height;
	minY = 21;
	maxY = height - 21;
	aG = Math.round(height * 0.75);

	bgImage = new Image();
	bgImage.src = "img/full-background.png";

	framework = new GameFramework();<commit_msg>Added resiezed background<commit_after>var framework;
var player;

var canvas;
var ctx;
var width;
var height;
var aG = 0;   // gravity acceleration (set in onload)

var minY, maxY = 0;

var bgImage;

var bgSpeed = -100;
var prevtime = 0;

var collisionCount = 0;


function Player(options, context, framework) {
	DrawableObject.call(this, options, context, framework);
}
Player.prototype = new DrawableObject({}, null, null);
Player.prototype.draw = function () {
	// this._ctx.fillStyle = "black";
	// this._ctx.fillRect(this._coordinates.x, this._coordinates.y, 30, 30);
	this._ctx.beginPath();
	this._ctx.fillStyle = "black";
	this._ctx.arc(this._coordinates.x, this._coordinates.y, this._measures.radius, 0, 2*Math.PI);
	this._ctx.fill();

	// Changing the position
	if (this._coordinates.y > maxY) {
		this._coordinates.y = maxY;
		this.stop();
	}
	if (this._coordinates.y < minY) {
		this._coordinates.y = minY;
		this.stop();
	}
};

function Background(options, context, framework) {
	DrawableObject.call(this, options, context, framework);
}
Background.prototype = new DrawableObject({}, null, null);
Background.prototype.draw = function () {
	this._ctx.globalAlpha = 0.3;
	this._ctx.drawImage(bgImage, this._coordinates.x, 0);
	this._ctx.drawImage(bgImage, this._coordinates.x + width, 0);
	if (Math.abs(this._coordinates.x) >= width) {
		this._coordinates.x = 0;
	}
	this._ctx.globalAlpha = 1;
};

function Brick(options, context, framework) {
	DrawableObject.call(this, options, context, framework);
}
Brick.prototype = new DrawableObject({}, null, null);
Brick.prototype.draw = function () {
	// this._ctx.fillStyle = "red";
	// this._ctx.fillRect(this._coordinates.x, this._coordinates.y, 30, 30);
	this._ctx.beginPath();
	this._ctx.fillStyle = "red";
	this._ctx.arc(this._coordinates.x, this._coordinates.y, this._measures.radius, 0, 2*Math.PI);
	this._ctx.fill();
}

var drawFrame = function (time) {
	// Respond to inputs
	document.querySelector("#fps span").innerHTML = framework.getFPS();
	if (framework.getInputState().up) {
		text = "up";
		player.setAcceleration({y: aG * -3});
	} else {
		text = "nothing";
		player.setAcceleration({y: aG});
	}
	document.querySelector("#inputStates span").innerHTML = text;
	document.querySelector("#collisionCount span").innerHTML = collisionCount;

	// Create the bricks
	if (time - prevtime > 1000) {
		prevtime = time;
		bricks.push(new Brick({
			x: width + 20,
			y: Math.floor((Math.random() * height) + 1),
			speedX: bgSpeed
		}, ctx, framework));
	}

	// Draw the thing
	// Clear the canvas
	ctx.clearRect(0, 0, width, height);

	// Draw the background
	background.drawFrame();

	// Draw the player
	player.drawFrame();

	// Draw the brick
	bricks.forEach(function (brick) {
		if (!brick.collided && brick.isCollidingWith(player)) {
			collisionCount++;
			brick.collided = true;
		}
		brick.drawFrame();
	});
}

window.onload = function init() {
	canvas = document.querySelector("#screamy");
	ctx = canvas.getContext('2d');
	width = canvas.width;
	height = canvas.height;
	minY = 21;
	maxY = height - 21;
	aG = Math.round(height * 0.75);

	bgImage = new Image();
	bgImage.src = "img/full-background_500_1000.png";

	framework = new GameFramework();
{'fraction_non_alphanumeric': 0.15949793356803918, 'fraction_numerical': 0.014235420174498699, 'mean_word_length': 4.202229299363057, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '441510', 'n_tokens_mistral': 2410, 'n_tokens_neox': 2252, 'n_words': 506}