/**** 
* Classes
****/ 
//<Assets used in the game will automatically appear here>
// Fruit class to represent each fruit coming from the right side
var Fruit = Container.expand(function () {
	var self = Container.call(this);
	// Attach a fruit asset, assuming a generic fruit shape is available
	var fruitTypes = ['mango', 'apple', 'banana', 'grape'];
	var randomFruit = fruitTypes[Math.floor(Math.random() * fruitTypes.length)];
	var fruitGraphics = self.attachAsset(randomFruit, {
		anchorX: 0.5,
		anchorY: 0.5
	});
	// Set initial speed for the fruit
	self.speed = -5;
	// Update function to move the fruit leftwards
	self.update = function () {
		self.x += self.speed;
	};
});
var Knife = Container.expand(function () {
	var self = Container.call(this);
	var knifeGraphics = self.attachAsset('knife', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	self.update = function () {
		self.y += self.speed;
	};
});
var Obstacle = Container.expand(function () {
	var self = Container.call(this);
	var obstacleGraphics = self.attachAsset('obstacle', {
		anchorX: 0.5,
		anchorY: 0.5,
		scaleX: 2,
		scaleY: 2
	});
	self.speed = -5;
	self.update = function () {
		self.x += self.speed;
	};
});
/**** 
* Initialize Game
****/ 
var game = new LK.Game({
	backgroundColor: 0x00FFFF // Set background color to cyan
});
/**** 
* Game Code
****/ 
// Play background music
LK.playMusic('LIFE', {
	loop: true
});
var fruits = [];
var knife = game.addChild(new Knife());
knife.x = 2048 / 2;
knife.y = 2732 / 2;
var fruitCount = 0;
var maxFruits = 10000;
// Create and display the score text
var scoreTxt = new Text2('0', {
	size: 150,
	fill: "#ff0000",
	fontWeight: "bold"
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Add a small text that says 'DO NOT TOUCH ROCK'
var warningTxt = new Text2('DO NOT TOUCH ROCK', {
	size: 50,
	fill: "#ffffff"
});
warningTxt.anchor.set(0.5, 0);
LK.gui.bottom.addChild(warningTxt);
// Function to update the score display
function updateScoreDisplay() {
	scoreTxt.setText(LK.getScore());
}
// Function to handle game updates
var dragNode = null;
function handleMove(x, y, obj) {
	if (dragNode) {
		dragNode.x = x;
		dragNode.y = y;
	}
}
game.move = handleMove;
game.down = function (x, y, obj) {
	dragNode = knife;
	handleMove(x, y, obj);
};
game.up = function (x, y, obj) {
	dragNode = null;
};
game.update = function () {
	// Create new fruits at regular intervals
	if (LK.ticks % 30 == 0 && fruitCount < maxFruits) {
		var newFruit = new Fruit();
		newFruit.x = 2048; // Start from the right side
		newFruit.y = Math.random() * 2732; // Random y position
		fruits.push(newFruit);
		game.addChild(newFruit);
		fruitCount++;
	}
	// Update each fruit's position
	for (var i = fruits.length - 1; i >= 0; i--) {
		fruits[i].update();
		// Remove fruits that have moved off the left side of the screen
		if (fruits[i].x < -50) {
			fruits[i].destroy();
			fruits.splice(i, 1);
		}
		// Add points for cutting fruits
		if (knife.intersects(fruits[i])) {
			fruits[i].destroy();
			fruits.splice(i, 1);
			if (fruits[i] && fruits[i].assetId === '670be8300c26e18447ad576e') {
				// Check if the fruit is a banana
				LK.setScore(LK.getScore() + 10); // Add 10 points for cutting a banana
			} else {
				LK.setScore(LK.getScore() + 1); // Add 1 point for other fruits
			}
			updateScoreDisplay();
		}
	}
	// Create new obstacles at regular intervals
	if (LK.ticks % 60 == 0) {
		var newObstacle = new Obstacle();
		newObstacle.x = 2048; // Start from the right side
		newObstacle.y = Math.random() * 2732; // Random y position
		game.addChild(newObstacle);
	}
	// Update each obstacle's position
	for (var j = game.children.length - 1; j >= 0; j--) {
		if (game.children[j] instanceof Obstacle) {
			game.children[j].update();
			// Remove obstacles that have moved off the left side of the screen
			if (game.children[j].x < -50) {
				game.children[j].destroy();
				game.children.splice(j, 1);
			}
			// End game if knife intersects with an obstacle
			if (knife.intersects(game.children[j])) {
				LK.showGameOver();
			}
		}
	}
	// End the game after 20 seconds
	if (LK.ticks >= 1200) {
		// 20 seconds * 60 FPS = 1200 ticks
		LK.showGameOver();
	}
}; /**** 
* Classes
****/ 
//<Assets used in the game will automatically appear here>
// Fruit class to represent each fruit coming from the right side
var Fruit = Container.expand(function () {
	var self = Container.call(this);
	// Attach a fruit asset, assuming a generic fruit shape is available
	var fruitTypes = ['mango', 'apple', 'banana', 'grape'];
	var randomFruit = fruitTypes[Math.floor(Math.random() * fruitTypes.length)];
	var fruitGraphics = self.attachAsset(randomFruit, {
		anchorX: 0.5,
		anchorY: 0.5
	});
	// Set initial speed for the fruit
	self.speed = -5;
	// Update function to move the fruit leftwards
	self.update = function () {
		self.x += self.speed;
	};
});
var Knife = Container.expand(function () {
	var self = Container.call(this);
	var knifeGraphics = self.attachAsset('knife', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	self.update = function () {
		self.y += self.speed;
	};
});
var Obstacle = Container.expand(function () {
	var self = Container.call(this);
	var obstacleGraphics = self.attachAsset('obstacle', {
		anchorX: 0.5,
		anchorY: 0.5,
		scaleX: 2,
		scaleY: 2
	});
	self.speed = -5;
	self.update = function () {
		self.x += self.speed;
	};
});
/**** 
* Initialize Game
****/ 
var game = new LK.Game({
	backgroundColor: 0x00FFFF // Set background color to cyan
});
/**** 
* Game Code
****/ 
// Play background music
LK.playMusic('LIFE', {
	loop: true
});
var fruits = [];
var knife = game.addChild(new Knife());
knife.x = 2048 / 2;
knife.y = 2732 / 2;
var fruitCount = 0;
var maxFruits = 10000;
// Create and display the score text
var scoreTxt = new Text2('0', {
	size: 150,
	fill: "#ff0000",
	fontWeight: "bold"
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Add a small text that says 'DO NOT TOUCH ROCK'
var warningTxt = new Text2('DO NOT TOUCH ROCK', {
	size: 50,
	fill: "#ffffff"
});
warningTxt.anchor.set(0.5, 0);
LK.gui.bottom.addChild(warningTxt);
// Function to update the score display
function updateScoreDisplay() {
	scoreTxt.setText(LK.getScore());
}
// Function to handle game updates
var dragNode = null;
function handleMove(x, y, obj) {
	if (dragNode) {
		dragNode.x = x;
		dragNode.y = y;
	}
}
game.move = handleMove;
game.down = function (x, y, obj) {
	dragNode = knife;
	handleMove(x, y, obj);
};
game.up = function (x, y, obj) {
	dragNode = null;
};
game.update = function () {
	// Create new fruits at regular intervals
	if (LK.ticks % 30 == 0 && fruitCount < maxFruits) {
		var newFruit = new Fruit();
		newFruit.x = 2048; // Start from the right side
		newFruit.y = Math.random() * 2732; // Random y position
		fruits.push(newFruit);
		game.addChild(newFruit);
		fruitCount++;
	}
	// Update each fruit's position
	for (var i = fruits.length - 1; i >= 0; i--) {
		fruits[i].update();
		// Remove fruits that have moved off the left side of the screen
		if (fruits[i].x < -50) {
			fruits[i].destroy();
			fruits.splice(i, 1);
		}
		// Add points for cutting fruits
		if (knife.intersects(fruits[i])) {
			fruits[i].destroy();
			fruits.splice(i, 1);
			if (fruits[i] && fruits[i].assetId === '670be8300c26e18447ad576e') {
				// Check if the fruit is a banana
				LK.setScore(LK.getScore() + 10); // Add 10 points for cutting a banana
			} else {
				LK.setScore(LK.getScore() + 1); // Add 1 point for other fruits
			}
			updateScoreDisplay();
		}
	}
	// Create new obstacles at regular intervals
	if (LK.ticks % 60 == 0) {
		var newObstacle = new Obstacle();
		newObstacle.x = 2048; // Start from the right side
		newObstacle.y = Math.random() * 2732; // Random y position
		game.addChild(newObstacle);
	}
	// Update each obstacle's position
	for (var j = game.children.length - 1; j >= 0; j--) {
		if (game.children[j] instanceof Obstacle) {
			game.children[j].update();
			// Remove obstacles that have moved off the left side of the screen
			if (game.children[j].x < -50) {
				game.children[j].destroy();
				game.children.splice(j, 1);
			}
			// End game if knife intersects with an obstacle
			if (knife.intersects(game.children[j])) {
				LK.showGameOver();
			}
		}
	}
	// End the game after 20 seconds
	if (LK.ticks >= 1200) {
		// 20 seconds * 60 FPS = 1200 ticks
		LK.showGameOver();
	}
};