User prompt
The new birdseed appears after 1 second, in a new location.
User prompt
When the birdseed is eaten, a new one appears.
User prompt
The birdseed appears on screen at the start of the game. The pigeon pecks at the seed, when the user scrolls the pigeon nearby the birdseed, and the player gets 100 points.
User prompt
The birdseed appears on screen every 5 seconds.
User prompt
The pigeon is controlled by the user’s thumb on a mobile device. The bird generates a signal when the bird approaches nearby birdseed.
User prompt
The bird walks on screen and approaches. The user tosses out bird seed for the pigeon.
User prompt
I want the pigeon to peck at the seed.
Initial prompt
Pigeons and Friends
/**** * Classes ****/ // BirdSeed class representing the seed var BirdSeed = Container.expand(function () { var self = Container.call(this); var birdSeedGraphics = self.attachAsset('birdseed1', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { // Update logic for birdseed }; }); //<Assets used in the game will automatically appear here> //<Write imports for supported plugins here> // Pigeon class representing the player character var Pigeon = Container.expand(function () { var self = Container.call(this); var pigeonGraphics = self.attachAsset('pigeon', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.update = function () { // Update logic for pigeon }; self.down = function (x, y, obj) { // Handle touch down event self.x = x; self.y = y; // Check for collisions between pigeon and birdseeds for (var i = birdSeeds.length - 1; i >= 0; i--) { var birdSeed = birdSeeds[i]; if (self.intersects(birdSeed)) { LK.getSound('pigeonpeck1').play(); birdSeed.destroy(); birdSeeds.splice(i, 1); } // Check for proximity between pigeon and birdseeds else if (Math.abs(self.x - birdSeed.x) < 200 && Math.abs(self.y - birdSeed.y) < 200) { console.log("Pigeon is approaching the birdseed!"); } } }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87ceeb // Init game with sky blue background }); /**** * Game Code ****/ // Initialize game variables var pigeon = game.addChild(new Pigeon()); pigeon.x = 2048 / 2; pigeon.y = 2732 - 200; var birdSeeds = []; var score = 0; // Spawn initial birdseed spawnBirdSeed(); // Function to spawn birdseeds at random positions function spawnBirdSeed() { var birdSeed = new BirdSeed(); birdSeed.x = Math.random() * 2048; birdSeed.y = Math.random() * 2732; birdSeeds.push(birdSeed); game.addChild(birdSeed); } // Handle game move event game.move = function (x, y, obj) { pigeon.x = x; pigeon.y = y; }; // Update game logic game.update = function () { // Check for collisions between pigeon and birdseeds for (var i = birdSeeds.length - 1; i >= 0; i--) { var birdSeed = birdSeeds[i]; if (pigeon.intersects(birdSeed)) { score += 100; // Award 100 points birdSeed.destroy(); birdSeeds.splice(i, 1); LK.setTimeout(spawnBirdSeed, 1000); // Spawn a new birdseed after 1 second LK.getSound('pigeonpeck1').play(); } } // Spawn new birdseed every 300 frames if (LK.ticks % 300 === 0) { spawnBirdSeed(); } }; // Display score var scoreTxt = new Text2('Score: 0', { size: 100, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Update score display function updateScore() { scoreTxt.setText('Score: ' + score); } // Call updateScore every frame game.update = function () { updateScore(); };
===================================================================
--- original.js
+++ change.js
@@ -84,9 +84,9 @@
if (pigeon.intersects(birdSeed)) {
score += 100; // Award 100 points
birdSeed.destroy();
birdSeeds.splice(i, 1);
- spawnBirdSeed(); // Spawn a new birdseed immediately
+ LK.setTimeout(spawnBirdSeed, 1000); // Spawn a new birdseed after 1 second
LK.getSound('pigeonpeck1').play();
}
}
// Spawn new birdseed every 300 frames