/**** * Classes ****/ // Armour class var Armour = Container.expand(function () { var self = Container.call(this); var armourGraphics = self.attachAsset('armour', { anchorX: 0.5, anchorY: 0.5 }); self.applyToBird = function (bird) { var protectiveLayer = self.attachAsset('armour', { anchorX: 0.5, anchorY: 0.5 }); protectiveLayer.tint = 0x0000ff; // Set the protective layer color to blue bird.addChild(protectiveLayer); LK.setTimeout(function () { bird.removeChild(protectiveLayer); }, 9000); // Remove the protective layer after 9 seconds }; }); var Bird = Container.expand(function () { var self = Container.call(this); var birdGraphics = self.attachAsset('bird', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 10; var starGraphics = null; self.update = function () { // Make the star glow and give light if (!starGraphics) { starGraphics = game.children.find(function (child) { return child instanceof Star; }); } if (starGraphics) { starGraphics.alpha = 0.5 + 0.5 * Math.sin(LK.ticks / 20); } // Bird movement logic self.x += self.vx; self.y += self.vy; // Bounce off the walls if (self.x < 0 || self.x > 2048) { self.vx *= -1; self.x = Math.max(0, Math.min(self.x, 2048)); } if (self.y < 0 || self.y > 2732) { self.vy *= -1; self.y = Math.max(0, Math.min(self.y, 2732)); } }; self.vx = 0; self.vy = 0; self.invincible = false; self.setInvincible = function (duration) { self.invincible = true; LK.setTimeout(function () { self.invincible = false; }, duration); }; }); // Bread class var Bread = Container.expand(function () { var self = Container.call(this); var breadGraphics = self.attachAsset('bread', { anchorX: 0.5, anchorY: 0.5 }); }); // Food class var Food = Container.expand(function () { var self = Container.call(this); var foodGraphics = self.attachAsset('food', { anchorX: 0.5, anchorY: 0.5 }); }); // Assets will be automatically created and loaded during gameplay // Honeybee class var Honeybee = Container.expand(function () { var self = Container.call(this); var honeybeeGraphics = self.attachAsset('honeybee', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 10; self.update = function () { // Honeybee movement logic self.x += self.vx; self.y += self.vy; // Bounce off the walls if (self.x < 0 || self.x > 2048) { self.vx *= -1; self.x = Math.max(0, Math.min(self.x, 2048)); } if (self.y < 0 || self.y > 2732) { self.vy *= -1; self.y = Math.max(0, Math.min(self.y, 2732)); } }; self.vx = 0; self.vy = 0; self.invincible = false; self.setInvincible = function (duration) { self.invincible = true; LK.setTimeout(function () { self.invincible = false; }, duration); }; }); // Shield class var Shield = Container.expand(function () { var self = Container.call(this); var shieldGraphics = self.attachAsset('shield', { anchorX: 0.5, anchorY: 0.5 }); }); var Star = Container.expand(function () { var self = Container.call(this); var starGraphics = self.attachAsset('star', { anchorX: 0.5, anchorY: 0.5 }); starGraphics.filters = [new filters.GlowFilter({ distance: 15, outerStrength: 2, color: 0xffff00 })]; }); // Sun class var Sun = Container.expand(function () { var self = Container.call(this); var sunGraphics = self.attachAsset('sun', { anchorX: 0.5, anchorY: 0.5 }); }); // Tree class var Tree = Container.expand(function () { var self = Container.call(this); var treeGraphics = self.attachAsset('tree', { anchorX: 0.5, anchorY: 0.5 }); }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB // Sky blue background }); /**** * Game Code ****/ // Add background image to the game var background = LK.getAsset('background', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 }); game.addChild(background); var background1 = LK.getAsset('background2', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 }); background1.visible = false; game.addChild(background1); var currentBackground = background; var nextBackground = background1; function switchBackground() { currentBackground.visible = false; nextBackground.visible = true; // Add a dark overlay when background1 is switched if (nextBackground === background1) { LK.effects.flashScreen(0x000000, 500); // Flash a black overlay for 500ms } var temp = currentBackground; currentBackground = nextBackground; nextBackground = temp; } LK.setInterval(switchBackground, 10000); var filters = { GlowFilter: function GlowFilter(options) { options = options || {}; this.distance = options.distance || 15; this.outerStrength = options.outerStrength || 2; options = options || {}; this.color = options.color || 0xffff00; } }; // Initialize game variables var sun = null; var bird = game.addChild(new Bird()); bird.x = 2048 / 2; bird.y = 2732 / 2; bird.vx = 5; bird.vy = 5; var shield = game.addChild(new Shield()); shield.x = Math.random() * 2048; shield.y = Math.random() * 2732; var trees = []; var foods = []; var score = 0; var breadSpawned = false; function spawnBread() { var bread = new Bread(); bread.x = Math.random() * 2048; bread.y = Math.random() * 2732; game.addChild(bread); } function spawnArmour() { var armour = new Armour(); armour.x = Math.random() * 2048; armour.y = Math.random() * 2732; game.addChild(armour); } var armourSpawned = false; var scoreTxt = new Text2('0', { size: 150, fill: "#ffffff", stroke: "#000000", strokeThickness: 10, dropShadow: true, dropShadowColor: "#000000", dropShadowBlur: 4, dropShadowAngle: Math.PI / 6, dropShadowDistance: 6, fontWeight: 'bold', fontStyle: 'italic' }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Function to spawn trees function spawnTree() { var tree = new Tree(); tree.x = Math.random() * 2048; tree.y = Math.random() * 2732; trees.push(tree); game.addChild(tree); } // Function to spawn food function spawnFood() { var food = new Food(); food.x = Math.random() * 2048; food.y = Math.random() * 2732; foods.push(food); game.addChild(food); } // Spawn initial trees and food for (var i = 0; i < 5; i++) { spawnTree(); spawnFood(); spawnFood(); } // Handle bird movement game.down = function (x, y, obj) { var game_position = game.toLocal(obj.global); bird.vx = (game_position.x - bird.x) / 60; bird.vy = (game_position.y - bird.y) / 60; }; // Update game state game.update = function () { bird.update(); game.children.forEach(function (child) { if (child instanceof Star) { child.update(); } }); // Check for collisions with trees for (var i = 0; i < trees.length; i++) { if (!bird.invincible && bird.intersects(trees[i])) { LK.effects.flashScreen(0xff0000, 1000); var sorryTxt = new Text2('SORRY', { size: 200, fill: "#ff0000", stroke: "#000000", strokeThickness: 10, dropShadow: true, dropShadowColor: "#000000", dropShadowBlur: 4, dropShadowAngle: Math.PI / 6, dropShadowDistance: 6, fontWeight: 'bold', fontStyle: 'italic' }); sorryTxt.anchor.set(0.5, 0.5); sorryTxt.x = 2048 / 2; sorryTxt.y = 2732 / 2; LK.gui.center.addChild(sorryTxt); LK.showGameOver(); return; } } // Check for collisions with food for (var i = 0; i < foods.length; i++) { if (bird.intersects(foods[i])) { score += 2; scoreTxt.setText(score); foods[i].destroy(); foods.splice(i, 1); spawnFood(); if (score >= 20 && !breadSpawned) { spawnBread(); breadSpawned = true; } if (score >= 50 && score < 52) { var score50Txt = new Text2('You are in 50 score', { size: 150, fill: "#00ff00", stroke: "#000000", strokeThickness: 10, dropShadow: true, dropShadowColor: "#000000", dropShadowBlur: 4, dropShadowAngle: Math.PI / 6, dropShadowDistance: 6, fontWeight: 'bold', fontStyle: 'italic' }); score50Txt.anchor.set(0.5, 0.5); score50Txt.x = 2048 / 2; score50Txt.y = 2732 / 2; LK.gui.center.addChild(score50Txt); LK.setTimeout(function () { LK.gui.center.removeChild(score50Txt); }, 2000); // Remove the message after 2 seconds } if (score >= 60 && !armourSpawned) { spawnArmour(); armourSpawned = true; // Replace bird with honeybee bird.destroy(); bird = game.addChild(new Honeybee()); bird.x = 2048 / 2; bird.y = 2732 / 2; bird.vx = 5; bird.vy = 5; } if (score >= 90) { bird.vx *= 1.5; // Increase horizontal speed by 50% bird.vy *= 1.5; // Increase vertical speed by 50% } var armour = game.children.find(function (child) { return child instanceof Armour; }); if (armour && bird.intersects(armour)) { armour.applyToBird(bird); armour.destroy(); armourSpawned = false; } } } // Check for collisions with bread if (breadSpawned) { var bread = game.children.find(function (child) { return child instanceof Bread; }); if (bird.intersects(bread)) { bird.setInvincible(9000); // Make bird invincible for 9 seconds bread.destroy(); breadSpawned = false; } } // Check for collisions with shield if (bird.intersects(shield)) { score += 5; scoreTxt.setText(score); bird.setInvincible(5000); // Make bird invincible for 5 seconds shield.destroy(); shield = game.addChild(new Shield()); shield.x = Math.random() * 2048; shield.y = Math.random() * 2732; } // Check for collisions with walls if (bird.x < 0 || bird.x > 2048 || bird.y < 0 || bird.y > 2732) { LK.effects.flashScreen(0xff0000, 1000); var sorryTxt = new Text2('SORRY', { size: 200, fill: "#ff0000", stroke: "#000000", strokeThickness: 10, dropShadow: true, dropShadowColor: "#000000", dropShadowBlur: 4, dropShadowAngle: Math.PI / 6, dropShadowDistance: 6, fontWeight: 'bold', fontStyle: 'italic' }); sorryTxt.anchor.set(0.5, 0.5); sorryTxt.x = 2048 / 2; sorryTxt.y = 2732 / 2; LK.gui.center.addChild(sorryTxt); LK.showGameOver(); return; } };
/****
* Classes
****/
// Armour class
var Armour = Container.expand(function () {
var self = Container.call(this);
var armourGraphics = self.attachAsset('armour', {
anchorX: 0.5,
anchorY: 0.5
});
self.applyToBird = function (bird) {
var protectiveLayer = self.attachAsset('armour', {
anchorX: 0.5,
anchorY: 0.5
});
protectiveLayer.tint = 0x0000ff; // Set the protective layer color to blue
bird.addChild(protectiveLayer);
LK.setTimeout(function () {
bird.removeChild(protectiveLayer);
}, 9000); // Remove the protective layer after 9 seconds
};
});
var Bird = Container.expand(function () {
var self = Container.call(this);
var birdGraphics = self.attachAsset('bird', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 10;
var starGraphics = null;
self.update = function () {
// Make the star glow and give light
if (!starGraphics) {
starGraphics = game.children.find(function (child) {
return child instanceof Star;
});
}
if (starGraphics) {
starGraphics.alpha = 0.5 + 0.5 * Math.sin(LK.ticks / 20);
}
// Bird movement logic
self.x += self.vx;
self.y += self.vy;
// Bounce off the walls
if (self.x < 0 || self.x > 2048) {
self.vx *= -1;
self.x = Math.max(0, Math.min(self.x, 2048));
}
if (self.y < 0 || self.y > 2732) {
self.vy *= -1;
self.y = Math.max(0, Math.min(self.y, 2732));
}
};
self.vx = 0;
self.vy = 0;
self.invincible = false;
self.setInvincible = function (duration) {
self.invincible = true;
LK.setTimeout(function () {
self.invincible = false;
}, duration);
};
});
// Bread class
var Bread = Container.expand(function () {
var self = Container.call(this);
var breadGraphics = self.attachAsset('bread', {
anchorX: 0.5,
anchorY: 0.5
});
});
// Food class
var Food = Container.expand(function () {
var self = Container.call(this);
var foodGraphics = self.attachAsset('food', {
anchorX: 0.5,
anchorY: 0.5
});
});
// Assets will be automatically created and loaded during gameplay
// Honeybee class
var Honeybee = Container.expand(function () {
var self = Container.call(this);
var honeybeeGraphics = self.attachAsset('honeybee', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 10;
self.update = function () {
// Honeybee movement logic
self.x += self.vx;
self.y += self.vy;
// Bounce off the walls
if (self.x < 0 || self.x > 2048) {
self.vx *= -1;
self.x = Math.max(0, Math.min(self.x, 2048));
}
if (self.y < 0 || self.y > 2732) {
self.vy *= -1;
self.y = Math.max(0, Math.min(self.y, 2732));
}
};
self.vx = 0;
self.vy = 0;
self.invincible = false;
self.setInvincible = function (duration) {
self.invincible = true;
LK.setTimeout(function () {
self.invincible = false;
}, duration);
};
});
// Shield class
var Shield = Container.expand(function () {
var self = Container.call(this);
var shieldGraphics = self.attachAsset('shield', {
anchorX: 0.5,
anchorY: 0.5
});
});
var Star = Container.expand(function () {
var self = Container.call(this);
var starGraphics = self.attachAsset('star', {
anchorX: 0.5,
anchorY: 0.5
});
starGraphics.filters = [new filters.GlowFilter({
distance: 15,
outerStrength: 2,
color: 0xffff00
})];
});
// Sun class
var Sun = Container.expand(function () {
var self = Container.call(this);
var sunGraphics = self.attachAsset('sun', {
anchorX: 0.5,
anchorY: 0.5
});
});
// Tree class
var Tree = Container.expand(function () {
var self = Container.call(this);
var treeGraphics = self.attachAsset('tree', {
anchorX: 0.5,
anchorY: 0.5
});
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB // Sky blue background
});
/****
* Game Code
****/
// Add background image to the game
var background = LK.getAsset('background', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2
});
game.addChild(background);
var background1 = LK.getAsset('background2', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2
});
background1.visible = false;
game.addChild(background1);
var currentBackground = background;
var nextBackground = background1;
function switchBackground() {
currentBackground.visible = false;
nextBackground.visible = true;
// Add a dark overlay when background1 is switched
if (nextBackground === background1) {
LK.effects.flashScreen(0x000000, 500); // Flash a black overlay for 500ms
}
var temp = currentBackground;
currentBackground = nextBackground;
nextBackground = temp;
}
LK.setInterval(switchBackground, 10000);
var filters = {
GlowFilter: function GlowFilter(options) {
options = options || {};
this.distance = options.distance || 15;
this.outerStrength = options.outerStrength || 2;
options = options || {};
this.color = options.color || 0xffff00;
}
};
// Initialize game variables
var sun = null;
var bird = game.addChild(new Bird());
bird.x = 2048 / 2;
bird.y = 2732 / 2;
bird.vx = 5;
bird.vy = 5;
var shield = game.addChild(new Shield());
shield.x = Math.random() * 2048;
shield.y = Math.random() * 2732;
var trees = [];
var foods = [];
var score = 0;
var breadSpawned = false;
function spawnBread() {
var bread = new Bread();
bread.x = Math.random() * 2048;
bread.y = Math.random() * 2732;
game.addChild(bread);
}
function spawnArmour() {
var armour = new Armour();
armour.x = Math.random() * 2048;
armour.y = Math.random() * 2732;
game.addChild(armour);
}
var armourSpawned = false;
var scoreTxt = new Text2('0', {
size: 150,
fill: "#ffffff",
stroke: "#000000",
strokeThickness: 10,
dropShadow: true,
dropShadowColor: "#000000",
dropShadowBlur: 4,
dropShadowAngle: Math.PI / 6,
dropShadowDistance: 6,
fontWeight: 'bold',
fontStyle: 'italic'
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Function to spawn trees
function spawnTree() {
var tree = new Tree();
tree.x = Math.random() * 2048;
tree.y = Math.random() * 2732;
trees.push(tree);
game.addChild(tree);
}
// Function to spawn food
function spawnFood() {
var food = new Food();
food.x = Math.random() * 2048;
food.y = Math.random() * 2732;
foods.push(food);
game.addChild(food);
}
// Spawn initial trees and food
for (var i = 0; i < 5; i++) {
spawnTree();
spawnFood();
spawnFood();
}
// Handle bird movement
game.down = function (x, y, obj) {
var game_position = game.toLocal(obj.global);
bird.vx = (game_position.x - bird.x) / 60;
bird.vy = (game_position.y - bird.y) / 60;
};
// Update game state
game.update = function () {
bird.update();
game.children.forEach(function (child) {
if (child instanceof Star) {
child.update();
}
});
// Check for collisions with trees
for (var i = 0; i < trees.length; i++) {
if (!bird.invincible && bird.intersects(trees[i])) {
LK.effects.flashScreen(0xff0000, 1000);
var sorryTxt = new Text2('SORRY', {
size: 200,
fill: "#ff0000",
stroke: "#000000",
strokeThickness: 10,
dropShadow: true,
dropShadowColor: "#000000",
dropShadowBlur: 4,
dropShadowAngle: Math.PI / 6,
dropShadowDistance: 6,
fontWeight: 'bold',
fontStyle: 'italic'
});
sorryTxt.anchor.set(0.5, 0.5);
sorryTxt.x = 2048 / 2;
sorryTxt.y = 2732 / 2;
LK.gui.center.addChild(sorryTxt);
LK.showGameOver();
return;
}
}
// Check for collisions with food
for (var i = 0; i < foods.length; i++) {
if (bird.intersects(foods[i])) {
score += 2;
scoreTxt.setText(score);
foods[i].destroy();
foods.splice(i, 1);
spawnFood();
if (score >= 20 && !breadSpawned) {
spawnBread();
breadSpawned = true;
}
if (score >= 50 && score < 52) {
var score50Txt = new Text2('You are in 50 score', {
size: 150,
fill: "#00ff00",
stroke: "#000000",
strokeThickness: 10,
dropShadow: true,
dropShadowColor: "#000000",
dropShadowBlur: 4,
dropShadowAngle: Math.PI / 6,
dropShadowDistance: 6,
fontWeight: 'bold',
fontStyle: 'italic'
});
score50Txt.anchor.set(0.5, 0.5);
score50Txt.x = 2048 / 2;
score50Txt.y = 2732 / 2;
LK.gui.center.addChild(score50Txt);
LK.setTimeout(function () {
LK.gui.center.removeChild(score50Txt);
}, 2000); // Remove the message after 2 seconds
}
if (score >= 60 && !armourSpawned) {
spawnArmour();
armourSpawned = true;
// Replace bird with honeybee
bird.destroy();
bird = game.addChild(new Honeybee());
bird.x = 2048 / 2;
bird.y = 2732 / 2;
bird.vx = 5;
bird.vy = 5;
}
if (score >= 90) {
bird.vx *= 1.5; // Increase horizontal speed by 50%
bird.vy *= 1.5; // Increase vertical speed by 50%
}
var armour = game.children.find(function (child) {
return child instanceof Armour;
});
if (armour && bird.intersects(armour)) {
armour.applyToBird(bird);
armour.destroy();
armourSpawned = false;
}
}
}
// Check for collisions with bread
if (breadSpawned) {
var bread = game.children.find(function (child) {
return child instanceof Bread;
});
if (bird.intersects(bread)) {
bird.setInvincible(9000); // Make bird invincible for 9 seconds
bread.destroy();
breadSpawned = false;
}
}
// Check for collisions with shield
if (bird.intersects(shield)) {
score += 5;
scoreTxt.setText(score);
bird.setInvincible(5000); // Make bird invincible for 5 seconds
shield.destroy();
shield = game.addChild(new Shield());
shield.x = Math.random() * 2048;
shield.y = Math.random() * 2732;
}
// Check for collisions with walls
if (bird.x < 0 || bird.x > 2048 || bird.y < 0 || bird.y > 2732) {
LK.effects.flashScreen(0xff0000, 1000);
var sorryTxt = new Text2('SORRY', {
size: 200,
fill: "#ff0000",
stroke: "#000000",
strokeThickness: 10,
dropShadow: true,
dropShadowColor: "#000000",
dropShadowBlur: 4,
dropShadowAngle: Math.PI / 6,
dropShadowDistance: 6,
fontWeight: 'bold',
fontStyle: 'italic'
});
sorryTxt.anchor.set(0.5, 0.5);
sorryTxt.x = 2048 / 2;
sorryTxt.y = 2732 / 2;
LK.gui.center.addChild(sorryTxt);
LK.showGameOver();
return;
}
};
A honeybee. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A glass bottle filled with honey. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A block of stone. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A shield of IRON MAN. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
sun. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Piece of bread. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
White star and give them glowing effect. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A small armour fit for honeybee. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Blue sky with white colour cloud. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Black sky with night weather and also imagine glowing white star and moon. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.