var Spider = Container.expand(function () {
	var self = Container.call(this);
	var spiderGraphics = self.createAsset('spider', 'Spider Graphics', .5, .5);
	spiderGraphics.scale.x = 3;
	spiderGraphics.scale.y = 3;
	self.x = -spiderGraphics.width;
	self.y = 2732 - spiderGraphics.height - 260;
	self.xSpeed = 0.5;
	self.move = function () {
		self.x += self.xSpeed;
		if (self.x > 2048) {
			self.x = -spiderGraphics.width;
		}
	};
});
var EmptyHeart = Container.expand(function () {
	var self = Container.call(this);
	var emptyHeartGraphics = self.createAsset('empty_heart', 'Empty Heart Graphics', .5, .5);
});
var RightBee = Container.expand(function () {
	var self = Container.call(this);
	var beeGraphics = self.createAsset('bee', 'Bee Graphics', .5, .5);
	beeGraphics.scale.x = 1.2;
	beeGraphics.scale.y = 1.2;
	self.spawnBee = function () {
		self.x = 2048 + 100;
		self.y = Math.random() * (2732 / 2);
		self.xSpeed = -(Math.random() * 7 + 3);
	};
	self.spawnBee();
	self.move = function () {
		self.x += self.xSpeed;
		if (self.x < -50) {
			self.y = Math.random() * (2732 / 2);
			self.xSpeed = -(Math.random() * 7 + 3);
			self.x = 2048 + 100;
		}
	};
});
var LeftBee = Container.expand(function () {
	var self = Container.call(this);
	var beeGraphics = self.createAsset('bee', 'Bee Graphics', .5, .5);
	beeGraphics.scale.x = -1.2;
	beeGraphics.scale.y = 1.2;
	self.spawnBee = function () {
		self.x = -100;
		self.y = Math.random() * (2732 / 2);
		self.xSpeed = Math.random() * 7 + 3;
	};
	self.spawnBee();
	self.move = function () {
		self.x += self.xSpeed;
		if (self.x > 2048 + 50) {
			self.y = Math.random() * (2732 / 2);
			self.xSpeed = Math.random() * 7 + 3;
			self.x = -100;
		}
	};
});
var Bee = Container.expand(function () {
	var self = Container.call(this);
	var beeGraphics = self.createAsset('bee', 'Bee Graphics', .5, .5);
	beeGraphics.scale.x = 1.8;
	beeGraphics.scale.y = 1.2;
	self.spawnBee();
});
var Heart = Container.expand(function () {
	var self = Container.call(this);
	var heartGraphics = self.createAsset('heart', 'Heart Graphics', .5, .5);
});
var Fly = Container.expand(function () {
	var self = Container.call(this);
	var flyGraphics = self.createAsset('fly', 'Fly Graphics', .5, .5);
	self.spawnFly = function () {
		var direction = Math.random() < 0.5 ? -1 : 1;
		self.xSpeed = direction * (Math.random() * 10 + 5);
		self.x = direction > 0 ? -50 : 2048 + 50;
		self.y = Math.random() * (2732 * 3 / 4 - self.height - LK.gui.topRight.height);
		var scale = 1 + self.y / (2732 * 3 / 4) * 0.2;
		self.scale.x = self.scale.y = scale;
	};
	self.spawnFly();
	self.move = function () {
		if (self.xSpeed > 0 && self.x > 2048 / 2 && !self.changedDirection || self.xSpeed < 0 && self.x < 2048 / 2 && !self.changedDirection) {
			self.xSpeed *= -1;
			self.changedDirection = true;
		}
		if (self.xSpeed > 0) {
			flyGraphics.scale.x = 1;
		} else if (self.xSpeed < 0) {
			flyGraphics.scale.x = -1;
		}
		self.x += self.xSpeed;
		if (self.x > 2048 + 50 || self.x < -50) {
			self.spawnFly();
		}
	};
});
var Plant = Container.expand(function () {
	var self = Container.call(this);
	self.isMoving = false;
	self.launchAt = function (x, y) {
		var startX = self.x;
		var startY = self.y;
		var endX = x;
		var endY = y;
		var time = 0;
		self.isMoving = true;
		self.parent.spiderMoveTimer = 0;
		self.parent.spiderIsMoving = false;
		LK.clearInterval(self.parent.spiderMoveInterval);
		self.fliesCaughtInJump = 0;
		if (x > 2048 / 2) {
			self.scale.x = -1;
		} else {
			self.scale.x = 1;
		}
		self.moveTowards = function () {
			if (time <= 30) {
				self.x = startX + (endX - startX) * (time / 30);
				self.y = startY - (startY - endY) * (time / 30);
				time++;
			} else if (time <= 90) {
				self.x = endX - (endX - startX) * ((time - 30) / 60);
				self.y = endY + (startY - endY) * ((time - 30) / 60);
				time++;
			} else {
				self.isMoving = false;
				self.moveTowards = null;
				self.parent.targetScore += self.fliesCaughtInJump * 100 + self.parent.bonusScore;
				self.fliesCaughtInJump = 0;
				self.parent.bonusScore = 0;
			}
		};
	};
	var plantGraphics = self.createAsset('plant', 'Plant Graphics', .5, .5);
	self.catchFly = function (fly) {
		if (self.intersects(fly)) {
			fly.destroy();
			self.fliesCaughtInJump = (self.fliesCaughtInJump || 0) + 1;
			if (fly.y < 2732 / 3) {
				self.parent.bonusScore += 150;
			}
			return true;
		}
		return false;
	};
	self.hitByBee = function (bee) {
		if (self.intersects(bee) && !self.hit) {
			self.hit = true;
			LK.effects.flashObject(self, 0xff0000, 1000);
			self.x = 2048 / 2;
			self.y = 2732 - self.height - 100;
			self.parent.loseHeart();
			if (self.isMoving) {
				self.isMoving = false;
				self.moveTowards = null;
			}
			bee.x = -100;
			LK.setTimeout(function () {
				self.hit = false;
			}, 1000);
			return true;
		}
		return false;
	};
});
var Game = Container.expand(function () {
	var self = Container.call(this);
	var messageIndex = 0;
	var messages = ['Catch the flies!', 'Avoid the bees!', 'Keep moving!'];
	var showMessage = function () {
		var startMessage = new Text2(messages[messageIndex], {
			size: 60,
			fill: '#FF1493',
			align: 'center'
		});
		startMessage.x -= 330;
		startMessage.anchor.set(0.5, 0.5);
		startMessage.x = 2048 / 2 - 350;
		startMessage.y = LK.gui.topCenter.height / 2 + 50;
		LK.gui.addChild(startMessage);
		LK.setTimeout(function () {
			startMessage.destroy();
			messageIndex++;
			if (messageIndex < messages.length) {
				showMessage();
			} else {
				self.scoreTxt.visible = true;
				LK.gui.topCenter.addChild(self.scoreTxt);
				self.scoreTxt.anchor.set(0.5, 0.5);
				self.scoreTxt.y = LK.gui.topCenter.height / 2;
			}
		}, 2500);
	};
	showMessage();
	self.spiderMoveTimer = 0;
	self.spiderIsMoving = false;
	self.scoreTxt = new Text2('0', {
		size: 120,
		fill: "#00BFFF",
		align: 'center'
	});
	self.scoreTxt.x -= 30;
	self.scoreTxt.visible = false;
	self.targetScore = 0;
	self.bonusScore = 0;
	self.targetScore = 0;
	self.currentScore = 0;
	self.updateScore = function (fliesCaught) {
		if (!plant.isMoving) {
			self.targetScore += fliesCaught * (fliesCaught > 1 ? 150 : 100);
		}
	};
	LK.on('tick', function () {
		if (!plant.isMoving && self.currentScore < self.targetScore) {
			self.currentScore += 5;
			if (self.currentScore > self.targetScore) {
				self.currentScore = self.targetScore;
			}
			self.scoreTxt.setText(self.currentScore);
		}
	});
	stage.on('down', function (obj) {
		if (!plant.isMoving && !plant.hit) {
			var pos = obj.event.getLocalPosition(self);
			plant.launchAt(pos.x, pos.y);
		}
	});
	var background = self.createAsset('background', 'Background Graphics', 0, 0);
	background.width = 2048;
	background.height = 2732;
	self.addChildAt(background, 0);
	var spider = self.addChild(new Spider());
	var flies = [];
	var plant = self.addChild(new Plant());
	plant.x = 2048 / 2;
	plant.y = 2732 - plant.height - 100;
	self.incrementScoreAmount = 100;
	var hearts = [];
	self.loseHeart = function () {
		if (hearts.length > 0) {
			var lostHeart = hearts.pop();
			var emptyHeart = new EmptyHeart();
			emptyHeart.x = lostHeart.x;
			emptyHeart.y = lostHeart.y;
			LK.effects.flashObject(emptyHeart, 0xff0000, 1000);
			LK.gui.topLeft.addChild(emptyHeart);
			lostHeart.destroy();
		}
		if (hearts.length === 0) {
			isGameOver = true;
		}
	};
	for (var i = 0; i < 3; i++) {
		var heart = new Heart();
		heart.x = 600 + i * (heart.width + 10);
		heart.y = 1840;
		LK.gui.topLeft.addChild(heart);
		hearts.push(heart);
	}
	var isGameOver = false;
	var flySpawnTimer = 0;
	var bees = [];
	var leftBee = new LeftBee();
	bees.push(leftBee);
	self.addChild(leftBee);
	var rightBee = new RightBee();
	bees.push(rightBee);
	self.addChild(rightBee);
	LK.on('tick', function () {
		for (var a = flies.length - 1; a >= 0; a--) {
			if (flies[a]) {
				flies[a].move();
				if (flies[a].x > 2048 + 50) {
					flies[a].destroy();
					flies.splice(a, 1);
				}
			}
		}
		flySpawnTimer++;
		if (flySpawnTimer >= 120 && flies.length < 5) {
			var newFly = new Fly();
			flies.push(newFly);
			self.addChild(newFly);
			flySpawnTimer = 0;
		}
		for (var a = flies.length - 1; a >= 0; a--) {
			if (plant.catchFly(flies[a])) {
				flies.splice(a, 1);
			}
		}
		if (plant.moveTowards) {
			plant.moveTowards();
		}
		bees.forEach(function (bee) {
			bee.move();
			if (plant.hitByBee(bee)) {}
		});
		if (plant.hitByBee(spider)) {}
		if (!plant.isMoving) {
			spider.move();
		}
		if (isGameOver) {
			LK.effects.flashScreen(0xff0000, 1000);
			LK.gui.children.forEach(function (child) {
				child.destroy();
			});
			LK.showGameOver();
		}
	});
});
 var Spider = Container.expand(function () {
	var self = Container.call(this);
	var spiderGraphics = self.createAsset('spider', 'Spider Graphics', .5, .5);
	spiderGraphics.scale.x = 3;
	spiderGraphics.scale.y = 3;
	self.x = -spiderGraphics.width;
	self.y = 2732 - spiderGraphics.height - 260;
	self.xSpeed = 0.5;
	self.move = function () {
		self.x += self.xSpeed;
		if (self.x > 2048) {
			self.x = -spiderGraphics.width;
		}
	};
});
var EmptyHeart = Container.expand(function () {
	var self = Container.call(this);
	var emptyHeartGraphics = self.createAsset('empty_heart', 'Empty Heart Graphics', .5, .5);
});
var RightBee = Container.expand(function () {
	var self = Container.call(this);
	var beeGraphics = self.createAsset('bee', 'Bee Graphics', .5, .5);
	beeGraphics.scale.x = 1.2;
	beeGraphics.scale.y = 1.2;
	self.spawnBee = function () {
		self.x = 2048 + 100;
		self.y = Math.random() * (2732 / 2);
		self.xSpeed = -(Math.random() * 7 + 3);
	};
	self.spawnBee();
	self.move = function () {
		self.x += self.xSpeed;
		if (self.x < -50) {
			self.y = Math.random() * (2732 / 2);
			self.xSpeed = -(Math.random() * 7 + 3);
			self.x = 2048 + 100;
		}
	};
});
var LeftBee = Container.expand(function () {
	var self = Container.call(this);
	var beeGraphics = self.createAsset('bee', 'Bee Graphics', .5, .5);
	beeGraphics.scale.x = -1.2;
	beeGraphics.scale.y = 1.2;
	self.spawnBee = function () {
		self.x = -100;
		self.y = Math.random() * (2732 / 2);
		self.xSpeed = Math.random() * 7 + 3;
	};
	self.spawnBee();
	self.move = function () {
		self.x += self.xSpeed;
		if (self.x > 2048 + 50) {
			self.y = Math.random() * (2732 / 2);
			self.xSpeed = Math.random() * 7 + 3;
			self.x = -100;
		}
	};
});
var Bee = Container.expand(function () {
	var self = Container.call(this);
	var beeGraphics = self.createAsset('bee', 'Bee Graphics', .5, .5);
	beeGraphics.scale.x = 1.8;
	beeGraphics.scale.y = 1.2;
	self.spawnBee();
});
var Heart = Container.expand(function () {
	var self = Container.call(this);
	var heartGraphics = self.createAsset('heart', 'Heart Graphics', .5, .5);
});
var Fly = Container.expand(function () {
	var self = Container.call(this);
	var flyGraphics = self.createAsset('fly', 'Fly Graphics', .5, .5);
	self.spawnFly = function () {
		var direction = Math.random() < 0.5 ? -1 : 1;
		self.xSpeed = direction * (Math.random() * 10 + 5);
		self.x = direction > 0 ? -50 : 2048 + 50;
		self.y = Math.random() * (2732 * 3 / 4 - self.height - LK.gui.topRight.height);
		var scale = 1 + self.y / (2732 * 3 / 4) * 0.2;
		self.scale.x = self.scale.y = scale;
	};
	self.spawnFly();
	self.move = function () {
		if (self.xSpeed > 0 && self.x > 2048 / 2 && !self.changedDirection || self.xSpeed < 0 && self.x < 2048 / 2 && !self.changedDirection) {
			self.xSpeed *= -1;
			self.changedDirection = true;
		}
		if (self.xSpeed > 0) {
			flyGraphics.scale.x = 1;
		} else if (self.xSpeed < 0) {
			flyGraphics.scale.x = -1;
		}
		self.x += self.xSpeed;
		if (self.x > 2048 + 50 || self.x < -50) {
			self.spawnFly();
		}
	};
});
var Plant = Container.expand(function () {
	var self = Container.call(this);
	self.isMoving = false;
	self.launchAt = function (x, y) {
		var startX = self.x;
		var startY = self.y;
		var endX = x;
		var endY = y;
		var time = 0;
		self.isMoving = true;
		self.parent.spiderMoveTimer = 0;
		self.parent.spiderIsMoving = false;
		LK.clearInterval(self.parent.spiderMoveInterval);
		self.fliesCaughtInJump = 0;
		if (x > 2048 / 2) {
			self.scale.x = -1;
		} else {
			self.scale.x = 1;
		}
		self.moveTowards = function () {
			if (time <= 30) {
				self.x = startX + (endX - startX) * (time / 30);
				self.y = startY - (startY - endY) * (time / 30);
				time++;
			} else if (time <= 90) {
				self.x = endX - (endX - startX) * ((time - 30) / 60);
				self.y = endY + (startY - endY) * ((time - 30) / 60);
				time++;
			} else {
				self.isMoving = false;
				self.moveTowards = null;
				self.parent.targetScore += self.fliesCaughtInJump * 100 + self.parent.bonusScore;
				self.fliesCaughtInJump = 0;
				self.parent.bonusScore = 0;
			}
		};
	};
	var plantGraphics = self.createAsset('plant', 'Plant Graphics', .5, .5);
	self.catchFly = function (fly) {
		if (self.intersects(fly)) {
			fly.destroy();
			self.fliesCaughtInJump = (self.fliesCaughtInJump || 0) + 1;
			if (fly.y < 2732 / 3) {
				self.parent.bonusScore += 150;
			}
			return true;
		}
		return false;
	};
	self.hitByBee = function (bee) {
		if (self.intersects(bee) && !self.hit) {
			self.hit = true;
			LK.effects.flashObject(self, 0xff0000, 1000);
			self.x = 2048 / 2;
			self.y = 2732 - self.height - 100;
			self.parent.loseHeart();
			if (self.isMoving) {
				self.isMoving = false;
				self.moveTowards = null;
			}
			bee.x = -100;
			LK.setTimeout(function () {
				self.hit = false;
			}, 1000);
			return true;
		}
		return false;
	};
});
var Game = Container.expand(function () {
	var self = Container.call(this);
	var messageIndex = 0;
	var messages = ['Catch the flies!', 'Avoid the bees!', 'Keep moving!'];
	var showMessage = function () {
		var startMessage = new Text2(messages[messageIndex], {
			size: 60,
			fill: '#FF1493',
			align: 'center'
		});
		startMessage.x -= 330;
		startMessage.anchor.set(0.5, 0.5);
		startMessage.x = 2048 / 2 - 350;
		startMessage.y = LK.gui.topCenter.height / 2 + 50;
		LK.gui.addChild(startMessage);
		LK.setTimeout(function () {
			startMessage.destroy();
			messageIndex++;
			if (messageIndex < messages.length) {
				showMessage();
			} else {
				self.scoreTxt.visible = true;
				LK.gui.topCenter.addChild(self.scoreTxt);
				self.scoreTxt.anchor.set(0.5, 0.5);
				self.scoreTxt.y = LK.gui.topCenter.height / 2;
			}
		}, 2500);
	};
	showMessage();
	self.spiderMoveTimer = 0;
	self.spiderIsMoving = false;
	self.scoreTxt = new Text2('0', {
		size: 120,
		fill: "#00BFFF",
		align: 'center'
	});
	self.scoreTxt.x -= 30;
	self.scoreTxt.visible = false;
	self.targetScore = 0;
	self.bonusScore = 0;
	self.targetScore = 0;
	self.currentScore = 0;
	self.updateScore = function (fliesCaught) {
		if (!plant.isMoving) {
			self.targetScore += fliesCaught * (fliesCaught > 1 ? 150 : 100);
		}
	};
	LK.on('tick', function () {
		if (!plant.isMoving && self.currentScore < self.targetScore) {
			self.currentScore += 5;
			if (self.currentScore > self.targetScore) {
				self.currentScore = self.targetScore;
			}
			self.scoreTxt.setText(self.currentScore);
		}
	});
	stage.on('down', function (obj) {
		if (!plant.isMoving && !plant.hit) {
			var pos = obj.event.getLocalPosition(self);
			plant.launchAt(pos.x, pos.y);
		}
	});
	var background = self.createAsset('background', 'Background Graphics', 0, 0);
	background.width = 2048;
	background.height = 2732;
	self.addChildAt(background, 0);
	var spider = self.addChild(new Spider());
	var flies = [];
	var plant = self.addChild(new Plant());
	plant.x = 2048 / 2;
	plant.y = 2732 - plant.height - 100;
	self.incrementScoreAmount = 100;
	var hearts = [];
	self.loseHeart = function () {
		if (hearts.length > 0) {
			var lostHeart = hearts.pop();
			var emptyHeart = new EmptyHeart();
			emptyHeart.x = lostHeart.x;
			emptyHeart.y = lostHeart.y;
			LK.effects.flashObject(emptyHeart, 0xff0000, 1000);
			LK.gui.topLeft.addChild(emptyHeart);
			lostHeart.destroy();
		}
		if (hearts.length === 0) {
			isGameOver = true;
		}
	};
	for (var i = 0; i < 3; i++) {
		var heart = new Heart();
		heart.x = 600 + i * (heart.width + 10);
		heart.y = 1840;
		LK.gui.topLeft.addChild(heart);
		hearts.push(heart);
	}
	var isGameOver = false;
	var flySpawnTimer = 0;
	var bees = [];
	var leftBee = new LeftBee();
	bees.push(leftBee);
	self.addChild(leftBee);
	var rightBee = new RightBee();
	bees.push(rightBee);
	self.addChild(rightBee);
	LK.on('tick', function () {
		for (var a = flies.length - 1; a >= 0; a--) {
			if (flies[a]) {
				flies[a].move();
				if (flies[a].x > 2048 + 50) {
					flies[a].destroy();
					flies.splice(a, 1);
				}
			}
		}
		flySpawnTimer++;
		if (flySpawnTimer >= 120 && flies.length < 5) {
			var newFly = new Fly();
			flies.push(newFly);
			self.addChild(newFly);
			flySpawnTimer = 0;
		}
		for (var a = flies.length - 1; a >= 0; a--) {
			if (plant.catchFly(flies[a])) {
				flies.splice(a, 1);
			}
		}
		if (plant.moveTowards) {
			plant.moveTowards();
		}
		bees.forEach(function (bee) {
			bee.move();
			if (plant.hitByBee(bee)) {}
		});
		if (plant.hitByBee(spider)) {}
		if (!plant.isMoving) {
			spider.move();
		}
		if (isGameOver) {
			LK.effects.flashScreen(0xff0000, 1000);
			LK.gui.children.forEach(function (child) {
				child.destroy();
			});
			LK.showGameOver();
		}
	});
});
 Simple side view of a pixel art fly on a sky blue background Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
 Head of a carnivorous plant, mouth open at top, pixel art Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
 Pixel art heart green Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
 a jungle with light streaming in from above, pixel art Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
 a pixel art bee, cute, side view, flying, no shadow Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
 a dark green box surrounded by vines, pixel art Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
 a blackened cracked heart, pixel art, no shadow Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
 a cute orange-yellow spider, side view, pixel art, fangs, no shadow Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.