User prompt
make it flap and float
User prompt
make wood larger and bigger triangle from wood
User prompt
add wood on side
User prompt
make 80 levels
User prompt
make it slow
User prompt
give it shape of parrot
User prompt
make it parrot bird
User prompt
Make it bird and make hand and some obstacles and make it to float quickly.
User prompt
add obstical
Initial prompt
flapper
===================================================================
--- original.js
+++ change.js
@@ -1,87 +1,99 @@
-/****
+/****
* Classes
-****/
+****/
// Assets will be automatically created and loaded by the LK engine based on their usage in the code.
// Bird class to represent the player's character
var Bird = Container.expand(function () {
- var self = Container.call(this);
- var birdGraphics = self.attachAsset('bird', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.velocity = 0;
- self.gravity = 0.5;
- self.flapStrength = -10;
- self.update = function () {
- self.velocity += self.gravity;
- self.y += self.velocity;
- };
- self.flap = function () {
- self.velocity = self.flapStrength;
- };
+ var self = Container.call(this);
+ var birdGraphics = self.attachAsset('bird', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.velocity = 0;
+ self.gravity = 0.5;
+ self.flapStrength = -10;
+ self.update = function () {
+ self.velocity += self.gravity;
+ self.y += self.velocity;
+ };
+ self.flap = function () {
+ self.velocity = self.flapStrength;
+ };
});
+// Obstacle class to represent obstacles
+var Obstacle = Container.expand(function () {
+ var self = Container.call(this);
+ var obstacleGraphics = self.attachAsset('pipe', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = -5;
+ self.update = function () {
+ self.x += self.speed;
+ };
+});
// Pipe class to represent obstacles
var Pipe = Container.expand(function () {
- var self = Container.call(this);
- var pipeGraphics = self.attachAsset('pipe', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.speed = -5;
- self.update = function () {
- self.x += self.speed;
- };
+ var self = Container.call(this);
+ var pipeGraphics = self.attachAsset('pipe', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = -5;
+ self.update = function () {
+ self.x += self.speed;
+ };
});
-/****
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x87CEEB // Sky blue background
+ backgroundColor: 0x87CEEB // Sky blue background
});
-/****
+/****
* Game Code
-****/
+****/
var bird = game.addChild(new Bird());
bird.x = 2048 / 4;
bird.y = 2732 / 2;
var pipes = [];
var pipeInterval = 1500;
var lastPipeTime = 0;
var score = 0;
var scoreTxt = new Text2('0', {
- size: 150,
- fill: "#ffffff"
+ size: 150,
+ fill: "#ffffff"
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
game.down = function (x, y, obj) {
- bird.flap();
+ bird.flap();
};
game.update = function () {
- bird.update();
- if (bird.y > 2732 || bird.y < 0) {
- LK.showGameOver();
- }
- if (LK.ticks - lastPipeTime > pipeInterval) {
- var pipe = new Pipe();
- pipe.x = 2048;
- pipe.y = Math.random() * (2732 - 400) + 200;
- pipes.push(pipe);
- game.addChild(pipe);
- lastPipeTime = LK.ticks;
- }
- for (var i = pipes.length - 1; i >= 0; i--) {
- pipes[i].update();
- if (pipes[i].x < -100) {
- pipes[i].destroy();
- pipes.splice(i, 1);
- score++;
- scoreTxt.setText(score);
- }
- if (bird.intersects(pipes[i])) {
- LK.showGameOver();
- }
- }
+ bird.update();
+ if (bird.y > 2732 || bird.y < 0) {
+ LK.showGameOver();
+ }
+ if (LK.ticks - lastPipeTime > pipeInterval) {
+ var obstacle = new Obstacle();
+ obstacle.x = 2048;
+ obstacle.y = Math.random() * (2732 - 400) + 200;
+ pipes.push(obstacle);
+ game.addChild(obstacle);
+ lastPipeTime = LK.ticks;
+ }
+ for (var i = pipes.length - 1; i >= 0; i--) {
+ pipes[i].update();
+ if (pipes[i].x < -100) {
+ pipes[i].destroy();
+ pipes.splice(i, 1);
+ score++;
+ scoreTxt.setText(score);
+ }
+ if (bird.intersects(pipes[i])) {
+ LK.showGameOver();
+ }
+ }
};
\ No newline at end of file