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
User prompt
it's still not working. please remove the admin tools for now
User prompt
it's still not working. make sure the admin tool is crafted properly so it works. make sure its in the correct section. it should proabbly be in var factory
User prompt
our admin tool doesn't work, when i click mishnu snacks don't increase. lets remove what we just did and instead make an admin tool to increase meat by 10 when clicking. meat on the backend, not the display text
User prompt
add an easy to remove function that increase "dog food" (the backend in our factory) as I click as an admin tool. Label thos lines //admin tool so they can be removed easily later
Code edit (1 edits merged)
Please save this source code
User prompt
please fix this
User prompt
Please fix the bug: 'Timeout.tick error: UpgradedZombie is not defined' in or related to this line: 'newZombie = new UpgradedZombie(); // Upgraded zombie for higher levels' Line Number: 955
===================================================================
--- original.js
+++ change.js
@@ -401,82 +401,144 @@
};
return self;
});
// Class for Humans
-// Updated Human class with sounds, graphics, and leveling
var Human = Container.expand(function () {
var self = Container.call(this);
- var levelGroup = Math.floor(factory.level / 5);
- // Colors based on level
- var humanColors = [0xFFE4E1, 0xFFFACD, 0xE0FFFF, 0xF0E68C, 0xFFDAB9];
- var humanColor = humanColors[levelGroup % humanColors.length];
var humanGraphics = self.attachAsset('human', {
anchorX: 0.5,
- anchorY: 0.5,
- tint: humanColor
+ anchorY: 0.5
});
- // Stats based on level
- self.speedX = (Math.random() * 2 - 1) * (2 * Math.pow(1.15, levelGroup));
- self.speedY = (Math.random() * 2 - 1) * (2 * Math.pow(1.15, levelGroup));
- self.harvestTime = 3000 * Math.pow(2, levelGroup); // Harvest time doubles every 5 levels
+ var bloodSplashes = [];
+ self.speedX = (Math.random() * 2 - 1) * 2;
+ self.speedY = (Math.random() * 2 - 1) * 2;
self.isBeingHarvested = false;
self.inRadiusStartTime = null;
- self.flashTimer = 0;
- self.flashInterval = 500;
- var bloodSplashes = [];
+ self.currentAgonySound = null;
+ self.currentCrunchSound = null;
+ self.yellStarted = false; // Tracks if the yell has started
+ self.yellShouldPlay = Math.random() < 1 / 3; // 1-in-3 chance for yelling
+ self.crunchShouldPlay = Math.random() < 1 / 6; // 1-in-3 chance for crunch sound
+ self.flashTimer = 0; // Timer for red flashing
+ self.flashInterval = 500; // Initial interval for flashing
self.update = function () {
+ // Escape logic
self.x += self.speedX;
self.y += self.speedY;
- // Keep humans within viewport margins
+ // Keep humans within the viewport margins
var margin = 50;
- if (self.x <= margin || self.x >= 2048 - margin) {
+ var bottomMargin = 300; // Extra margin for bottom text box
+ if (self.x <= margin) {
+ self.x = margin;
self.speedX *= -1;
+ } else if (self.x >= 2048 - margin) {
+ self.x = 2048 - margin;
+ self.speedX *= -1;
}
- if (self.y <= margin || self.y >= 2432 - margin) {
+ if (self.y <= margin) {
+ self.y = margin;
self.speedY *= -1;
+ } else if (self.y >= 2432 - margin) {
+ // Ensure humans respect new boundary height
+ self.y = 2432 - margin;
+ self.speedY *= -1;
}
// Check distance to Mishnu
var dx = self.x - mishnu.x;
var dy = self.y - mishnu.y;
var distance = Math.sqrt(dx * dx + dy * dy);
- if (distance < radius.radiusSize) {
+ if (mishnu.humansHarvested >= mishnu.cargoMax * 1.5) {
+ // Stop all sounds when cargo exceeds 150% capacity
+ if (self.currentAgonySound !== null) {
+ fadeOutSound(self.currentAgonySound, 500);
+ }
+ if (self.currentCrunchSound) {
+ self.currentCrunchSound.stop();
+ }
+ self.isBeingHarvested = false;
+ humanGraphics.tint = 0xFFFFFF; // Reset flashing
+ return;
+ }
+ if (distance < radius.radiusSize - 2) {
if (!self.isBeingHarvested) {
self.isBeingHarvested = true;
self.inRadiusStartTime = Date.now();
self.flashTimer = 0;
bloodSplashes = [];
+ self.yellStarted = false;
// Play crunch sound if applicable
- if (Math.random() < 0.5) {
- var crunchSound = getRandomSound(['Dog_Crunch', 'Dog_Crunch_2', 'Dog_Crunch_3']);
- crunchSound.volume = 0.3;
- crunchSound.play();
+ if (self.crunchShouldPlay) {
+ self.currentCrunchSound = getRandomSound(['Dog_Crunch', 'Dog_Crunch_2', 'Dog_Crunch_3']);
+ self.currentCrunchSound.volume = 0.3;
+ self.currentCrunchSound.play();
}
} else {
+ // Calculate vibration intensity based on time in the radius
var elapsedTime = Date.now() - self.inRadiusStartTime;
- if (elapsedTime >= self.harvestTime / mishnu.harvestSpeed) {
- game.removeChild(self);
- humans.splice(humans.indexOf(self), 1);
- mishnu.humansHarvested++;
- // Final blood splashes
- for (var i = 0; i < 10; i++) {
- var bloodSplash = game.addChild(new BloodSplash(self.x, self.y, true));
- bloodSplashes.push(bloodSplash);
+ var intensity = Math.min(1, elapsedTime / 3000); // Max intensity at 3 seconds
+ // Add vibration effect
+ humanGraphics.x = Math.random() * intensity * 10 - intensity * 5;
+ humanGraphics.y = Math.random() * intensity * 10 - intensity * 5;
+ // Escape logic during vibration
+ var runSpeed = 2; // Speed humans try to escape the radius
+ self.x += dx / distance * runSpeed;
+ self.y += dy / distance * runSpeed;
+ // Flash red effect
+ self.flashTimer += 16; // Assume a fixed delta of 16ms per frame
+ if (self.flashTimer >= self.flashInterval) {
+ self.flashTimer = 0;
+ humanGraphics.tint = humanGraphics.tint === 0xFFFFFF ? 0xFF0000 : 0xFFFFFF;
+ // Emit blood splash
+ var bloodSplash = game.addChild(new BloodSplash(self.x, self.y));
+ bloodSplashes.push(bloodSplash);
+ }
+ // Increase flash frequency closer to harvest
+ self.flashInterval = Math.max(100, 500 - elapsedTime / 3000 * 400);
+ // 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']);
+ self.currentAgonySound.volume = 0.3;
+ self.currentAgonySound.play();
+ }
+ if (elapsedTime >= 3000 / mishnu.harvestSpeed) {
+ // Harvest after 3 seconds
+ if (mishnu.humansHarvested < mishnu.cargoMax * 1.5) {
+ game.removeChild(self); // Remove human from the game
+ humans.splice(humans.indexOf(self), 1); // Remove from array
+ mishnu.humansHarvested++;
+ // Stop yelling abruptly
+ if (self.currentAgonySound) {
+ self.currentAgonySound.stop();
+ }
+ // Play ding and squish sounds on harvest
+ LK.getSound('Ding_1').play();
+ getRandomSound(['Squish_1', 'Squish_2', 'Squish_3', 'Squish_4']).play();
+ // Final blood splashes
+ for (var i = 0; i < 10; i++) {
+ var bloodSplash = game.addChild(new BloodSplash(self.x, self.y, true));
+ bloodSplashes.push(bloodSplash);
+ }
}
- } else {
- // Flash red effect
- self.flashTimer += 16;
- if (self.flashTimer >= self.flashInterval) {
- self.flashTimer = 0;
- humanGraphics.tint = humanGraphics.tint === humanColor ? 0xFF0000 : humanColor;
- var bloodSplash = game.addChild(new BloodSplash(self.x, self.y));
- bloodSplashes.push(bloodSplash);
- }
}
}
} else {
+ // Reset harvesting state if outside the radius
+ if (self.isBeingHarvested) {
+ if (self.currentAgonySound && self.yellStarted) {
+ self.currentAgonySound.loop = false;
+ }
+ if (self.currentCrunchSound) {
+ self.currentCrunchSound.stop();
+ }
+ }
self.isBeingHarvested = false;
self.inRadiusStartTime = null;
- humanGraphics.tint = humanColor; // Reset color
+ self.flashTimer = 0;
+ humanGraphics.tint = 0xFFFFFF; // Reset flashing
+ bloodSplashes.forEach(function (splash) {
+ game.removeChild(splash);
+ });
}
};
return self;
});
@@ -519,63 +581,187 @@
globalHealthBar.y = 2560; // Position at the top center
uiLayer.addChild(globalHealthBar); // Add to the UI layer to ensure visibility
return self;
});
-// Updated Zombie class with sounds, graphics, and leveling
var Zombie = Container.expand(function () {
var self = Container.call(this);
- var levelGroup = Math.floor(factory.level / 5);
- // Colors based on level
- var zombieColors = [0x30a330, 0xd93838, 0x2f53b4, 0xe9d735, 0xb733b7];
- var zombieColor = zombieColors[levelGroup % zombieColors.length];
+ // Add the zombie graphics
var zombieGraphics = self.attachAsset('Zombie', {
anchorX: 0.5,
- anchorY: 0.5,
- tint: zombieColor
+ anchorY: 0.5
});
- // Stats based on level
- self.speed = 2 * Math.pow(1.15, levelGroup); // Speed increases 15% every 5 levels
- self.harvestTime = 4000 * Math.pow(2, levelGroup); // Harvest time doubles every 5 levels
- self.state = 'roaming';
- self.inRadiusStartTime = null;
- self.lastAttackTime = 0;
- var attackCooldown = 3000; // Cooldown between attacks
+ zombieGraphics.tint = 0x007e94; // Blue tint for the mask
+ // 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
+ self.targetY = Math.random() * 2432;
+ self.inRadiusStartTime = null; // Time zombie entered Mishnu's radius
+ var agonySound = null;
+ var harvestSoundPlayed = false;
+ // Helper function: Generate a random roaming target
+ function setRandomTarget() {
+ self.targetX = Math.random() * 2048;
+ self.targetY = Math.random() * 2432;
+ }
+ // Helper function: Move to a target
+ function moveToTarget(targetX, targetY) {
+ var speedMultiplier = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
+ var dx = targetX - self.x;
+ var dy = targetY - self.y;
+ var distance = Math.sqrt(dx * dx + dy * dy);
+ if (distance > 1) {
+ self.x += dx / distance * self.speed * speedMultiplier;
+ self.y += dy / distance * self.speed * speedMultiplier;
+ } else {
+ setRandomTarget();
+ }
+ }
+ // Add sparkles
+ function emitStars() {
+ var sparkle = self.attachAsset('Stars', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: Math.random() * 0.3 + 0.1,
+ scaleY: Math.random() * 0.3 + 0.1,
+ alpha: 1,
+ tint: 0xFFFFFF // White sparkles
+ });
+ // Position sparkles randomly around the zombie
+ var angle = Math.random() * Math.PI * 2;
+ var radius = zombieGraphics.width / 2 + 10;
+ sparkle.x = Math.cos(angle) * radius;
+ sparkle.y = Math.sin(angle) * radius;
+ var lifetime = Math.random() * 400 + 200;
+ var elapsed = 0;
+ var interval = LK.setInterval(function () {
+ elapsed += 16; // Assume 16ms per frame
+ sparkle.y -= 0.5; // Subtle upward motion
+ sparkle.alpha = Math.max(0, 1 - elapsed / lifetime); // Gradual fade-out
+ if (elapsed >= lifetime) {
+ LK.clearInterval(interval);
+ self.removeChild(sparkle);
+ }
+ }, 16);
+ }
+ // Periodically emit sparkles
+ LK.setInterval(emitStars, 300);
+ // 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));
+ }
+ }
+ // Update behavior
self.update = function () {
var dx = mishnu.x - self.x;
var dy = mishnu.y - self.y;
- var distance = Math.sqrt(dx * dx + dy * dy);
- if (self.state === 'roaming') {
- self.x += (Math.random() * 2 - 1) * self.speed;
- self.y += (Math.random() * 2 - 1) * self.speed;
- if (distance < radius.radiusSize) {
- self.state = 'attacking';
- self.inRadiusStartTime = Date.now();
- // Play giggle sound if applicable
- if (Math.random() < 0.5) {
- var giggleSound = getRandomSound(['GiggleMan_1', 'GiggleMan_2', 'GiggleMan_3', 'GiggleMan_4']);
- giggleSound.volume = 0.3;
- giggleSound.play();
+ 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();
+ }
}
- }
- } else if (self.state === 'attacking') {
- self.x += dx / distance * self.speed;
- self.y += dy / distance * self.speed;
- if (distance < radius.radiusSize / 2 && Date.now() - self.lastAttackTime > attackCooldown) {
- globalHealthBar.setHealth(globalHealthBar.currentHealth - 1);
- self.lastAttackTime = Date.now();
- self.state = 'fleeing';
- // Flash grey mask on Mishnu, radius, and health bar
- flashGreyMask([mishnu, radius, globalHealthBar], 400, 3);
- LK.getSound('Hit').play(); // Play hit sound
- }
- } else if (self.state === 'fleeing') {
- self.x -= dx / distance * self.speed;
- self.y -= dy / distance * self.speed;
- if (distance > radius.radiusSize + 50) {
+ 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.setTimeout(function () {
+ LK.getSound('Bark').play(); // Play "Bark" sound
+ }, 200); // Delay of 0.2 seconds
+ }
+ } 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';
- }
+ setRandomTarget();
+ break;
}
};
+ // Set initial target
+ setRandomTarget();
return self;
});
/****
@@ -589,8 +775,9 @@
/****
* Game Code
****/
+// Modify game logic to include zombie spawning
// Declare healthBar globally for accessibility
// Booster spawning logic
// Booster spawning logic
var boosters = [];
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