/**** 
* Classes
****/ 
//<Assets used in the game will automatically appear here>
// Class for Background
var Background = Container.expand(function () {
	var self = Container.call(this);
	var backgroundGraphics = self.attachAsset('background', {
		anchorX: 0,
		anchorY: 0
	});
});
// Class for Cooking Pot
var CookingPot = Container.expand(function () {
	var self = Container.call(this);
	var potGraphics = self.attachAsset('cookingPot', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	self.update = function () {
		// Update logic for cooking pot if needed
	};
});
// Class for Ingredients
var Ingredient = Container.expand(function () {
	var self = Container.call(this);
	var ingredientGraphics = self.attachAsset('ingredient', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	self.update = function () {
		// Update logic for ingredients if needed
	};
});
// Class for Score Display
var ScoreDisplay = Container.expand(function () {
	var self = Container.call(this);
	var scoreText = new Text2('Score: 0', {
		size: 100,
		fill: 0xFFFFFF
	});
	scoreText.anchor.set(0.5, 0);
	self.addChild(scoreText);
	self.updateScore = function (score) {
		scoreText.setText('Score: ' + score);
	};
});
/**** 
* Initialize Game
****/ 
var game = new LK.Game({
	backgroundColor: 0x000000 //Init game with black background
});
/**** 
* Game Code
****/ 
var background = game.addChild(new Background());
// Initialize game variables
var ingredients = [];
var score = 0;
var cookingPot = game.addChild(new CookingPot());
var scoreDisplay = LK.gui.top.addChild(new ScoreDisplay());
// Position the cooking pot at the bottom center of the screen
cookingPot.x = 2048 / 2;
cookingPot.y = 2732 - 200;
// Function to spawn a new ingredient
function spawnIngredient() {
	var ingredient = new Ingredient();
	ingredient.x = Math.random() * 2048;
	ingredient.y = 0;
	ingredients.push(ingredient);
	game.addChild(ingredient);
}
// Function to update the game state
game.update = function () {
	// Move ingredients down the screen
	for (var i = ingredients.length - 1; i >= 0; i--) {
		var ingredient = ingredients[i];
		ingredient.y += 5; // Move down by 5 pixels per frame
		// Check if ingredient intersects with the cooking pot
		if (ingredient.intersects(cookingPot)) {
			score += 10;
			scoreDisplay.updateScore(score);
			ingredient.destroy();
			ingredients.splice(i, 1);
		} else if (ingredient.y > 2732) {
			// Remove ingredient if it goes off screen
			ingredient.destroy();
			ingredients.splice(i, 1);
		}
	}
	// Spawn a new ingredient every 60 frames
	if (LK.ticks % 60 === 0) {
		spawnIngredient();
	}
	// Publish the game when the score reaches 100
	if (score >= 100) {
		LK.publish();
	}
}; /**** 
* Classes
****/ 
//<Assets used in the game will automatically appear here>
// Class for Background
var Background = Container.expand(function () {
	var self = Container.call(this);
	var backgroundGraphics = self.attachAsset('background', {
		anchorX: 0,
		anchorY: 0
	});
});
// Class for Cooking Pot
var CookingPot = Container.expand(function () {
	var self = Container.call(this);
	var potGraphics = self.attachAsset('cookingPot', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	self.update = function () {
		// Update logic for cooking pot if needed
	};
});
// Class for Ingredients
var Ingredient = Container.expand(function () {
	var self = Container.call(this);
	var ingredientGraphics = self.attachAsset('ingredient', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	self.update = function () {
		// Update logic for ingredients if needed
	};
});
// Class for Score Display
var ScoreDisplay = Container.expand(function () {
	var self = Container.call(this);
	var scoreText = new Text2('Score: 0', {
		size: 100,
		fill: 0xFFFFFF
	});
	scoreText.anchor.set(0.5, 0);
	self.addChild(scoreText);
	self.updateScore = function (score) {
		scoreText.setText('Score: ' + score);
	};
});
/**** 
* Initialize Game
****/ 
var game = new LK.Game({
	backgroundColor: 0x000000 //Init game with black background
});
/**** 
* Game Code
****/ 
var background = game.addChild(new Background());
// Initialize game variables
var ingredients = [];
var score = 0;
var cookingPot = game.addChild(new CookingPot());
var scoreDisplay = LK.gui.top.addChild(new ScoreDisplay());
// Position the cooking pot at the bottom center of the screen
cookingPot.x = 2048 / 2;
cookingPot.y = 2732 - 200;
// Function to spawn a new ingredient
function spawnIngredient() {
	var ingredient = new Ingredient();
	ingredient.x = Math.random() * 2048;
	ingredient.y = 0;
	ingredients.push(ingredient);
	game.addChild(ingredient);
}
// Function to update the game state
game.update = function () {
	// Move ingredients down the screen
	for (var i = ingredients.length - 1; i >= 0; i--) {
		var ingredient = ingredients[i];
		ingredient.y += 5; // Move down by 5 pixels per frame
		// Check if ingredient intersects with the cooking pot
		if (ingredient.intersects(cookingPot)) {
			score += 10;
			scoreDisplay.updateScore(score);
			ingredient.destroy();
			ingredients.splice(i, 1);
		} else if (ingredient.y > 2732) {
			// Remove ingredient if it goes off screen
			ingredient.destroy();
			ingredients.splice(i, 1);
		}
	}
	// Spawn a new ingredient every 60 frames
	if (LK.ticks % 60 === 0) {
		spawnIngredient();
	}
	// Publish the game when the score reaches 100
	if (score >= 100) {
		LK.publish();
	}
};