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
User prompt
we probably need the human and zomb variable to know what level we are on so we can spawn the correct zombies no? because here at level 5 we get our upgraded humans and zombies, however after that batch they go back to the default zombies and humans. not sure why
Code edit (1 edits merged)
Please save this source code
User prompt
so it seems our upgradeStatsAtMilestone function updated one batch of zombies at level 5, however i didn't notice humans being different. Also after i got rid of the zombies on that level, level 6 started spawning base zombies again. We need it to be incremental in this fashion. level 1 -4 (base human, base zombie) then 5-9 (upgraded zombie and humans, new color masl), then 10-14 (new upgraded zombie and humans new color mask) and so forth...
User prompt
well no here you are increasing the text but not the actual meat in the backend, my factory should be making dog food if i had actually increased the meat
User prompt
make a separate function that when i click, the "meat" in the factory increases. Make it so we can remove it easily later
User prompt
ok undo that, we're going to do it a different way
User prompt
give me an admin/temporary cheat button we will disable later: when i click it increases mishnu snax inside factory
User prompt
function upgradeStatsAtMilestone: take a look at this function critical for the game progression. Make sure it is implemented correctly, and that our zombies and humans will have their stats and masks implemented without fail every invrement of 5 levels. If you see problems please fix them.
User prompt
Please fix the bug: 'Timeout.tick error: zombieGraphics is not defined' in or related to this line: 'var radius = zombieGraphics.width / 2 + 10;' Line Number: 696
User prompt
The error zombie.zombieGraphics is undefined indicates that the zombieGraphics property was not correctly assigned to the zombie object in the Zombie class. To fix this, you need to ensure zombieGraphics is assigned as a property of the zombie object (self) so that it can be accessed later.
User prompt
Please fix the bug: 'Timeout.tick error: zombie.zombieGraphics is undefined' in or related to this line: 'zombie.zombieGraphics.tint = newZombieColor;' Line Number: 874
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: humanGraphics is not defined' in or related to this line: 'var intensity = Math.min(1, elapsedTime / 3000); // Max intensity at 3 seconds' Line Number: 536
User prompt
The error indicates that humanGraphics is not correctly referenced in your Human class. The issue arises because the humanGraphics variable is declared inside the Human constructor but is being accessed using self.humanGraphics in the update function. To fix this: Assign humanGraphics as a property of self (e.g., self.humanGraphics). Update all references to humanGraphics to use self.humanGraphics.
User prompt
Please fix the bug: 'ReferenceError: humanGraphics is not defined' in or related to this line: 'humanGraphics.tint = 0xFFFFFF; // Reset flashing' Line Number: 592
User prompt
Please fix the bug: 'ReferenceError: humanGraphics is not defined' in or related to this line: 'humanGraphics.tint = 0xFFFFFF; // Reset flashing' Line Number: 592
User prompt
Please fix the bug: 'Timeout.tick error: human.humanGraphics is undefined' in or related to this line: 'human.humanGraphics.tint = newHumanColor;' Line Number: 863
===================================================================
--- 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