LK.getAsset('target9', 'Target Graphics 9', 0.5, 0.5);
LK.getAsset('target8', 'Target Graphics 8', 0.5, 0.5);
LK.getAsset('target7', 'Target Graphics 7', 0.5, 0.5);
LK.getAsset('target6', 'Target Graphics 6', 0.5, 0.5);
LK.getAsset('target5', 'Target Graphics 5', 0.5, 0.5);
LK.getAsset('target4', 'Target Graphics 4', 0.5, 0.5);
LK.getAsset('target3', 'Target Graphics 3', 0.5, 0.5);
var Particle = Container.expand(function () {
	var self = Container.call(this);
	var particleGraphics = self.createAsset('particle', 'Particle Graphics', .5, .5);
	self.speed = Math.random() * 5 + 2;
	self.direction = Math.random() * Math.PI * 2;
	self.alpha = 1;
	self.move = function () {
		self.x += Math.cos(self.direction) * self.speed;
		self.y += Math.sin(self.direction) * self.speed;
		self.alpha -= 0.02;
		if (self.alpha <= 0) self.destroy();
	};
});
var Projectile = Container.expand(function () {
	var self = Container.call(this);
	var projectileGraphics = self.createAsset('projectile', 'Projectile Graphics', .5, .5);
	self.speed = 14;
	self.direction = '';
	self.move = function () {
		if (self.direction === 'up') self.y -= self.speed;
		if (self.direction === 'down') self.y += self.speed;
		if (self.direction === 'left') self.x -= self.speed;
		if (self.direction === 'right') self.x += self.speed;
	};
});
var Target = Container.expand(function (game_level) {
	var self = Container.call(this);
	var targetID = "target" + game_level % 9;
	var targetGraphics = self.createAsset(targetID, 'Target Graphics', .5, .5);
	self.speed = 4 + game_level;
	if (self.speed > 9) self.speed = 9;
	self.direction = Math.random() < 0.5 ? 'horizontal' : 'vertical';
	self.move = function () {
		if (self.direction === 'horizontal') {
			self.x += self.speed;
			if (self.x > 2048) self.x = 0;
			if (self.x < 0) self.x = 2048;
		} else {
			self.y += self.speed;
			if (self.y > 2732) self.y = 0;
			if (self.y < 0) self.y = 2732;
		}
	};
});
var Game = Container.expand(function () {
	var self = Container.call(this);
	var background = self.createAsset('background', 'Game Background', 0.5, 0.5);
	background.width = 2048;
	background.height = 2732;
	background.x = 1024;
	background.y = 1366;
	background.alpha = 0.15;
	self.addChildAt(background, 0);
	var instructionsText = new Text2('Tap anywhere to launch projectiles\nand destroy targets.\n\nSpare your touches!', {
		size: 70,
		fill: '#ffffff',
		align: 'center'
	});
	instructionsText.anchor.set(0.5, 0.5);
	instructionsText.x = 2048 / 2 - 2048 / 7;
	instructionsText.y = 1000;
	LK.gui.addChild(instructionsText);
	self.level = 1;
	self.touchesLeft = 5;
	self.targetsLeft = 5;
	self.points = 0;
	self.numberOfProjectiles = 0;
	var levelText = new Text2('Level: ' + self.level, {
		size: 70,
		fill: "#ffffff"
	});
	levelText.anchor.set(0, 1);
	LK.gui.bottomLeft.addChild(levelText);
	var touchesLeftText = new Text2('Touches Left: ' + self.touchesLeft, {
		size: 70,
		fill: "#ffffff"
	});
	touchesLeftText.anchor.set(0, 0);
	touchesLeftText.y = 50;
	touchesLeftText.x = 140;
	LK.gui.topCenter.addChild(touchesLeftText);
	var pointsText = new Text2('Score: ' + self.points, {
		size: 70,
		fill: "#ffffff"
	});
	pointsText.anchor.set(0, 0);
	pointsText.x = 140;
	pointsText.y = 140;
	LK.gui.topCenter.addChild(pointsText);
	var targetsLeftText = new Text2('Targets Left: ' + self.targetsLeft, {
		size: 70,
		fill: "#ffffff"
	});
	var projectiles = [];
	var enemies = [];
	var targets = [];
	var touchesLeft = 5;
	for (var i = 0; i < 5; i++) {
		var target = new Target(self.level);
		target.x = Math.random() * (2048 - 100) + 50;
		target.y = Math.random() * (2732 - 100) + 50;
		targets.push(target);
		self.addChild(target);
	}
	var spawnEnemy = function () {
		var enemy = new Enemy();
		enemy.x = Math.random() * 2048;
		enemy.y = 0;
		enemies.push(enemy);
		self.addChild(enemy);
	};
	LK.on('tick', function () {
		if (projectiles.length === 0 && self.touchesLeft === 0) {
			LK.effects.flashObject(touchesLeftText, 0xff0000, 1000);
			LK.setTimeout(function () {
				LK.showGameOver();
			}, 1000);
		}
		for (var i = 0; i < targets.length; i++) {
			targets[i].move();
		}
		for (var i = 0; i < self.children.length; i++) {
			if (self.children[i] instanceof Projectile) {
				if (self.children[i].x < 0 || self.children[i].x > 2048 || self.children[i].y < 0 || self.children[i].y > 2732) {
					var index1 = projectiles.indexOf(self.children[i]);
					if (index1 > -1) {
						projectiles.splice(index1, 1);
						self.numberOfProjectiles--;
						self.children[i].destroy();
					}
				}
			}
			if (self.children[i] instanceof Projectile || self.children[i] instanceof Particle) {
				self.children[i].move();
				for (var j = 0; j < targets.length; j++) {
					if (self.children[i] && targets[j] && self.children[i].intersects(targets[j])) {
						var directions = ['up', 'down', 'left', 'right'];
						for (var k = 0; k < 4; k++) {
							var newProjectile = new Projectile();
							newProjectile.x = targets[j].x;
							newProjectile.y = targets[j].y;
							newProjectile.direction = directions[k];
							projectiles.push(newProjectile);
							self.addChild(newProjectile);
						}
						var index = projectiles.indexOf(self.children[i]);
						if (index > -1) {
							projectiles.splice(index, 1);
							self.numberOfProjectiles--;
							self.children[i].destroy();
						}
						targets[j].destroy();
						self.targetsLeft--;
						self.points += 10;
						pointsText.setText('Score: ' + self.points);
						targets.splice(j, 1);
						targetsLeftText.setText('Targets Left: ' + self.targetsLeft);
						if (self.targetsLeft <= 0) {
							self.level++;
							if (self.level > 9) self.level = 1;
							for (var i = self.children.length - 1; i >= 0; i--) {
								if (self.children[i] instanceof Projectile) {
									self.children[i].destroy();
								}
							}
							var levelUpText = new Text2('Level ' + self.level + '!', {
								size: 70,
								fill: '#ffffff',
								align: 'center'
							});
							levelUpText.anchor.set(0.5, 0.5);
							levelUpText.x = 700;
							levelUpText.y = 1000;
							LK.gui.addChild(levelUpText);
							var blinkInterval = LK.setInterval(function () {
								levelUpText.visible = !levelUpText.visible;
							}, 150);
							LK.setTimeout(function () {
								LK.clearInterval(blinkInterval);
								levelUpText.destroy();
								levelText.setText('Level: ' + self.level);
							}, 1500);
							LK.setTimeout(function () {
								for (var i = 0; i < 5 + Math.floor(self.level / 2); i++) {
									var target = new Target(self.level);
									target.x = Math.random() * 2048;
									target.y = Math.random() * 2732;
									targets.push(target);
									self.addChild(target);
								}
								self.targetsLeft = 5 + Math.floor(self.level / 2);
								targetsLeftText.setText('Targets Left: ' + self.targetsLeft);
								projectiles = [];
								self.touchesLeft += 2;
								touchesLeftText.setText('Touches Left: ' + self.touchesLeft);
							}, 2000);
						}
					}
				}
			}
		}
	});
	stage.on('down', function (obj) {
		if (instructionsText) {
			instructionsText.setText('');
		}
		if (self.touchesLeft > 0) {
			var pos = obj.event.getLocalPosition(self);
			var directions = ['up', 'down', 'left', 'right'];
			for (var i = 0; i < 4; i++) {
				var projectile = new Projectile();
				projectile.x = pos.x;
				projectile.y = pos.y;
				projectile.direction = directions[i];
				self.numberOfProjectiles++;
				projectile.on('destroy', function () {
					var index = projectiles.indexOf(projectile);
					if (index > -1) {
						projectiles.splice(index, 1);
					}
				});
				self.addChild(projectile);
				projectiles.push(projectile);
			}
			self.touchesLeft--;
			touchesLeftText.setText('Touches Left: ' + self.touchesLeft);
		}
	});
});
 LK.getAsset('target9', 'Target Graphics 9', 0.5, 0.5);
