User prompt
For every 50 touches, definitely 1 chicken will come out
User prompt
For every t0 touch, definitely 1 chicken will come out
User prompt
Every 5 chickens should have 2x more foxes
User prompt
Replace the text egg life with the text egg health and delete the text egg life
User prompt
Let foxes kill chickens and delete the score text above and write the life of the egg there and write the number of chickens instead of wave text
User prompt
Increase fox speed by 2x
User prompt
Reduce the chicken hatching rate to 2.5% and reduce the black chicken hatching rate to 0.5%
User prompt
Let a big fox come out from above every 20 foxes and die in 5 bullets
User prompt
foxes should not fall directly down, they should fall towards the egg
User prompt
Foxes should not change color when hit by bullets
User prompt
make the background baby blue
User prompt
make foxes orange ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
remove zombies, instead of zombies foxes will fall
User prompt
Kill zombies with one hit
User prompt
Zombies on the right and left fall diagonally
User prompt
Don't let the zombies fall down and attack the egg directly.
User prompt
Chickens should not be born together
User prompt
even higher
User prompt
Let them be born 2 floors higher
User prompt
Let chickens be born on eggs
User prompt
Chickens should be born on the left or right side of the egg, not on top
User prompt
remove the "tap the egg to hatch chicken" text on the egg
User prompt
The writing on the egg should be removed and the chickens should be born on the right or left side of the egg instead of on it.
User prompt
make the background a field
User prompt
Black chicken fire 3 bullets at once
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var BlackChicken = Container.expand(function () { var self = Container.call(this); var chickenGraphics = self.attachAsset('blackChicken', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 1; self.shootTimer = 0; self.shootCooldown = 60; // 1 second at 60fps self.target = null; self.lastTarget = null; self.damage = 4; // 4x stronger than regular chicken self.update = function () { // Find nearest zombie var nearestZombie = null; var nearestDistance = Infinity; for (var i = 0; i < zombies.length; i++) { var zombie = zombies[i]; var distance = Math.sqrt(Math.pow(zombie.x - self.x, 2) + Math.pow(zombie.y - self.y, 2)); if (distance < nearestDistance && distance < 300) { nearestDistance = distance; nearestZombie = zombie; } } self.target = nearestZombie; // Move towards target if (self.target) { var dx = self.target.x - self.x; var dy = self.target.y - self.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance > 0) { self.x += dx / distance * self.speed; self.y += dy / distance * self.speed; } } // Shoot at target self.shootTimer++; if (self.shootTimer >= self.shootCooldown && self.target) { self.shootTimer = 0; self.shoot(); } }; self.shoot = function () { if (self.target) { // Fire 3 shots for black chicken with slight spread var angles = [-0.3, 0, 0.3]; // Left, center, right spread for (var shotIndex = 0; shotIndex < 3; shotIndex++) { var newBullet = new Bullet(); newBullet.x = self.x; newBullet.y = self.y; // Add angle spread to target position var angle = Math.atan2(self.target.y - self.y, self.target.x - self.x) + angles[shotIndex]; var distance = 500; // Arbitrary distance for target calculation newBullet.targetX = self.x + Math.cos(angle) * distance; newBullet.targetY = self.y + Math.sin(angle) * distance; newBullet.damage = self.damage; // Use black chicken's damage bullets.push(newBullet); game.addChild(newBullet); } LK.getSound('shoot').play(); } }; return self; }); var Bullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.attachAsset('bullet', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 8; self.targetX = 0; self.targetY = 0; self.directionX = 0; self.directionY = 0; self.damage = 1; // Calculate direction on creation self.calculateDirection = function () { var dx = self.targetX - self.x; var dy = self.targetY - self.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance > 0) { self.directionX = dx / distance; self.directionY = dy / distance; } }; self.update = function () { if (self.directionX === 0 && self.directionY === 0) { self.calculateDirection(); } self.x += self.directionX * self.speed; self.y += self.directionY * self.speed; }; return self; }); var Chicken = Container.expand(function () { var self = Container.call(this); var chickenGraphics = self.attachAsset('chicken', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 1; self.shootTimer = 0; self.shootCooldown = 60; // 1 second at 60fps self.target = null; self.lastTarget = null; self.update = function () { // Find nearest zombie var nearestZombie = null; var nearestDistance = Infinity; for (var i = 0; i < zombies.length; i++) { var zombie = zombies[i]; var distance = Math.sqrt(Math.pow(zombie.x - self.x, 2) + Math.pow(zombie.y - self.y, 2)); if (distance < nearestDistance && distance < 300) { nearestDistance = distance; nearestZombie = zombie; } } self.target = nearestZombie; // Move towards target if (self.target) { var dx = self.target.x - self.x; var dy = self.target.y - self.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance > 0) { self.x += dx / distance * self.speed; self.y += dy / distance * self.speed; } } // Shoot at target self.shootTimer++; if (self.shootTimer >= self.shootCooldown && self.target) { self.shootTimer = 0; self.shoot(); } }; self.shoot = function () { if (self.target) { var newBullet = new Bullet(); newBullet.x = self.x; newBullet.y = self.y; newBullet.targetX = self.target.x; newBullet.targetY = self.target.y; bullets.push(newBullet); game.addChild(newBullet); LK.getSound('shoot').play(); } }; return self; }); var Egg = Container.expand(function () { var self = Container.call(this); var eggGraphics = self.attachAsset('egg', { anchorX: 0.5, anchorY: 0.5 }); self.health = 10; self.maxHealth = 10; self.hatchChance = 0.1; // 10% chance self.blackChickenChance = 0.025; // 2.5% chance self.lastHealth = self.health; self.down = function (x, y, obj) { self.tryHatch(); }; self.tryHatch = function () { var randomValue = Math.random(); if (randomValue < self.blackChickenChance) { // Spawn black chicken (2.5% chance) self.spawnBlackChicken(); LK.getSound('hatch').play(); LK.effects.flashObject(self, 0x000000, 300); } else if (randomValue < self.hatchChance) { // Spawn regular chicken (remaining 7.5% to reach 10% total) self.spawnChicken(); LK.getSound('hatch').play(); LK.effects.flashObject(self, 0xFFD700, 300); } else { // Failed hatch visual feedback tween(self, { scaleX: 1.1, scaleY: 1.1 }, { duration: 100, onFinish: function onFinish() { tween(self, { scaleX: 1, scaleY: 1 }, { duration: 100 }); } }); } }; self.spawnChicken = function () { var newChicken = new Chicken(); newChicken.x = self.x + (Math.random() - 0.5) * 100; newChicken.y = self.y - 50; chickens.push(newChicken); game.addChild(newChicken); }; self.spawnBlackChicken = function () { var newBlackChicken = new BlackChicken(); newBlackChicken.x = self.x + (Math.random() - 0.5) * 100; newBlackChicken.y = self.y - 50; chickens.push(newBlackChicken); game.addChild(newBlackChicken); }; self.takeDamage = function (damage) { self.health -= damage; LK.effects.flashObject(self, 0xFF0000, 500); // Update egg color based on health var healthRatio = self.health / self.maxHealth; if (healthRatio > 0.6) { eggGraphics.tint = 0xFFF8DC; // Beige } else if (healthRatio > 0.3) { eggGraphics.tint = 0xFFD700; // Yellow } else { eggGraphics.tint = 0xFF4500; // Red } if (self.health <= 0) { return true; // Egg is destroyed } return false; }; return self; }); var Zombie = Container.expand(function () { var self = Container.call(this); var zombieGraphics = self.attachAsset('zombie', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 2; self.health = 3; self.maxHealth = 3; self.lastY = 0; self.update = function () { self.y += self.speed; // Update health color based on damage var healthRatio = self.health / self.maxHealth; if (healthRatio > 0.6) { zombieGraphics.tint = 0x228B22; // Green } else if (healthRatio > 0.3) { zombieGraphics.tint = 0xFFD700; // Yellow } else { zombieGraphics.tint = 0xFF4500; // Red } }; self.takeDamage = function (damage) { self.health -= damage; LK.effects.flashObject(self, 0xFF0000, 200); if (self.health <= 0) { return true; // Zombie is dead } return false; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x228B22 }); /**** * Game Code ****/ var egg = null; var zombies = []; var chickens = []; var bullets = []; var zombieSpawnTimer = 0; var zombieSpawnRate = 120; // 2 seconds at 60fps var waveNumber = 1; var zombiesKilled = 0; var gameStartTime = Date.now(); // Create UI elements var scoreTxt = new Text2('Score: 0', { size: 60, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); var healthTxt = new Text2('Egg Health: 10', { size: 50, fill: 0xFFFFFF }); healthTxt.anchor.set(0, 0); healthTxt.x = 50; healthTxt.y = 50; LK.gui.topLeft.addChild(healthTxt); var waveTxt = new Text2('Wave: 1', { size: 50, fill: 0xFFFFFF }); waveTxt.anchor.set(1, 0); waveTxt.x = -50; waveTxt.y = 50; LK.gui.topRight.addChild(waveTxt); // Create egg at bottom center egg = new Egg(); egg.x = 2048 / 2; egg.y = 2732 - 200; game.addChild(egg); function spawnZombie() { var newZombie = new Zombie(); newZombie.x = Math.random() * (2048 - 160) + 80; newZombie.y = -50; newZombie.speed = 1 + Math.random() * 2 + waveNumber * 0.5; newZombie.lastY = newZombie.y; zombies.push(newZombie); game.addChild(newZombie); } function updateDifficulty() { var currentTime = Date.now(); var elapsedTime = (currentTime - gameStartTime) / 1000; // Increase wave every 30 seconds var newWave = Math.floor(elapsedTime / 30) + 1; if (newWave > waveNumber) { waveNumber = newWave; waveTxt.setText('Wave: ' + waveNumber); // Increase spawn rate zombieSpawnRate = Math.max(30, 120 - waveNumber * 10); } } game.update = function () { updateDifficulty(); // Spawn zombies zombieSpawnTimer++; if (zombieSpawnTimer >= zombieSpawnRate) { zombieSpawnTimer = 0; spawnZombie(); } // Update zombies for (var i = zombies.length - 1; i >= 0; i--) { var zombie = zombies[i]; // Check if zombie reached egg if (zombie.lastY < egg.y && zombie.y >= egg.y && Math.abs(zombie.x - egg.x) < 100) { // Zombie attacks egg if (egg.takeDamage(1)) { // Egg is destroyed - game over LK.effects.flashScreen(0xFF0000, 1000); LK.showGameOver(); return; } healthTxt.setText('Egg Health: ' + egg.health); // Remove zombie after attack zombie.destroy(); zombies.splice(i, 1); continue; } // Remove zombies that go off screen if (zombie.y > 2732 + 100) { zombie.destroy(); zombies.splice(i, 1); continue; } zombie.lastY = zombie.y; } // Update bullets for (var j = bullets.length - 1; j >= 0; j--) { var bullet = bullets[j]; // Check bullet-zombie collisions var hit = false; for (var k = zombies.length - 1; k >= 0; k--) { var zombie = zombies[k]; if (bullet.intersects(zombie)) { // Bullet hits zombie if (zombie.takeDamage(bullet.damage)) { // Zombie is killed LK.getSound('zombieHit').play(); zombiesKilled++; LK.setScore(zombiesKilled * 10); scoreTxt.setText('Score: ' + LK.getScore()); zombie.destroy(); zombies.splice(k, 1); } bullet.destroy(); bullets.splice(j, 1); hit = true; break; } } // Remove bullets that go off screen if (!hit && (bullet.x < -50 || bullet.x > 2048 + 50 || bullet.y < -50 || bullet.y > 2732 + 50)) { bullet.destroy(); bullets.splice(j, 1); } } // Update chickens for (var l = chickens.length - 1; l >= 0; l--) { var chicken = chickens[l]; // Check if chicken is still alive (no health system for chickens yet) // Could add zombie attacks on chickens in future versions } };
===================================================================
--- original.js
+++ change.js
@@ -201,21 +201,17 @@
}
};
self.spawnChicken = function () {
var newChicken = new Chicken();
- // Spawn to the left or right of the egg
- var side = Math.random() < 0.5 ? -1 : 1; // -1 for left, 1 for right
- newChicken.x = self.x + side * 200; // 200 pixels to the side
- newChicken.y = self.y;
+ newChicken.x = self.x + (Math.random() - 0.5) * 100;
+ newChicken.y = self.y - 50;
chickens.push(newChicken);
game.addChild(newChicken);
};
self.spawnBlackChicken = function () {
var newBlackChicken = new BlackChicken();
- // Spawn to the left or right of the egg
- var side = Math.random() < 0.5 ? -1 : 1; // -1 for left, 1 for right
- newBlackChicken.x = self.x + side * 200; // 200 pixels to the side
- newBlackChicken.y = self.y;
+ newBlackChicken.x = self.x + (Math.random() - 0.5) * 100;
+ newBlackChicken.y = self.y - 50;
chickens.push(newBlackChicken);
game.addChild(newBlackChicken);
};
self.takeDamage = function (damage) {
@@ -311,15 +307,8 @@
waveTxt.anchor.set(1, 0);
waveTxt.x = -50;
waveTxt.y = 50;
LK.gui.topRight.addChild(waveTxt);
-var instructionTxt = new Text2('Tap the egg to hatch chickens!', {
- size: 40,
- fill: 0xFFFFFF
-});
-instructionTxt.anchor.set(0.5, 1);
-instructionTxt.y = -100;
-LK.gui.bottom.addChild(instructionTxt);
// Create egg at bottom center
egg = new Egg();
egg.x = 2048 / 2;
egg.y = 2732 - 200;