/**** * Classes ****/ var Background = Container.expand(function () { var self = Container.call(this); var backgroundGraphics = self.attachAsset('background', {}); backgroundGraphics.scale.set(1.4); backgroundGraphics.alpha = 0.6; self.addChild(backgroundGraphics); }); var Bee = Container.expand(function () { var self = Container.call(this); self.canJump = true; self.beeJumping = false; self.onFlower = false; self.currentFlower = null; var beeGraphics = self.attachAsset('bee', { anchorX: 0.5, anchorY: 0.5 }); beeGraphics.scale.set(2); self.collectNectar = function () {}; self._update_migrated = function () { if (self.beeJumping) { self.x += beeSpeed * Math.cos(self.rotation - Math.PI / 2); self.y += beeSpeed * Math.sin(self.rotation - Math.PI / 2); } if (self.onFlower && self.currentFlower) { var currentFlower = self.currentFlower; var orbitRadius = currentFlower.height / 1.5; self.rotation += self.rotationStep; self.rotation = currentFlower.rotation; var ang = self.rotation * (180 / Math.PI); ang = self.rotation; self.x += maxV * Math.sin(ang); self.y += maxV * -Math.cos(ang); self.x = currentFlower.x + orbitRadius * Math.sin(ang); self.y = currentFlower.y + orbitRadius * -Math.cos(ang); } if (self.y < 0 && !self.onFlower) { LK.setScore(playerScore); LK.showGameOver(); } if (self.x < 0 || self.x > 2048 || self.y > 2732) { LK.setScore(playerScore); LK.showGameOver(); } }; Object.defineProperty(self, 'height', { get: function get() { return beeGraphics.height; } }); }); var Flower = Container.expand(function () { var self = Container.call(this); var flowerType = Math.floor(Math.random() * 8) + 1; var flowerGraphics = self.createAsset('flower' + flowerType, { anchorX: 0.5, anchorY: 0.5 }); var randomScale = Math.random() * 2 + 2; flowerGraphics.scale.set(randomScale); self.addChild(flowerGraphics); for (var i = 1; i <= 8; i++) { LK.getAsset('flower' + i, { anchorX: 0.5, anchorY: 0.5 }); } self.canCollide = true; self.rotationStep = (Math.random() < 0.5 ? -1 : 1) * MAX_ROTATION_SPEED; self.verticalMovement = 0; self.produceNectar = function () {}; self._update_migrated = function () { self.rotation += self.rotationStep; if (flowersFalling == true) { self.y += flowerSpeed; } }; }); var Sparkle = Container.expand(function () { var self = Container.call(this); var sparkleGraphics = self.attachAsset('sparkle', { anchorX: 0.5, anchorY: 0.5 }); sparkleGraphics.scale.set(0.5); self.lifespan = 500; self.vx = 10 - Math.random() * 20; self.vy = 10 - Math.random() * 20; self._update_migrated = function (delta) { self.lifespan -= delta; self.x += delta * self.vx / 10; self.y += delta * self.vy / 10; self.vx *= 0.95; self.vy *= 0.95; if (self.lifespan <= 0) { self.destroy(); } }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ var MAX_ROTATION_SPEED = 0.02; var maxV = 4; var flowersFalling = false; var flowerSpeed = 1; var beeSpeed = 5; var playerScore = 0; var gameStarted = false; var background = game.addChild(new Background()); var bee = game.addChild(new Bee()); var flowers = [game.addChild(new Flower()), game.addChild(new Flower()), game.addChild(new Flower()), game.addChild(new Flower())]; flowers[0].y = -300; flowers[1].y = 400; flowers[2].y = 1100; flowers[3].y = 1800; flowers[0].x = 1024; flowers[1].x = 904; flowers[2].x = 1200; flowers[3].x = 1024; flowers.forEach(function (flower, index) { flower.y += flower.height / 2; }); var nectars = []; var scoreTxt = new Text2('0', { size: 150, fill: "#ffff88", stroke: "#882222", strokeThickness: 12 }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); var startTxt = new Text2("Tap to jump from\nflower to flower\ngathering nectar.\n\nDon't fly off the edges!", { size: 80, fill: "#ffffcc", align: 'center', stroke: "#440000", strokeThickness: 12 }); startTxt.anchor.set(0.5, 0.5); LK.gui.center.addChild(startTxt); var isGameOver = false; var sparkleTimer = 0; bee.x = 1024; bee.y = 2732 - bee.height - 100; LK.on('tick', function () { if (gameStarted) { bee._update_migrated(); flowers.forEach(function (flower) { if (flower.canCollide == true) { if (bee.intersects(flower)) { if (!bee.onFlower) { bee.x = flower.x; bee.y = flower.y - flower.height / 1.5; flowersFalling = true; flowerSpeed += 0.3; MAX_ROTATION_SPEED += 0.005; beeSpeed *= 1.05; playerScore += 1000; scoreTxt.setText(playerScore.toString()); } bee.rotationStep = flower.rotationStep; bee.currentFlower = flower; bee.beeJumping = false; bee.onFlower = true; flower.canCollide = false; bee.canJump = true; } } }); sparkleTimer += 16.6667; if (sparkleTimer >= 50) { var sparkle = new Sparkle(); sparkle.x = bee.x; sparkle.y = bee.y; game.addChild(sparkle); sparkleTimer = 0; playerScore += 1; scoreTxt.setText(playerScore.toString()); } for (var i = game.children.length - 1; i >= 0; i--) { var child = game.children[i]; if (child instanceof Sparkle) { child._update_migrated(16.6667); } } if (isGameOver) { LK.setScore(playerScore); LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } for (var i = 0; i < flowers.length; i++) { flowers[i].produceNectar(); flowers[i]._update_migrated(); if (flowers[i].y > 2732) { flowers[i].destroy(); flowers.splice(i, 1); var newFlower = new Flower(); newFlower.x = 500 + Math.random() * (1748 - 500); newFlower.y = -newFlower.height - 200; flowers.push(newFlower); game.addChild(newFlower); } } for (var j = 0; j < nectars.length; j++) { if (bee.intersects(nectars[j])) { bee.collectNectar(); nectars[j].destroy(); nectars.splice(j, 1); } } } }); game.on('down', function (x, y, obj) { if (!gameStarted) { gameStarted = true; startTxt.visible = false; } if (bee.canJump) { bee.beeJumping = true; bee.canJump = false; bee.onFlower = false; bee.currentFlower = null; } });
/****
* Classes
****/
var Background = Container.expand(function () {
var self = Container.call(this);
var backgroundGraphics = self.attachAsset('background', {});
backgroundGraphics.scale.set(1.4);
backgroundGraphics.alpha = 0.6;
self.addChild(backgroundGraphics);
});
var Bee = Container.expand(function () {
var self = Container.call(this);
self.canJump = true;
self.beeJumping = false;
self.onFlower = false;
self.currentFlower = null;
var beeGraphics = self.attachAsset('bee', {
anchorX: 0.5,
anchorY: 0.5
});
beeGraphics.scale.set(2);
self.collectNectar = function () {};
self._update_migrated = function () {
if (self.beeJumping) {
self.x += beeSpeed * Math.cos(self.rotation - Math.PI / 2);
self.y += beeSpeed * Math.sin(self.rotation - Math.PI / 2);
}
if (self.onFlower && self.currentFlower) {
var currentFlower = self.currentFlower;
var orbitRadius = currentFlower.height / 1.5;
self.rotation += self.rotationStep;
self.rotation = currentFlower.rotation;
var ang = self.rotation * (180 / Math.PI);
ang = self.rotation;
self.x += maxV * Math.sin(ang);
self.y += maxV * -Math.cos(ang);
self.x = currentFlower.x + orbitRadius * Math.sin(ang);
self.y = currentFlower.y + orbitRadius * -Math.cos(ang);
}
if (self.y < 0 && !self.onFlower) {
LK.setScore(playerScore);
LK.showGameOver();
}
if (self.x < 0 || self.x > 2048 || self.y > 2732) {
LK.setScore(playerScore);
LK.showGameOver();
}
};
Object.defineProperty(self, 'height', {
get: function get() {
return beeGraphics.height;
}
});
});
var Flower = Container.expand(function () {
var self = Container.call(this);
var flowerType = Math.floor(Math.random() * 8) + 1;
var flowerGraphics = self.createAsset('flower' + flowerType, {
anchorX: 0.5,
anchorY: 0.5
});
var randomScale = Math.random() * 2 + 2;
flowerGraphics.scale.set(randomScale);
self.addChild(flowerGraphics);
for (var i = 1; i <= 8; i++) {
LK.getAsset('flower' + i, {
anchorX: 0.5,
anchorY: 0.5
});
}
self.canCollide = true;
self.rotationStep = (Math.random() < 0.5 ? -1 : 1) * MAX_ROTATION_SPEED;
self.verticalMovement = 0;
self.produceNectar = function () {};
self._update_migrated = function () {
self.rotation += self.rotationStep;
if (flowersFalling == true) {
self.y += flowerSpeed;
}
};
});
var Sparkle = Container.expand(function () {
var self = Container.call(this);
var sparkleGraphics = self.attachAsset('sparkle', {
anchorX: 0.5,
anchorY: 0.5
});
sparkleGraphics.scale.set(0.5);
self.lifespan = 500;
self.vx = 10 - Math.random() * 20;
self.vy = 10 - Math.random() * 20;
self._update_migrated = function (delta) {
self.lifespan -= delta;
self.x += delta * self.vx / 10;
self.y += delta * self.vy / 10;
self.vx *= 0.95;
self.vy *= 0.95;
if (self.lifespan <= 0) {
self.destroy();
}
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000
});
/****
* Game Code
****/
var MAX_ROTATION_SPEED = 0.02;
var maxV = 4;
var flowersFalling = false;
var flowerSpeed = 1;
var beeSpeed = 5;
var playerScore = 0;
var gameStarted = false;
var background = game.addChild(new Background());
var bee = game.addChild(new Bee());
var flowers = [game.addChild(new Flower()), game.addChild(new Flower()), game.addChild(new Flower()), game.addChild(new Flower())];
flowers[0].y = -300;
flowers[1].y = 400;
flowers[2].y = 1100;
flowers[3].y = 1800;
flowers[0].x = 1024;
flowers[1].x = 904;
flowers[2].x = 1200;
flowers[3].x = 1024;
flowers.forEach(function (flower, index) {
flower.y += flower.height / 2;
});
var nectars = [];
var scoreTxt = new Text2('0', {
size: 150,
fill: "#ffff88",
stroke: "#882222",
strokeThickness: 12
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
var startTxt = new Text2("Tap to jump from\nflower to flower\ngathering nectar.\n\nDon't fly off the edges!", {
size: 80,
fill: "#ffffcc",
align: 'center',
stroke: "#440000",
strokeThickness: 12
});
startTxt.anchor.set(0.5, 0.5);
LK.gui.center.addChild(startTxt);
var isGameOver = false;
var sparkleTimer = 0;
bee.x = 1024;
bee.y = 2732 - bee.height - 100;
LK.on('tick', function () {
if (gameStarted) {
bee._update_migrated();
flowers.forEach(function (flower) {
if (flower.canCollide == true) {
if (bee.intersects(flower)) {
if (!bee.onFlower) {
bee.x = flower.x;
bee.y = flower.y - flower.height / 1.5;
flowersFalling = true;
flowerSpeed += 0.3;
MAX_ROTATION_SPEED += 0.005;
beeSpeed *= 1.05;
playerScore += 1000;
scoreTxt.setText(playerScore.toString());
}
bee.rotationStep = flower.rotationStep;
bee.currentFlower = flower;
bee.beeJumping = false;
bee.onFlower = true;
flower.canCollide = false;
bee.canJump = true;
}
}
});
sparkleTimer += 16.6667;
if (sparkleTimer >= 50) {
var sparkle = new Sparkle();
sparkle.x = bee.x;
sparkle.y = bee.y;
game.addChild(sparkle);
sparkleTimer = 0;
playerScore += 1;
scoreTxt.setText(playerScore.toString());
}
for (var i = game.children.length - 1; i >= 0; i--) {
var child = game.children[i];
if (child instanceof Sparkle) {
child._update_migrated(16.6667);
}
}
if (isGameOver) {
LK.setScore(playerScore);
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
}
for (var i = 0; i < flowers.length; i++) {
flowers[i].produceNectar();
flowers[i]._update_migrated();
if (flowers[i].y > 2732) {
flowers[i].destroy();
flowers.splice(i, 1);
var newFlower = new Flower();
newFlower.x = 500 + Math.random() * (1748 - 500);
newFlower.y = -newFlower.height - 200;
flowers.push(newFlower);
game.addChild(newFlower);
}
}
for (var j = 0; j < nectars.length; j++) {
if (bee.intersects(nectars[j])) {
bee.collectNectar();
nectars[j].destroy();
nectars.splice(j, 1);
}
}
}
});
game.on('down', function (x, y, obj) {
if (!gameStarted) {
gameStarted = true;
startTxt.visible = false;
}
if (bee.canJump) {
bee.beeJumping = true;
bee.canJump = false;
bee.onFlower = false;
bee.currentFlower = null;
}
});
A large red round flower. Top down view. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A large blue round flower. Top down view. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A round yellow flower. Top down view. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A round purple and red flower. Top down view. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A round green and yellow flower. Top down view. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A round orange and white flower. Top down view. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A round cyan and blue flower. Top down view. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A round magenta and green flower. Top down view. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A happy little bee. Top down view. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a lush meadow full of tiny flowers. top-down view. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
yellow pointy star twinkle. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.