User prompt
Generate a description for this game
User prompt
Make it so that the boost only happens if you collect the sugar
User prompt
Make a sound effect play when you collect the sugar
User prompt
Make it so sugar randomly spawns and you have to touch it to activate the mechanic
User prompt
Make a sugar mechanic that if used makes your gravity stronger but also make your flap strength higher
User prompt
Move the ground sprite left 1000 units
User prompt
Make the horizontal space between pipes bigger by 1000units
User prompt
Make the gravity slightly stronger
User prompt
Increase the flap strength
User prompt
Make it less floaty
User prompt
Make it so if you touch the ceiling you lose
User prompt
Remove the shop
User prompt
Make it so you can access the shop
User prompt
Make it so you can only access the shop before the game
User prompt
add a shop
User prompt
Again
User prompt
Do that again
User prompt
Make it so there is more space between each pair of pipes, not the gap that you fly through, the part after that
User prompt
Delay spawning a new pipe by 0.2 seconds
User prompt
Undo
User prompt
Make it so there is more space between horizontal pipes
User prompt
Undo
User prompt
Make the gap between separate pipes bigger
User prompt
Make it so the top pipe sprite shows it being upside down
User prompt
Undo
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * 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.7; self.flapStrength = -15; self.rotation = 0; self.dead = false; self.flap = function () { if (self.dead) { return; } self.velocity = self.flapStrength * (sugarActive ? 1.5 : 1); LK.getSound('flap').play(); // Rotate bird upward when flapping tween(self, { rotation: -0.5 }, { duration: 200, easing: tween.easeOut }); }; self.update = function () { if (self.dead) { return; } if (gameStarted) { self.velocity += self.gravity * (sugarActive ? 1.5 : 1); self.y += self.velocity; } // Rotate bird downward when falling if (self.velocity > 0) { var targetRotation = Math.min(Math.PI / 2, self.velocity * 0.05); tween(self, { rotation: targetRotation }, { duration: 100, easing: tween.linear }); } }; self.die = function () { if (self.dead) { return; } self.dead = true; LK.getSound('hit').play(); // Flash red when dying LK.effects.flashObject(self, 0xFF0000, 500); }; return self; }); var Pipe = Container.expand(function () { var self = Container.call(this); var topPipe = self.attachAsset('pipe', { anchorX: 0.5, anchorY: 1.0, flipY: 1 // Flip the top pipe vertically }); var bottomPipe = self.attachAsset('pipe', { anchorX: 0.5, anchorY: 0.0 }); self.gapSize = 400; self.speed = 5; self.scored = false; self.setGapPosition = function (y) { topPipe.y = y - self.gapSize / 2; // Adjust top pipe position bottomPipe.y = y + self.gapSize / 2; // Revert bottom pipe position to its original state }; self.update = function () { self.x -= self.speed; }; return self; }); var Sugar = Container.expand(function () { var self = Container.call(this); var sugarGraphics = self.attachAsset('sugar', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.update = function () { self.x -= self.speed; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB }); /**** * Game Code ****/ var sugarActive = false; // Initialize GUI elements var bird; var pipes = []; var ground; var gameStarted = false; var gameSpeed = 5; var pipeSpawnTimer = 0; var pipeSpawnInterval = 100; var score = 0; var highScore = storage.highScore || 0; var gameOver = false; // Initialize GUI elements var scoreTxt = new Text2('0', { size: 150, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); var tapToStartTxt = new Text2('TAP TO START', { size: 80, fill: 0xFFFFFF }); tapToStartTxt.anchor.set(0.5, 0.5); LK.gui.center.addChild(tapToStartTxt); var highScoreTxt = new Text2('BEST: 0', { size: 60, fill: 0xFFFFFF }); highScoreTxt.anchor.set(0.5, 0); highScoreTxt.y = 160; highScoreTxt.setText('BEST: ' + highScore); LK.gui.top.addChild(highScoreTxt); // Initialize game objects function initGame() { // Create bird bird = new Bird(); bird.x = 400; bird.y = 2732 / 2; bird.velocity = 0; // Ensure bird doesn't move before game starts game.addChild(bird); // Create ground ground = LK.getAsset('ground', { anchorX: 0, anchorY: 0 }); ground.x -= 1000; ground.y = 2732 - ground.height; game.addChild(ground); // Move ground to the front game.setChildIndex(ground, game.children.length - 1); // Reset game state pipes = []; sugars = []; gameStarted = false; gameSpeed = 5; pipeSpawnTimer = 0; sugarSpawnTimer = 0; score = 0; gameOver = false; // Update score display scoreTxt.setText('0'); LK.setScore(0); // Show tap to start message tapToStartTxt.visible = true; // Play background music LK.playMusic('bgmusic', { fade: { start: 0, end: 0.4, duration: 1000 } }); } // Create a new pipe function spawnPipe() { var pipe = new Pipe(); pipe.x = 2048 + pipe.width + 1600; // Increase space between pipes by another 1000 pixels // Random gap position, but keep within reasonable bounds var minGapX = 400; var maxGapX = 2048 - 400; var gapX = minGapX + Math.random() * (maxGapX - minGapX); pipe.setGapPosition(gapX); pipe.speed = gameSpeed; game.addChild(pipe); pipes.push(pipe); } // Start the game function startGame() { if (gameStarted || gameOver) { return; } gameStarted = true; tapToStartTxt.visible = false; bird.flap(); } // Handle collision detection function checkCollisions() { if (!gameStarted || gameOver) { return; } // Check for ground collision if (bird.y + bird.height / 2 > ground.y) { gameEnd(); return; } // Check for ceiling collision if (bird.y - bird.height / 2 < 0) { gameEnd(); // Trigger game over when touching the ceiling return; } // Check for pipe collisions for (var i = 0; i < pipes.length; i++) { var pipe = pipes[i]; // Get references to the pipe parts var topPipe = pipe.children[0]; var bottomPipe = pipe.children[1]; // Convert positions to global game coordinates var topPipeGlobal = game.toLocal(topPipe.parent.toGlobal(topPipe.position)); var bottomPipeGlobal = game.toLocal(bottomPipe.parent.toGlobal(bottomPipe.position)); // Check for collision with top pipe if (bird.x + bird.width / 3 > pipe.x - topPipe.width / 2 && bird.x - bird.width / 3 < pipe.x + topPipe.width / 2 && bird.y - bird.height / 3 < topPipeGlobal.y) { gameEnd(); return; } // Check for collision with bottom pipe if (bird.x + bird.width / 3 > pipe.x - bottomPipe.width / 2 && bird.x - bird.width / 3 < pipe.x + bottomPipe.width / 2 && bird.y + bird.height / 3 > bottomPipeGlobal.y) { gameEnd(); return; } // Check if bird passed pipe (scoring) if (!pipe.scored && pipe.x + topPipe.width / 2 < bird.x - bird.width / 2) { pipe.scored = true; incrementScore(); } } // Check for sugar collisions for (var i = sugars.length - 1; i >= 0; i--) { if (bird.intersects(sugars[i])) { sugarActive = true; sugars[i].destroy(); sugars.splice(i, 1); } } } // Increment the score function incrementScore() { score++; LK.setScore(score); scoreTxt.setText(score.toString()); // Increase game speed slightly with each point if (score % 5 === 0 && gameSpeed < 10) { gameSpeed += 0.5; // Update speed for existing pipes for (var i = 0; i < pipes.length; i++) { pipes[i].speed = gameSpeed; } } LK.getSound('point').play(); // Update high score if needed if (score > highScore) { highScore = score; storage.highScore = highScore; highScoreTxt.setText('BEST: ' + highScore); } } // End the game function gameEnd() { if (gameOver) { return; } gameOver = true; bird.die(); // Flash screen red LK.effects.flashScreen(0xFF0000, 500); // Show game over after a short delay LK.setTimeout(function () { LK.showGameOver(); }, 1000); } // Input handlers game.down = function (x, y, obj) { if (!gameStarted) { startGame(); } else if (!gameOver) { sugarActive = !sugarActive; bird.flap(); } }; // Game update function game.update = function () { if (gameStarted && !gameOver) { // Spawn pipes pipeSpawnTimer++; if (pipeSpawnTimer >= pipeSpawnInterval) { LK.setTimeout(function () { spawnPipe(); }, 200); // Delay spawning by 0.2 seconds pipeSpawnTimer = 0; } // Spawn sugar sugarSpawnTimer++; if (sugarSpawnTimer >= 300) { // Randomly spawn sugar every 300 frames var sugar = new Sugar(); sugar.x = 2048 + sugar.width; sugar.y = Math.random() * (2732 - 200); // Random y position game.addChild(sugar); sugars.push(sugar); sugarSpawnTimer = 0; } // Update pipes for (var i = pipes.length - 1; i >= 0; i--) { pipes[i].update(); // Remove pipes that have gone off-screen if (pipes[i].x < -pipes[i].width) { pipes[i].destroy(); pipes.splice(i, 1); } } // Update sugars for (var i = sugars.length - 1; i >= 0; i--) { sugars[i].update(); // Remove sugars that have gone off-screen if (sugars[i].x < -sugars[i].width) { sugars[i].destroy(); sugars.splice(i, 1); } } // Check for collisions checkCollisions(); } }; // Initialize the game initGame();
===================================================================
--- original.js
+++ change.js
@@ -84,8 +84,20 @@
self.x -= self.speed;
};
return self;
});
+var Sugar = Container.expand(function () {
+ var self = Container.call(this);
+ var sugarGraphics = self.attachAsset('sugar', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = 5;
+ self.update = function () {
+ self.x -= self.speed;
+ };
+ return self;
+});
/****
* Initialize Game
****/
@@ -148,11 +160,13 @@
// Move ground to the front
game.setChildIndex(ground, game.children.length - 1);
// Reset game state
pipes = [];
+ sugars = [];
gameStarted = false;
gameSpeed = 5;
pipeSpawnTimer = 0;
+ sugarSpawnTimer = 0;
score = 0;
gameOver = false;
// Update score display
scoreTxt.setText('0');
@@ -229,8 +243,16 @@
pipe.scored = true;
incrementScore();
}
}
+ // Check for sugar collisions
+ for (var i = sugars.length - 1; i >= 0; i--) {
+ if (bird.intersects(sugars[i])) {
+ sugarActive = true;
+ sugars[i].destroy();
+ sugars.splice(i, 1);
+ }
+ }
}
// Increment the score
function incrementScore() {
score++;
@@ -285,8 +307,19 @@
spawnPipe();
}, 200); // Delay spawning by 0.2 seconds
pipeSpawnTimer = 0;
}
+ // Spawn sugar
+ sugarSpawnTimer++;
+ if (sugarSpawnTimer >= 300) {
+ // Randomly spawn sugar every 300 frames
+ var sugar = new Sugar();
+ sugar.x = 2048 + sugar.width;
+ sugar.y = Math.random() * (2732 - 200); // Random y position
+ game.addChild(sugar);
+ sugars.push(sugar);
+ sugarSpawnTimer = 0;
+ }
// Update pipes
for (var i = pipes.length - 1; i >= 0; i--) {
pipes[i].update();
// Remove pipes that have gone off-screen
@@ -294,8 +327,17 @@
pipes[i].destroy();
pipes.splice(i, 1);
}
}
+ // Update sugars
+ for (var i = sugars.length - 1; i >= 0; i--) {
+ sugars[i].update();
+ // Remove sugars that have gone off-screen
+ if (sugars[i].x < -sugars[i].width) {
+ sugars[i].destroy();
+ sugars.splice(i, 1);
+ }
+ }
// Check for collisions
checkCollisions();
}
};
Flappy bird pipe, is green. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Grass. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Pile of sugar. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows