User prompt
Please fix the bug: 'ReferenceError: lasers is not defined' in or related to this line: 'lasers.splice(lasers.indexOf(self), 1);' Line Number: 749
User prompt
var Boss is not spawning at level 2 as it should. make boss spawning at level 2 and game loop update for boss is placed in the correct place of our script to make him spawn
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: addBloodSplashes is not defined' in or related to this line: 'addBloodSplashes(true);' Line Number: 790
Code edit (15 edits merged)
Please save this source code
User prompt
we cannot have more than one dog munching sound playing at a time.
Code edit (1 edits merged)
Please save this source code
Code edit (5 edits merged)
Please save this source code
User prompt
Lets go ahead and standardize all human image assets that start with human_ to dimensions 48x146
User prompt
Please fix the bug: 'ReferenceError: greyscaleFilter is not defined' in or related to this line: 'humanGraphics.filters = [greyscaleFilter]; // Reset to greyscale filter' Line Number: 618
User prompt
Please fix the bug: 'ReferenceError: greyscaleFilter is not defined' in or related to this line: 'humanGraphics.filters = [greyscaleFilter]; // Reset to greyscale filter' Line Number: 618
User prompt
Please fix the bug: 'filters is not defined' in or related to this line: 'var greyscaleFilter = new filters.ColorMatrixFilter();' Line Number: 487
Code edit (3 edits merged)
Please save this source code
User prompt
atm the humans are not spawning in greyscale. this is a reminder of how we did it for zombies: zombieGraphics.tint = 0x007e94; // Blue tint for the mask YOu can use grey for a grey mask
User prompt
fix
User prompt
instead of doing this so complicated, do it similarly to how we apply masks on zombies. Apply a grey mask over our humans the same way we color our zombie
User prompt
Please fix the bug: 'filters is not defined' in or related to this line: 'humanGraphics.filters = [new filters.ColorMatrixFilter()];' Line Number: 484
User prompt
humans are not loading in greyscale
User prompt
now to normalize humans even further, make sure they load in greyscale
User prompt
one of the humans appear as purple rectangle why is this
Code edit (2 edits merged)
Please save this source code
User prompt
normalize all the human images (Human_#) asset to dimension 80x220. iterate through all of them
User prompt
We need to redo the appearance for humans. When it loads the Human image assets it can choose randomly between Human_1 all the way to Human_16 (That's right any of the 16 human images at random) so list them out and make them random
Code edit (1 edits merged)
Please save this source code
Code edit (3 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -215,8 +215,81 @@
}, 16);
};
return self;
});
+// Boss Class
+var Boss = Container.expand(function () {
+ var self = Container.call(this);
+ // Boss attributes
+ var bossGraphics = self.attachAsset('Alien', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ zIndex: 2
+ });
+ var radiusGraphics = self.attachAsset('radius', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 10,
+ scaleY: 10,
+ tint: 0x00FF00,
+ // Green tint for radius
+ alpha: 0.3
+ });
+ self.addChild(radiusGraphics);
+ bossGraphics.zIndex = 3; // Ensure Alien is above radius
+ self.addChild(bossGraphics);
+ self.x = 2048 / 2; // Spawn at top-center of the viewport
+ self.y = -100;
+ self.speed = 2; // Boss movement speed
+ self.radiusSize = 300; // Harvest radius size
+ var laserCooldown = 2000; // Time (ms) between laser shots
+ var laserElapsedTime = 0;
+ var lasers = [];
+ // Update boss behavior
+ self.update = function () {
+ // Move towards Mishnu
+ var dx = mishnu.x - self.x;
+ var dy = mishnu.y - self.y;
+ var distance = Math.sqrt(dx * dx + dy * dy);
+ if (distance > 1) {
+ self.x += dx / distance * self.speed;
+ self.y += dy / distance * self.speed;
+ }
+ // Check for humans within radius
+ humans.forEach(function (human) {
+ var humanDx = human.x - self.x;
+ var humanDy = human.y - self.y;
+ var humanDistance = Math.sqrt(humanDx * humanDx + humanDy * humanDy);
+ if (humanDistance < self.radiusSize) {
+ game.removeChild(human);
+ humans.splice(humans.indexOf(human), 1);
+ // Add blood splash effect for harvested humans
+ game.addChild(new BloodSplash(human.x, human.y, true));
+ }
+ });
+ // Handle laser shooting
+ laserElapsedTime += 16; // Assume 16ms per frame
+ if (laserElapsedTime >= laserCooldown) {
+ shootLaser();
+ laserElapsedTime = 0;
+ }
+ // Update lasers
+ lasers.forEach(function (laser) {
+ laser.update();
+ });
+ // Remove off-screen lasers
+ lasers = lasers.filter(function (laser) {
+ return laser.isInViewport();
+ });
+ };
+ // Laser shooting logic
+ function shootLaser() {
+ var laser = new Laser(self.x, self.y, mishnu.x, mishnu.y);
+ lasers.push(laser);
+ game.addChild(laser);
+ }
+ return self;
+});
// Factory Class
var Factory = Container.expand(function () {
var self = Container.call(this);
var factoryGraphics = self.attachAsset('Factory', {
@@ -523,9 +596,9 @@
// Start agony yell after 1 second of harvesting
if (elapsedTime > 1000 && !self.yellStarted && self.yellShouldPlay) {
self.yellStarted = true;
self.currentAgonySound = getRandomSound(['Agony_Yell_1', 'Agony_Yell_2', 'Agony_Yell_3', 'Agony_Yell_4', 'Agony_Yell_5', 'Agony_Yell_6', 'Agony_Yell_7', 'Agony_Yell_8', 'Agony_Yell_9', 'Agony_Yell_10']);
- self.currentAgonySound.volume = 0.3;
+ self.currentAgonySound.volume = 0.05;
self.currentAgonySound.play();
}
if (elapsedTime >= 3000 / mishnu.harvestSpeed) {
// Harvest after 3 seconds
@@ -568,8 +641,51 @@
}
};
return self;
});
+// Laser Class
+var Laser = Container.expand(function (startX, startY, targetX, targetY) {
+ var self = Container.call(this);
+ var laserGraphics = self.attachAsset('Laser', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 0.3,
+ scaleY: 0.3,
+ tint: 0xFF0000 // Red tint for lasers
+ });
+ self.x = startX;
+ self.y = startY;
+ var speed = 10;
+ var dx = targetX - startX;
+ var dy = targetY - startY;
+ var distance = Math.sqrt(dx * dx + dy * dy);
+ var velocityX = dx / distance * speed;
+ var velocityY = dy / distance * speed;
+ // Update laser behavior
+ self.update = function () {
+ self.x += velocityX;
+ self.y += velocityY;
+ // Check collision with Mishnu
+ var mishnuDx = mishnu.x - self.x;
+ var mishnuDy = mishnu.y - self.y;
+ var mishnuDistance = Math.sqrt(mishnuDx * mishnuDx + mishnuDy * mishnuDy);
+ if (mishnuDistance < 50) {
+ game.removeChild(self);
+ lasers.splice(lasers.indexOf(self), 1);
+ globalHealthBar.setHealth(globalHealthBar.currentHealth - 1);
+ }
+ // Remove if out of viewport
+ if (!self.isInViewport()) {
+ game.removeChild(self);
+ }
+ };
+ // Check if laser is within the viewport
+ self.isInViewport = function () {
+ return self.x >= -50 && self.x <= 2048 + 50 && self.y >= -50 && self.y <= 2432 + 50;
+ };
+ return self;
+});
+// Add boss spawning at level 2
// Class for Mishnu
var Mishnu = Container.expand(function () {
var self = Container.call(this);
var mishnuGraphics = self.attachAsset('mishnu', {
@@ -615,12 +731,41 @@
var zombieGraphics = self.attachAsset('Zombie', {
anchorX: 0.5,
anchorY: 0.5
});
- zombieGraphics.tint = 0x007e94; // Blue tint for the mask
+ // Helper function to get a color based on the level
+ function getColorForLevel(level) {
+ var colors = [0xFF0000,
+ // Bright red
+ 0x00FF00,
+ // Bright green
+ 0x0000FF,
+ // Bright blue
+ 0xFFFF00,
+ // Bright yellow
+ 0xFF00FF,
+ // Bright magenta
+ 0x00FFFF,
+ // Bright cyan
+ 0xFFA500,
+ // Bright orange
+ 0x800080,
+ // Bright purple
+ 0xFFFFFF,
+ // Bright white
+ 0xFFC0CB // Bright pink
+ ];
+ return colors[level % colors.length]; // Cycle through colors
+ }
+ // Set zombie attributes dynamically based on factory level
+ function initializeZombie(level) {
+ zombieGraphics.tint = getColorForLevel(level); // Set vivid color
+ self.harvestTime = 4000 + level * 500; // Increase harvest time with level
+ }
+ // Call the initializer with the current factory level
+ initializeZombie(factory.level);
// Attributes
self.speed = 2;
- self.harvestTime = 4000; // Time (ms) in radius to get harvested
self.attackCooldown = 3000; // Cooldown (ms) between attacks
self.lastAttackTime = 0; // Tracks the last attack time
self.state = 'roaming'; // Initial state
self.targetX = Math.random() * 2048; // Random initial roaming target
@@ -647,14 +792,12 @@
}
}
// Add sparkles
function emitStars() {
- // Emit a single sparkle per call
var sparkle = self.attachAsset('Stars', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: Math.random() * 0.3 + 0.1,
- // Keep sparkles relatively small
scaleY: Math.random() * 0.3 + 0.1,
alpha: 1,
tint: 0xFFFFFF // Bright white sparkles
});
@@ -676,16 +819,16 @@
self.removeChild(sparkle); // Remove sparkle after its lifetime
}
}, 16);
}
- // Adjust the interval for emitting sparkles to avoid buildup
- LK.setInterval(emitStars, 200); // Emit sparkles less frequently
+ // Emit sparkles periodically
+ LK.setInterval(emitStars, 200);
// Add blood splashes
function addBloodSplashes() {
var isFinal = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
var count = isFinal ? 10 : 1;
for (var i = 0; i < count; i++) {
- var bloodSplash = game.addChild(new BloodSplash(self.x, self.y, isFinal));
+ game.addChild(new BloodSplash(self.x, self.y, isFinal));
}
}
// Update behavior
self.update = function () {
@@ -693,99 +836,64 @@
var dy = mishnu.y - self.y;
var distanceToMishnu = Math.sqrt(dx * dx + dy * dy);
switch (self.state) {
case 'roaming':
- // Wandering logic
moveToTarget(self.targetX, self.targetY);
- // Enter Mishnu's radius
if (distanceToMishnu < radius.radiusSize) {
self.state = 'attacking';
self.inRadiusStartTime = Date.now();
- // Play agony sound (1-in-3 chance)
if (Math.random() < 1 / 2) {
agonySound = getRandomSound(['GiggleMan_1', 'GiggleMan_2', 'GiggleMan_3', 'GiggleMan_4']);
agonySound.volume = 0.3;
agonySound.play();
}
}
break;
case 'attacking':
- // Attack logic
moveToTarget(mishnu.x, mishnu.y, 1.5);
if (distanceToMishnu < radius.radiusSize) {
var elapsedTime = Date.now() - self.inRadiusStartTime;
- // Harvest if in radius for the required time
if (elapsedTime >= self.harvestTime / mishnu.harvestSpeed) {
self.state = 'harvested';
game.removeChild(self);
zombies.splice(zombies.indexOf(self), 1);
mishnu.humansHarvested += 2;
- // Play harvest sounds
if (!harvestSoundPlayed) {
LK.getSound('Ding_1').play();
getRandomSound(['Squish_1', 'Squish_2', 'Squish_3', 'Squish_4']).play();
harvestSoundPlayed = true;
}
addBloodSplashes(true);
return;
}
- // Attack Mishnu if close
if (distanceToMishnu < 50 && Date.now() - self.lastAttackTime > self.attackCooldown) {
globalHealthBar.setHealth(globalHealthBar.currentHealth - 1);
self.lastAttackTime = Date.now();
self.state = 'fleeing';
- // Set flee target
var fleeAngle = Math.random() * Math.PI * 2;
self.targetX = mishnu.x + Math.cos(fleeAngle) * (radius.radiusSize + 50);
self.targetY = mishnu.y + Math.sin(fleeAngle) * (radius.radiusSize + 50);
addBloodSplashes();
- // Flash grey mask on Mishnu, radius, and health bar
flashGreyMask([mishnu, radius, globalHealthBar], 400, 3);
- LK.getSound('Hit').play(); // Play "Hit" sound
+ LK.getSound('Hit').play();
LK.setTimeout(function () {
- // Play a random bark sound with a delay
var barks = ['Bark', 'Bark_1', 'Bark_2'];
- var randomBark = barks[Math.floor(Math.random() * barks.length)];
- LK.getSound(randomBark).play();
- }, 200); // Delay of 0.2 seconds
+ LK.getSound(barks[Math.floor(Math.random() * barks.length)]).play();
+ }, 200);
}
} else {
- // Outside radius, return to roaming
self.state = 'roaming';
setRandomTarget();
}
break;
case 'fleeing':
- // Flee logic
moveToTarget(self.targetX, self.targetY, 2);
if (distanceToMishnu > radius.radiusSize + 50) {
- // Successfully fled, return to roaming
self.state = 'roaming';
setRandomTarget();
- } else if (distanceToMishnu < radius.radiusSize) {
- // If Mishnu keeps the zombie in the radius, reset harvest timer
- if (!self.inRadiusStartTime) {
- self.inRadiusStartTime = Date.now();
- }
- var elapsedTime = Date.now() - self.inRadiusStartTime;
- if (elapsedTime >= self.harvestTime) {
- self.state = 'harvested';
- game.removeChild(self);
- zombies.splice(zombies.indexOf(self), 1);
- mishnu.humansHarvested += 2;
- // Play harvest sounds
- if (!harvestSoundPlayed) {
- LK.getSound('Ding_1').play();
- getRandomSound(['Squish_1', 'Squish_2', 'Squish_3', 'Squish_4']).play();
- harvestSoundPlayed = true;
- }
- addBloodSplashes(true);
- return;
- }
}
break;
case 'harvested':
- // Zombie is removed after harvesting
break;
default:
console.error("Zombie in unknown state: ".concat(self.state));
self.state = 'roaming';
@@ -809,13 +917,28 @@
/****
* Game Code
****/
-// Modify game logic to include zombie spawning
-// Declare healthBar globally for accessibility
+// Add boss spawning at level 2
+// Define ColorMatrixFilter to fix 'filters is not defined' error
// Booster spawning logic
// Booster spawning logic
-// Define ColorMatrixFilter to fix 'filters is not defined' error
+// Declare healthBar globally for accessibility
+// Modify game logic to include zombie spawning
+var bossSpawned = false;
+function checkForBossSpawn() {
+ if (factory.level === 2 && !bossSpawned) {
+ var boss = new Boss();
+ game.addChild(boss);
+ bossSpawned = true;
+ }
+}
+// Update game loop to include boss logic
+var originalGameUpdate = game.update;
+game.update = function () {
+ originalGameUpdate.call(this);
+ checkForBossSpawn();
+};
var boosters = [];
function spawnBooster() {
var booster = new Booster();
boosters.push(booster);
@@ -1087,8 +1210,9 @@
boosters.forEach(function (booster) {
booster.update();
});
checkBoosterPickup();
+ checkForBossSpawn();
// Calculate dynamic minimum and maximum humans on screen
var minHumansOnScreen = Math.max((factory.nextLevelRequirement - factory.dogFood) * 7, 20); // Ensure a minimum of 20
var maxHumansOnScreen = Math.ceil(minHumansOnScreen * 1.5); // Scale max to 150% of min
// Ensure minimum number of humans on screen
blurry texture background 4k black and white
can of Dog Food. Game asset. 3d clipart. Blank background. High contrast. No shadows..
black capsule. Game asset. 3d clipart. Blank background. High contrast. No shadows..
woman in short shorts. mobile game art. pixel art. full body. front facing. Blank background. High contrast. No shadows.
laser beam cartoon game asset. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
bone. clipart. cartoon. Blank background. High contrast. No shadows..
Game Over. Red game letters, dripping. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Dog_panting
Sound effect
Agony_Yell_1
Sound effect
Music_Level_1_5
Music
Music_Level_1_4
Music
Agony_Yell_2
Sound effect
Agony_Yell_3
Sound effect
Agony_Yell_4
Sound effect
Agony_Yell_5
Sound effect
Agony_Yell_6
Sound effect
Agony_Yell_7
Sound effect
Dog_Crunch
Sound effect
Dog_Crunch_2
Sound effect
Dog_Crunch_3
Sound effect
Ding_1
Sound effect
Squish_1
Sound effect
Squish_2
Sound effect
Squish_4
Sound effect
Squish_3
Sound effect
Factory_Deposit
Sound effect
Factory_Operation
Sound effect
Level_Up
Sound effect
Bark
Sound effect
Hit
Sound effect
Agony_Yell_8
Sound effect
Agony_Yell_9
Sound effect
GiggleMan_1
Sound effect
GiggleMan_2
Sound effect
GiggleMan_3
Sound effect
GiggleMan_4
Sound effect
Booster_Sound
Sound effect
Can
Sound effect
woosh
Sound effect
Agony_Yell_10
Sound effect
Bark_2
Sound effect
Bark_3
Sound effect
laser
Sound effect
searing
Sound effect
laser_2
Sound effect
Laser_3
Sound effect
Laser_4
Sound effect
Boss_Hit
Sound effect
Boss_Hit_2
Sound effect
Boss_Hit_3
Sound effect
GiggleMan_5
Sound effect
GiggleMan_6
Sound effect
hip_hop_loop
Sound effect