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 fox var nearestFox = null; var nearestDistance = Infinity; for (var i = 0; i < foxes.length; i++) { var fox = foxes[i]; var distance = Math.sqrt(Math.pow(fox.x - self.x, 2) + Math.pow(fox.y - self.y, 2)); if (distance < nearestDistance && distance < 300) { nearestDistance = distance; nearestFox = fox; } } self.target = nearestFox; // 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 fox var nearestFox = null; var nearestDistance = Infinity; for (var i = 0; i < foxes.length; i++) { var fox = foxes[i]; var distance = Math.sqrt(Math.pow(fox.x - self.x, 2) + Math.pow(fox.y - self.y, 2)); if (distance < nearestDistance && distance < 300) { nearestDistance = distance; nearestFox = fox; } } self.target = nearestFox; // 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(); // Spawn on top of the egg with random horizontal offset newChicken.x = self.x + (Math.random() - 0.5) * 200; // Random offset between -100 and +100 newChicken.y = self.y - 400; chickens.push(newChicken); game.addChild(newChicken); }; self.spawnBlackChicken = function () { var newBlackChicken = new BlackChicken(); // Spawn on top of the egg with random horizontal offset newBlackChicken.x = self.x + (Math.random() - 0.5) * 200; // Random offset between -100 and +100 newBlackChicken.y = self.y - 400; 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 Fox = Container.expand(function () { var self = Container.call(this); var foxGraphics = self.attachAsset('fox', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 2; self.health = 3; self.maxHealth = 3; self.lastY = 0; self.moveDirection = 'straight'; // Default movement direction self.update = function () { // Move towards the egg if (egg) { var dx = egg.x - self.x; var dy = egg.y - self.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance > 0) { // Normalize direction and apply speed self.x += dx / distance * self.speed * 0.7; // Slightly slower horizontal movement self.y += dy / distance * self.speed; } else { // Fallback to moving down if somehow at same position self.y += self.speed; } } else { // Fallback to moving down if egg doesn't exist self.y += self.speed; } // Health tracking without color changes var healthRatio = self.health / self.maxHealth; }; self.takeDamage = function (damage) { self.health -= damage; LK.effects.flashObject(self, 0xFF0000, 200); if (self.health <= 0) { return true; // Fox is dead } return false; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB }); /**** * Game Code ****/ var egg = null; var foxes = []; var chickens = []; var bullets = []; var foxSpawnTimer = 0; var foxSpawnRate = 120; // 2 seconds at 60fps var waveNumber = 1; var foxesKilled = 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 spawnFox() { var newFox = new Fox(); newFox.x = Math.random() * (2048 - 160) + 80; newFox.y = -50; newFox.speed = 1 + Math.random() * 2 + waveNumber * 0.5; newFox.lastY = newFox.y; // Set diagonal movement based on spawn position var screenCenter = 2048 / 2; if (newFox.x < screenCenter - 300) { // Left side - move diagonally right newFox.moveDirection = 'diagonal-right'; } else if (newFox.x > screenCenter + 300) { // Right side - move diagonally left newFox.moveDirection = 'diagonal-left'; } else { // Center - move straight down newFox.moveDirection = 'straight'; } foxes.push(newFox); game.addChild(newFox); } 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 foxSpawnRate = Math.max(30, 120 - waveNumber * 10); } } game.update = function () { updateDifficulty(); // Spawn foxes foxSpawnTimer++; if (foxSpawnTimer >= foxSpawnRate) { foxSpawnTimer = 0; spawnFox(); } // Update foxes for (var i = foxes.length - 1; i >= 0; i--) { var fox = foxes[i]; // Check if fox reached egg if (fox.lastY < egg.y && fox.y >= egg.y && Math.abs(fox.x - egg.x) < 100) { // Fox 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 fox after attack fox.destroy(); foxes.splice(i, 1); continue; } // Remove foxes that go off screen if (fox.y > 2732 + 100) { fox.destroy(); foxes.splice(i, 1); continue; } fox.lastY = fox.y; } // Update bullets for (var j = bullets.length - 1; j >= 0; j--) { var bullet = bullets[j]; // Check bullet-fox collisions var hit = false; for (var k = foxes.length - 1; k >= 0; k--) { var fox = foxes[k]; if (bullet.intersects(fox)) { // Bullet hits fox - kill immediately with one hit LK.getSound('foxHit').play(); foxesKilled++; LK.setScore(foxesKilled * 10); scoreTxt.setText('Score: ' + LK.getScore()); fox.destroy(); foxes.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
@@ -246,17 +246,23 @@
self.maxHealth = 3;
self.lastY = 0;
self.moveDirection = 'straight'; // Default movement direction
self.update = function () {
- // Move based on direction
- if (self.moveDirection === 'diagonal-right') {
- self.x += self.speed * 0.5; // Move right at half speed
- self.y += self.speed;
- } else if (self.moveDirection === 'diagonal-left') {
- self.x -= self.speed * 0.5; // Move left at half speed
- self.y += self.speed;
+ // Move towards the egg
+ if (egg) {
+ var dx = egg.x - self.x;
+ var dy = egg.y - self.y;
+ var distance = Math.sqrt(dx * dx + dy * dy);
+ if (distance > 0) {
+ // Normalize direction and apply speed
+ self.x += dx / distance * self.speed * 0.7; // Slightly slower horizontal movement
+ self.y += dy / distance * self.speed;
+ } else {
+ // Fallback to moving down if somehow at same position
+ self.y += self.speed;
+ }
} else {
- // Default straight down movement
+ // Fallback to moving down if egg doesn't exist
self.y += self.speed;
}
// Health tracking without color changes
var healthRatio = self.health / self.maxHealth;