/****
* Classes
****/
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.8;
self.flapPower = -12;
self.rotation = 0;
self.flap = function () {
self.velocity = self.flapPower;
LK.getSound('flap').play();
};
self.update = function () {
self.velocity += self.gravity;
self.y += self.velocity;
// Rotate bird based on velocity
self.rotation = Math.min(Math.max(self.velocity * 0.05, -0.5), 1.2);
birdGraphics.rotation = self.rotation;
// Check ground collision
if (self.y > 2732 - 150) {
self.y = 2732 - 150;
gameOver = true;
}
// Check ceiling collision
if (self.y < 50) {
self.y = 50;
gameOver = true;
}
};
return self;
});
var Pipe = Container.expand(function () {
var self = Container.call(this);
self.gapSize = 300;
self.speed = -4;
self.scored = false;
// Create top pipe
self.topPipe = self.attachAsset('pipe', {
anchorX: 0.5,
anchorY: 1
});
// Create bottom pipe
self.bottomPipe = self.attachAsset('pipe', {
anchorX: 0.5,
anchorY: 0
});
self.setGapPosition = function (gapY) {
self.topPipe.y = gapY - self.gapSize / 2;
self.bottomPipe.y = gapY + self.gapSize / 2;
};
self.update = function () {
self.x += self.speed;
// Check if bird passed through pipe
if (!self.scored && self.x < bird.x) {
self.scored = true;
LK.setScore(LK.getScore() + 1);
scoreTxt.setText(LK.getScore());
LK.getSound('score').play();
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB
});
/****
* Game Code
****/
var bird;
var pipes = [];
var ground;
var scoreTxt;
var gameOver = false;
var gameStarted = false;
var pipeSpawnTimer = 0;
var pipeSpawnInterval = 90; // frames between pipe spawns
// Create ground
ground = game.addChild(LK.getAsset('ground', {
anchorX: 0,
anchorY: 1,
x: 0,
y: 2732
}));
// Create bird
bird = game.addChild(new Bird());
bird.x = 300;
bird.y = 2732 / 2;
// Create score text
scoreTxt = new Text2('0', {
size: 80,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
scoreTxt.y = 100;
// Create instruction text
var instructionTxt = new Text2('TAP TO START', {
size: 60,
fill: 0xFFFFFF
});
instructionTxt.anchor.set(0.5, 0.5);
LK.gui.center.addChild(instructionTxt);
function spawnPipe() {
var pipe = new Pipe();
pipe.x = 2048 + 60;
// Random gap position between 200 and 2532 (accounting for gap size)
var gapY = 200 + Math.random() * (2532 - 400);
pipe.setGapPosition(gapY);
pipes.push(pipe);
game.addChild(pipe);
}
function checkCollisions() {
for (var i = 0; i < pipes.length; i++) {
var pipe = pipes[i];
// Check collision with top pipe
if (bird.intersects(pipe.topPipe)) {
gameOver = true;
LK.getSound('hit').play();
return;
}
// Check collision with bottom pipe
if (bird.intersects(pipe.bottomPipe)) {
gameOver = true;
LK.getSound('hit').play();
return;
}
}
}
function cleanupPipes() {
for (var i = pipes.length - 1; i >= 0; i--) {
var pipe = pipes[i];
if (pipe.x < -100) {
pipe.destroy();
pipes.splice(i, 1);
}
}
}
game.down = function (x, y, obj) {
if (gameOver) {
return;
}
if (!gameStarted) {
gameStarted = true;
instructionTxt.visible = false;
}
bird.flap();
};
game.update = function () {
if (gameOver) {
LK.showGameOver();
return;
}
if (!gameStarted) {
return;
}
// Update bird
// Spawn pipes
pipeSpawnTimer++;
if (pipeSpawnTimer >= pipeSpawnInterval) {
spawnPipe();
pipeSpawnTimer = 0;
}
// Check collisions
checkCollisions();
// Cleanup off-screen pipes
cleanupPipes();
}; ===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,177 @@
-/****
+/****
+* Classes
+****/
+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.8;
+ self.flapPower = -12;
+ self.rotation = 0;
+ self.flap = function () {
+ self.velocity = self.flapPower;
+ LK.getSound('flap').play();
+ };
+ self.update = function () {
+ self.velocity += self.gravity;
+ self.y += self.velocity;
+ // Rotate bird based on velocity
+ self.rotation = Math.min(Math.max(self.velocity * 0.05, -0.5), 1.2);
+ birdGraphics.rotation = self.rotation;
+ // Check ground collision
+ if (self.y > 2732 - 150) {
+ self.y = 2732 - 150;
+ gameOver = true;
+ }
+ // Check ceiling collision
+ if (self.y < 50) {
+ self.y = 50;
+ gameOver = true;
+ }
+ };
+ return self;
+});
+var Pipe = Container.expand(function () {
+ var self = Container.call(this);
+ self.gapSize = 300;
+ self.speed = -4;
+ self.scored = false;
+ // Create top pipe
+ self.topPipe = self.attachAsset('pipe', {
+ anchorX: 0.5,
+ anchorY: 1
+ });
+ // Create bottom pipe
+ self.bottomPipe = self.attachAsset('pipe', {
+ anchorX: 0.5,
+ anchorY: 0
+ });
+ self.setGapPosition = function (gapY) {
+ self.topPipe.y = gapY - self.gapSize / 2;
+ self.bottomPipe.y = gapY + self.gapSize / 2;
+ };
+ self.update = function () {
+ self.x += self.speed;
+ // Check if bird passed through pipe
+ if (!self.scored && self.x < bird.x) {
+ self.scored = true;
+ LK.setScore(LK.getScore() + 1);
+ scoreTxt.setText(LK.getScore());
+ LK.getSound('score').play();
+ }
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x87CEEB
+});
+
+/****
+* Game Code
+****/
+var bird;
+var pipes = [];
+var ground;
+var scoreTxt;
+var gameOver = false;
+var gameStarted = false;
+var pipeSpawnTimer = 0;
+var pipeSpawnInterval = 90; // frames between pipe spawns
+// Create ground
+ground = game.addChild(LK.getAsset('ground', {
+ anchorX: 0,
+ anchorY: 1,
+ x: 0,
+ y: 2732
+}));
+// Create bird
+bird = game.addChild(new Bird());
+bird.x = 300;
+bird.y = 2732 / 2;
+// Create score text
+scoreTxt = new Text2('0', {
+ size: 80,
+ fill: 0xFFFFFF
+});
+scoreTxt.anchor.set(0.5, 0);
+LK.gui.top.addChild(scoreTxt);
+scoreTxt.y = 100;
+// Create instruction text
+var instructionTxt = new Text2('TAP TO START', {
+ size: 60,
+ fill: 0xFFFFFF
+});
+instructionTxt.anchor.set(0.5, 0.5);
+LK.gui.center.addChild(instructionTxt);
+function spawnPipe() {
+ var pipe = new Pipe();
+ pipe.x = 2048 + 60;
+ // Random gap position between 200 and 2532 (accounting for gap size)
+ var gapY = 200 + Math.random() * (2532 - 400);
+ pipe.setGapPosition(gapY);
+ pipes.push(pipe);
+ game.addChild(pipe);
+}
+function checkCollisions() {
+ for (var i = 0; i < pipes.length; i++) {
+ var pipe = pipes[i];
+ // Check collision with top pipe
+ if (bird.intersects(pipe.topPipe)) {
+ gameOver = true;
+ LK.getSound('hit').play();
+ return;
+ }
+ // Check collision with bottom pipe
+ if (bird.intersects(pipe.bottomPipe)) {
+ gameOver = true;
+ LK.getSound('hit').play();
+ return;
+ }
+ }
+}
+function cleanupPipes() {
+ for (var i = pipes.length - 1; i >= 0; i--) {
+ var pipe = pipes[i];
+ if (pipe.x < -100) {
+ pipe.destroy();
+ pipes.splice(i, 1);
+ }
+ }
+}
+game.down = function (x, y, obj) {
+ if (gameOver) {
+ return;
+ }
+ if (!gameStarted) {
+ gameStarted = true;
+ instructionTxt.visible = false;
+ }
+ bird.flap();
+};
+game.update = function () {
+ if (gameOver) {
+ LK.showGameOver();
+ return;
+ }
+ if (!gameStarted) {
+ return;
+ }
+ // Update bird
+ // Spawn pipes
+ pipeSpawnTimer++;
+ if (pipeSpawnTimer >= pipeSpawnInterval) {
+ spawnPipe();
+ pipeSpawnTimer = 0;
+ }
+ // Check collisions
+ checkCollisions();
+ // Cleanup off-screen pipes
+ cleanupPipes();
+};
\ No newline at end of file
single pole flappy bird. In-Game asset. 2d. High contrast. No shadows
ground have mincraft ground trxture. In-Game asset. 2d. High contrast. No shadows
long dragon. In-Game asset. 2d. High contrast. No shadows
yeti cartoon image. In-Game asset. 2d. High contrast. No shadows
speed dragon. In-Game asset. 2d. High contrast. No shadows
mount everest. In-Game asset. 2d. High contrast. No shadows
crown. In-Game asset. 2d. High contrast. No shadows
replay button. In-Game asset. 2d. High contrast. No shadows