User prompt
Make the birds easier to control
User prompt
Once you fall the floor, you die
User prompt
Please
User prompt
Every single time you die, it shows you your score and a funny picture of a bird
User prompt
Every single time you die, make a funny message relating to birds
User prompt
Every single time the bird falls on the floor he dies
User prompt
Make a score every time you touch the fruit
User prompt
Make a thing called fruit that the bird collects
Initial prompt
Flappy float
/**** * Classes ****/ //<Assets used in the game will automatically appear here> //<Write imports for supported plugins here> // Bird class to represent the player var Bird = Container.expand(function () { var self = Container.call(this); var birdGraphics = self.attachAsset('bird', { anchorX: 0.5, anchorY: 0.5 }); self.speedY = 0; self.gravity = 0.5; self.flapStrength = -10; self.update = function () { self.speedY += self.gravity; self.y += self.speedY; // Check for collision with top and bottom of the screen if (self.y < 0) { self.y = 0; self.speedY = 0; } else if (self.y > 2732) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } }; self.flap = function () { self.speedY = self.flapStrength; }; }); // Fruit class to represent the collectible items var Fruit = Container.expand(function () { var self = Container.call(this); var fruitGraphics = self.attachAsset('fruit', { anchorX: 0.5, anchorY: 0.5 }); self.speedX = -5; self.update = function () { self.x += self.speedX; // Reset fruit position if it goes off screen if (self.x < -fruitGraphics.width) { self.x = 2048 + fruitGraphics.width; self.y = Math.random() * 2000 + 200; } }; }); // Wall class to represent the obstacles var Wall = Container.expand(function () { var self = Container.call(this); var wallGraphics = self.attachAsset('wall', { anchorX: 0.5, anchorY: 0.5 }); self.speedX = -5; self.update = function () { self.x += self.speedX; // Reset wall position if it goes off screen if (self.x < -wallGraphics.width) { self.x = 2048 + wallGraphics.width; self.y = Math.random() * 2000 + 200; } }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB // Sky blue background }); /**** * Game Code ****/ // Initialize bird var bird = new Bird(); bird.x = 2048 / 4; bird.y = 2732 / 2; game.addChild(bird); // Initialize walls var walls = []; for (var i = 0; i < 3; i++) { var wall = new Wall(); wall.x = 2048 + i * 700; wall.y = Math.random() * 2000 + 200; walls.push(wall); game.addChild(wall); } // Initialize fruits var fruits = []; for (var i = 0; i < 5; i++) { var fruit = new Fruit(); fruit.x = 2048 + i * 500; fruit.y = Math.random() * 2000 + 200; fruits.push(fruit); game.addChild(fruit); } // Handle game updates game.update = function () { bird.update(); walls.forEach(function (wall) { wall.update(); // Check for collision with bird if (bird.intersects(wall)) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } }); fruits.forEach(function (fruit) { fruit.update(); // Check for collision with bird if (bird.intersects(fruit)) { // Increase score by 1 LK.setScore(LK.getScore() + 1); // Reset fruit position fruit.x = 2048 + fruit.width; fruit.y = Math.random() * 2000 + 200; } }); }; // Handle touch input for flapping game.down = function (x, y, obj) { bird.flap(); };
===================================================================
--- original.js
+++ change.js
@@ -20,10 +20,10 @@
if (self.y < 0) {
self.y = 0;
self.speedY = 0;
} else if (self.y > 2732) {
- self.y = 2732;
- self.speedY = 0;
+ LK.effects.flashScreen(0xff0000, 1000);
+ LK.showGameOver();
}
};
self.flap = function () {
self.speedY = self.flapStrength;