User prompt
Add new asset "armour" when player reach on score 60
User prompt
Change the background colour into black and sky-blue in every 20 seconds
User prompt
Make the bird to collect bread and get power for 9 seconds
User prompt
Add new asset "bread" when player reach on score 20
User prompt
Change the background colour "black" in every 20 seconds
User prompt
increase the number of spawning of stone when player reach on score 60
User prompt
Add the function of cookie which gives energy to bird
User prompt
Add new asset " cookie" will be visible when the player reach on 20 score
User prompt
Remove clouds asset
User prompt
Make the bird that bounces from side of wall
User prompt
Make the clouds still and when the bird collides and it dies
User prompt
Make the background beautiful add cloud and sun
User prompt
Add a test when the bird goes a accident on stone or wallis "SORRY"
User prompt
Add a test when the bird dies is "SORRY"
User prompt
Make the score board cool
User prompt
Add a function of shield which make the bird invincible for 5 seconds
User prompt
Add a new object shield
User prompt
Make the bird that bounces from side of wall
User prompt
Decrease the movement speed of bird
User prompt
Make it little easier
Initial prompt
Flappy clappy
/**** * Classes ****/ // Assets will be automatically created and loaded during gameplay // Bird class var Bird = Container.expand(function () { var self = Container.call(this); var birdGraphics = self.attachAsset('bird', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 10; self.update = function () { // 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); }; }); // Cloud class var Cloud = Container.expand(function () { var self = Container.call(this); var cloudGraphics = self.attachAsset('cloud', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 1; self.update = function () { // Clouds remain still, no movement logic }; }); // Food class var Food = Container.expand(function () { var self = Container.call(this); var foodGraphics = self.attachAsset('food', { anchorX: 0.5, anchorY: 0.5 }); }); // Shield class var Shield = Container.expand(function () { var self = Container.call(this); var shieldGraphics = self.attachAsset('shield', { anchorX: 0.5, anchorY: 0.5 }); }); // 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 ****/ // Initialize game variables var sun = game.addChild(new Sun()); sun.x = 2048 - 150; sun.y = 150; var cloud1 = game.addChild(new Cloud()); cloud1.x = 300; cloud1.y = 200; var cloud2 = game.addChild(new Cloud()); cloud2.x = 800; cloud2.y = 400; 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 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(); // Check for collisions with clouds if (bird.intersects(cloud1) || bird.intersects(cloud2)) { 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 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(); } } // 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; } };
===================================================================
--- original.js
+++ change.js
@@ -16,11 +16,13 @@
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;
@@ -99,8 +101,10 @@
cloud2.y = 400;
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 = [];
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.