User prompt
when apple touches player make the game end
User prompt
spawn less apples
User prompt
change the time from 60 seconds to 10 seconds
User prompt
add a timer on top which shows when the 60 seconds are done
User prompt
Please fix the bug: 'TypeError: LK.isGameOver is not a function. (In 'LK.isGameOver()', 'LK.isGameOver' is undefined)' in or related to this line: 'if (LK.isGameOver()) {' Line Number: 84
User prompt
only allow the game to run for 60 seconds
User prompt
every time you shoot a apple it updates your score
User prompt
make it so you can shoot the apples
User prompt
add apples that spawn as enemies from the top of the screen
User prompt
add vertical movement as well
User prompt
remove enemies
Initial prompt
Apple shooter
/**** 
* Classes
****/ 
// Apple class
var Apple = Container.expand(function () {
	var self = Container.call(this);
	var appleGraphics = self.attachAsset('apple', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	self.speed = 5;
	self.move = function () {
		self.y += self.speed;
	};
});
// Bullet class
var Bullet = Container.expand(function () {
	var self = Container.call(this);
	var bulletGraphics = self.attachAsset('bullet', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	self.speed = -10;
	self.move = function () {
		self.y += self.speed;
	};
});
// Assets are automatically created based on usage in the code.
// Player class
var Player = Container.expand(function () {
	var self = Container.call(this);
	var playerGraphics = self.attachAsset('player', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	self.move = function (x, y) {
		self.x = x;
		self.y = y;
	};
	self.shoot = function () {
		var bullet = new Bullet();
		bullet.x = self.x;
		bullet.y = self.y - 50; // Shoot from above the player
		game.addChild(bullet);
		bullets.push(bullet);
	};
});
/**** 
* Initialize Game
****/ 
var game = new LK.Game({
	backgroundColor: 0x000000 // Init game with black background 
});
/**** 
* Game Code
****/ 
var player = game.addChild(new Player());
player.x = 1024; // Center horizontally
player.y = 2500; // Position towards the bottom
var bullets = [];
var apples = [];
// Touch event to move player and shoot
game.on('down', function (obj) {
	var pos = obj.event.getLocalPosition(game);
	player.move(pos.x, pos.y);
	player.shoot();
});
// Game tick event
LK.on('tick', function () {
	// Spawn apples
	if (LK.ticks % 60 == 0) {
		// Every second
		var apple = new Apple();
		apple.x = Math.random() * 2048; // Random horizontal position
		apple.y = 0; // Spawn at the top of the screen
		game.addChild(apple);
		apples.push(apple);
	}
	// Move bullets
	for (var i = bullets.length - 1; i >= 0; i--) {
		bullets[i].move();
		if (bullets[i].y < 0) {
			bullets[i].destroy();
			bullets.splice(i, 1);
		}
	}
	// Move apples
	for (var i = apples.length - 1; i >= 0; i--) {
		apples[i].move();
		if (apples[i].y > 2732) {
			// If apple has reached the bottom of the screen
			apples[i].destroy();
			apples.splice(i, 1);
		}
	}
}); ===================================================================
--- original.js
+++ change.js
@@ -1,7 +1,19 @@
 /**** 
 * Classes
 ****/ 
+// Apple class
+var Apple = Container.expand(function () {
+	var self = Container.call(this);
+	var appleGraphics = self.attachAsset('apple', {
+		anchorX: 0.5,
+		anchorY: 0.5
+	});
+	self.speed = 5;
+	self.move = function () {
+		self.y += self.speed;
+	};
+});
 // Bullet class
 var Bullet = Container.expand(function () {
 	var self = Container.call(this);
 	var bulletGraphics = self.attachAsset('bullet', {
@@ -47,21 +59,40 @@
 var player = game.addChild(new Player());
 player.x = 1024; // Center horizontally
 player.y = 2500; // Position towards the bottom
 var bullets = [];
+var apples = [];
 // Touch event to move player and shoot
 game.on('down', function (obj) {
 	var pos = obj.event.getLocalPosition(game);
 	player.move(pos.x, pos.y);
 	player.shoot();
 });
 // Game tick event
 LK.on('tick', function () {
+	// Spawn apples
+	if (LK.ticks % 60 == 0) {
+		// Every second
+		var apple = new Apple();
+		apple.x = Math.random() * 2048; // Random horizontal position
+		apple.y = 0; // Spawn at the top of the screen
+		game.addChild(apple);
+		apples.push(apple);
+	}
 	// Move bullets
 	for (var i = bullets.length - 1; i >= 0; i--) {
 		bullets[i].move();
 		if (bullets[i].y < 0) {
 			bullets[i].destroy();
 			bullets.splice(i, 1);
 		}
 	}
+	// Move apples
+	for (var i = apples.length - 1; i >= 0; i--) {
+		apples[i].move();
+		if (apples[i].y > 2732) {
+			// If apple has reached the bottom of the screen
+			apples[i].destroy();
+			apples.splice(i, 1);
+		}
+	}
 });
\ No newline at end of file