/**** 
* Classes
****/ 
// Food class
var Food = Container.expand(function (word) {
	var self = Container.call(this);
	var foodGraphics = self.attachAsset('food', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	var foodText = self.attachAsset(new Text2(word, {
		size: 50,
		fill: "#ffffff"
	}), {
		anchorX: 0.5,
		anchorY: 0.5
	});
	self.scaleX = 0.3;
	self.scaleY = 0.3;
});
// Assets will be automatically created based on usage in the code.
// Goose class
var Goose = Container.expand(function () {
	var self = Container.call(this);
	var gooseGraphics = self.attachAsset('goose', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	self.scaleX = 0.5;
	self.scaleY = 0.5;
	self.eat = function () {
		// Increase size slightly to simulate eating
		self.scaleX += 0.05;
		self.scaleY += 0.05;
	};
	self.clone = function () {
		var newGoose = new Goose();
		newGoose.x = Math.random() * (2048 - newGoose.width) + newGoose.width / 2;
		newGoose.y = Math.random() * (2732 - newGoose.height) + newGoose.height / 2;
		game.addChild(newGoose);
		geese.push(newGoose);
	};
});
/**** 
* Initialize Game
****/ 
var game = new LK.Game({
	backgroundColor: 0x87CEEB // Light blue background
});
/**** 
* Game Code
****/ 
var geese = [];
var foods = [];
// Create initial goose
var initialGoose = new Goose();
initialGoose.x = 1024; // Center horizontally
initialGoose.y = 1366; // Center vertically
game.addChild(initialGoose);
geese.push(initialGoose);
// Handle touch input to create food
game.on('down', function (obj) {
	var pos = obj.event.getLocalPosition(game);
	var foodWord = prompt("Type a word for food:");
	if (foodWord && foodWord.toLowerCase() === "clone") {
		geese.forEach(function (goose) {
			goose.clone();
		});
	} else {
		var food = new Food(foodWord);
		food.x = pos.x;
		food.y = pos.y;
		game.addChild(food);
		foods.push(food);
	}
});
// Check for goose eating food
LK.on('tick', function () {
	geese.forEach(function (goose) {
		foods.forEach(function (food, index) {
			if (goose.intersects(food)) {
				goose.eat();
				food.destroy();
				foods.splice(index, 1);
			}
		});
	});
}); /**** 
* Classes
****/ 
// Food class
var Food = Container.expand(function (word) {
	var self = Container.call(this);
	var foodGraphics = self.attachAsset('food', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	var foodText = self.attachAsset(new Text2(word, {
		size: 50,
		fill: "#ffffff"
	}), {
		anchorX: 0.5,
		anchorY: 0.5
	});
	self.scaleX = 0.3;
	self.scaleY = 0.3;
});
// Assets will be automatically created based on usage in the code.
// Goose class
var Goose = Container.expand(function () {
	var self = Container.call(this);
	var gooseGraphics = self.attachAsset('goose', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	self.scaleX = 0.5;
	self.scaleY = 0.5;
	self.eat = function () {
		// Increase size slightly to simulate eating
		self.scaleX += 0.05;
		self.scaleY += 0.05;
	};
	self.clone = function () {
		var newGoose = new Goose();
		newGoose.x = Math.random() * (2048 - newGoose.width) + newGoose.width / 2;
		newGoose.y = Math.random() * (2732 - newGoose.height) + newGoose.height / 2;
		game.addChild(newGoose);
		geese.push(newGoose);
	};
});
/**** 
* Initialize Game
****/ 
var game = new LK.Game({
	backgroundColor: 0x87CEEB // Light blue background
});
/**** 
* Game Code
****/ 
var geese = [];
var foods = [];
// Create initial goose
var initialGoose = new Goose();
initialGoose.x = 1024; // Center horizontally
initialGoose.y = 1366; // Center vertically
game.addChild(initialGoose);
geese.push(initialGoose);
// Handle touch input to create food
game.on('down', function (obj) {
	var pos = obj.event.getLocalPosition(game);
	var foodWord = prompt("Type a word for food:");
	if (foodWord && foodWord.toLowerCase() === "clone") {
		geese.forEach(function (goose) {
			goose.clone();
		});
	} else {
		var food = new Food(foodWord);
		food.x = pos.x;
		food.y = pos.y;
		game.addChild(food);
		foods.push(food);
	}
});
// Check for goose eating food
LK.on('tick', function () {
	geese.forEach(function (goose) {
		foods.forEach(function (food, index) {
			if (goose.intersects(food)) {
				goose.eat();
				food.destroy();
				foods.splice(index, 1);
			}
		});
	});
});