LK.getAsset('target8', 'Target Graphics 8', 0.5, 0.5);
LK.getAsset('target7', 'Target Graphics 7', 0.5, 0.5);
LK.getAsset('target6', 'Target Graphics 6', 0.5, 0.5);
LK.getAsset('target5', 'Target Graphics 5', 0.5, 0.5);
LK.getAsset('target4', 'Target Graphics 4', 0.5, 0.5);
LK.getAsset('target3', 'Target Graphics 3', 0.5, 0.5);
var Particle = Container.expand(function () {
	var self = Container.call(this);
	var particleGraphics = self.createAsset('particle', 'Particle Graphics', .5, .5);
	self.speed = Math.random() * 5 + 2;
	self.direction = Math.random() * Math.PI * 2;
	self.alpha = 1;
	self.move = function () {
		self.x += Math.cos(self.direction) * self.speed;
		self.y += Math.sin(self.direction) * self.speed;
		self.alpha -= 0.02;
		if (self.alpha <= 0) self.destroy();
	};
});
var Projectile = Container.expand(function () {
	var self = Container.call(this);
	var projectileGraphics = self.createAsset('projectile', 'Projectile Graphics', .5, .5);
	self.speed = 14;
	self.direction = '';
	self.move = function () {
		if (self.direction === 'up') self.y -= self.speed;
		if (self.direction === 'down') self.y += self.speed;
		if (self.direction === 'left') self.x -= self.speed;
		if (self.direction === 'right') self.x += self.speed;
	};
});
var Target = Container.expand(function (game_level) {
	var self = Container.call(this);
	var targetID = "target" + game_level % 9;
	var targetGraphics = self.createAsset(targetID, 'Target Graphics', .5, .5);
	self.speed = 4 + game_level;
	if (self.speed > 9) self.speed = 9;
	self.direction = Math.random() < 0.5 ? 'horizontal' : 'vertical';
	self.move = function () {
		if (self.direction === 'horizontal') {
			self.x += self.speed;
			if (self.x > 2048) self.x = 0;
			if (self.x < 0) self.x = 2048;
		} else {
			self.y += self.speed;
			if (self.y > 2732) self.y = 0;
			if (self.y < 0) self.y = 2732;
		}
	};
});
var Game = Container.expand(function () {
	var self = Container.call(this);
	var background = self.createAsset('background', 'Game Background', 0.5, 0.5);
	background.width = 2048;
	background.height = 2732;
	background.x = 1024;
	background.y = 1366;
	background.alpha = 0.15;
	self.addChildAt(background, 0);
	var instructionsText = new Text2('Tap anywhere to launch projectiles\nand destroy targets.\n\nSpare your touches!', {
		size: 70,
		fill: '#ffffff',
		align: 'center'
	});
	instructionsText.anchor.set(0.5, 0.5);
	instructionsText.x = 2048 / 2 - 2048 / 7;
	instructionsText.y = 1000;
	LK.gui.addChild(instructionsText);
	self.level = 1;
	self.touchesLeft = 5;
	self.targetsLeft = 5;
	self.points = 0;
	self.numberOfProjectiles = 0;
	var levelText = new Text2('Level: ' + self.level, {
		size: 70,
		fill: "#ffffff"
	});
	levelText.anchor.set(0, 1);
	LK.gui.bottomLeft.addChild(levelText);
	var touchesLeftText = new Text2('Touches Left: ' + self.touchesLeft, {
		size: 70,
		fill: "#ffffff"
	});
	touchesLeftText.anchor.set(0, 0);
	touchesLeftText.y = 50;
	touchesLeftText.x = 140;
	LK.gui.topCenter.addChild(touchesLeftText);
	var pointsText = new Text2('Score: ' + self.points, {
		size: 70,
		fill: "#ffffff"
	});
	pointsText.anchor.set(0, 0);
	pointsText.x = 140;
	pointsText.y = 140;
	LK.gui.topCenter.addChild(pointsText);
	var targetsLeftText = new Text2('Targets Left: ' + self.targetsLeft, {
		size: 70,
		fill: "#ffffff"
	});
	var projectiles = [];
	var enemies = [];
	var targets = [];
	var touchesLeft = 5;
	for (var i = 0; i < 5; i++) {
		var target = new Target(self.level);
		target.x = Math.random() * (2048 - 100) + 50;
		target.y = Math.random() * (2732 - 100) + 50;
		targets.push(target);
		self.addChild(target);
	}
	var spawnEnemy = function () {
		var enemy = new Enemy();
		enemy.x = Math.random() * 2048;
		enemy.y = 0;
		enemies.push(enemy);
		self.addChild(enemy);
	};
	LK.on('tick', function () {
		if (projectiles.length === 0 && self.touchesLeft === 0) {
			LK.effects.flashObject(touchesLeftText, 0xff0000, 1000);
			LK.setTimeout(function () {
				LK.showGameOver();
			}, 1000);
		}
		for (var i = 0; i < targets.length; i++) {
			targets[i].move();
		}
		for (var i = 0; i < self.children.length; i++) {
			if (self.children[i] instanceof Projectile) {
				if (self.children[i].x < 0 || self.children[i].x > 2048 || self.children[i].y < 0 || self.children[i].y > 2732) {
					var index1 = projectiles.indexOf(self.children[i]);
					if (index1 > -1) {
						projectiles.splice(index1, 1);
						self.numberOfProjectiles--;
						self.children[i].destroy();
					}
				}
			}
			if (self.children[i] instanceof Projectile || self.children[i] instanceof Particle) {
				self.children[i].move();
				for (var j = 0; j < targets.length; j++) {
					if (self.children[i] && targets[j] && self.children[i].intersects(targets[j])) {
						var directions = ['up', 'down', 'left', 'right'];
						for (var k = 0; k < 4; k++) {
							var newProjectile = new Projectile();
							newProjectile.x = targets[j].x;
							newProjectile.y = targets[j].y;
							newProjectile.direction = directions[k];
							projectiles.push(newProjectile);
							self.addChild(newProjectile);
						}
						var index = projectiles.indexOf(self.children[i]);
						if (index > -1) {
							projectiles.splice(index, 1);
							self.numberOfProjectiles--;
							self.children[i].destroy();
						}
						targets[j].destroy();
						self.targetsLeft--;
						self.points += 10;
						pointsText.setText('Score: ' + self.points);
						targets.splice(j, 1);
						targetsLeftText.setText('Targets Left: ' + self.targetsLeft);
						if (self.targetsLeft <= 0) {
							self.level++;
							if (self.level > 9) self.level = 1;
							for (var i = self.children.length - 1; i >= 0; i--) {
								if (self.children[i] instanceof Projectile) {
									self.children[i].destroy();
								}
							}
							var levelUpText = new Text2('Level ' + self.level + '!', {
								size: 70,
								fill: '#ffffff',
								align: 'center'
							});
							levelUpText.anchor.set(0.5, 0.5);
							levelUpText.x = 700;
							levelUpText.y = 1000;
							LK.gui.addChild(levelUpText);
							var blinkInterval = LK.setInterval(function () {
								levelUpText.visible = !levelUpText.visible;
							}, 150);
							LK.setTimeout(function () {
								LK.clearInterval(blinkInterval);
								levelUpText.destroy();
								levelText.setText('Level: ' + self.level);
							}, 1500);
							LK.setTimeout(function () {
								for (var i = 0; i < 5 + Math.floor(self.level / 2); i++) {
									var target = new Target(self.level);
									target.x = Math.random() * 2048;
									target.y = Math.random() * 2732;
									targets.push(target);
									self.addChild(target);
								}
								self.targetsLeft = 5 + Math.floor(self.level / 2);
								targetsLeftText.setText('Targets Left: ' + self.targetsLeft);
								projectiles = [];
								self.touchesLeft += 2;
								touchesLeftText.setText('Touches Left: ' + self.touchesLeft);
							}, 2000);
						}
					}
				}
			}
		}
	});
	stage.on('down', function (obj) {
		if (instructionsText) {
			instructionsText.setText('');
		}
		if (self.touchesLeft > 0) {
			var pos = obj.event.getLocalPosition(self);
			var directions = ['up', 'down', 'left', 'right'];
			for (var i = 0; i < 4; i++) {
				var projectile = new Projectile();
				projectile.x = pos.x;
				projectile.y = pos.y;
				projectile.direction = directions[i];
				self.numberOfProjectiles++;
				projectile.on('destroy', function () {
					var index = projectiles.indexOf(projectile);
					if (index > -1) {
						projectiles.splice(index, 1);
					}
				});
				self.addChild(projectile);
				projectiles.push(projectile);
			}
			self.touchesLeft--;
			touchesLeftText.setText('Touches Left: ' + self.touchesLeft);
		}
	});
});
 Simple flat icon, 200x200pixels, one bright color square with border. No shadows, top down view, transparent background. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
 Simple flat icon, 200x200pixels, one bright color circle with border. No shadows, top down view, transparent background. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
 Simple flat icon, 200x200pixels, one bright color diamond with border. No shadows, top down view, transparent background. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
 Simple flat icon, 200x200pixels, one bright color romb with border. No shadows, top down view, transparent background. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
 Simple flat icon, 200x200pixels, one bright color smiley with border. No shadows, top down view, transparent background. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
 1024x1366 pixels, totally black no more than 20 very small, barely visible, stars here and there. Simple Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
 Single Game Texture, 50x50pix. In-Game asset. 2d. Blank background. High contrast. No shadows. Light green circle with border. Simple. No other objects. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.