Code edit (6 edits merged)
Please save this source code
User prompt
Replace text for Dog Food: It should say Mishnu Snax:
Code edit (1 edits merged)
Please save this source code
User prompt
when zombie is down fleeing, he goes back to the same state then when he spawned. use a drastic measure to enforce this. because we keep going in circles and the zombie seems to just freeze after fleeing. Everytime.
User prompt
he needs to just walk around after fleeing, the same state he was in when he spawned in
User prompt
still frozen
User prompt
still frozen....
User prompt
make it so that after fleeing the zombie returns to idle and roams around. as he should. he cannot be frozen in any way after fleeing and exiting the radius. he just resets to his default state. no matter what if he exits the radius he's reset. not frozen in place after fleeing. i dont know hwy this is happening
User prompt
i need you to read the console logs for insights into why the zombie might freeze. Let me know the output if further refinement is needed! we added debugging however i cannot read the logs
Code edit (8 edits merged)
Please save this source code
User prompt
can you help fix this issue?
Code edit (1 edits merged)
Please save this source code
Code edit (3 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: r is undefined' in or related to this line: 'if (bloodGraphics.alpha >= 1) {' Line Number: 61
User prompt
Please fix the bug: 'TypeError: r is undefined' in or related to this line: 'if (self.currentAgonySound) {' Line Number: 585
User prompt
sparkle.blendMode = PIXI.BLEND_MODES.ADD;
User prompt
Please fix the bug: 'Timeout.tick error: BLEND_MODES is not defined' in or related to this line: 'sparkle.blendMode = BLEND_MODES.ADD;' Line Number: 461
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: r is undefined' in or related to this line: 'glow.y = self.y;' Line Number: 493
User prompt
Please fix the bug: 'TypeError: r is undefined' in or related to this line: 'if (bloodGraphics.alpha >= 1) {' Line Number: 62
User prompt
if (LK.getAsset('Glow'))) to ensure the Glow asset exists before attempting to attach or reference it.
Code edit (4 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: r is undefined' in or related to this line: 'glow.y = self.y;' Line Number: 489
User prompt
Please fix the bug: 'TypeError: r is undefined' in or related to this line: 'glow.y = self.y;' Line Number: 488
Code edit (3 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -394,112 +394,183 @@
var zombieGraphics = self.attachAsset('Zombie', {
anchorX: 0.5,
anchorY: 0.5
});
- // Apply blue tint directly to the zombie
zombieGraphics.tint = 0x18dfe2; // Blue tint for the mask
- // Improved sparkle emission logic for directional effect
- self.emitStars = function () {
+ // 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,
- // Smaller sparkles
scaleY: Math.random() * 0.3 + 0.1,
alpha: 1,
tint: 0xFFFFFF // White sparkles
});
- // Position sparkles randomly around the zombie on the outer edge
+ // Position sparkles randomly around the zombie
var angle = Math.random() * Math.PI * 2;
- var radius = zombieGraphics.width / 2 + 10; // Ensure sparkles are outside the zombie
+ var radius = zombieGraphics.width / 2 + 10;
sparkle.x = Math.cos(angle) * radius;
sparkle.y = Math.sin(angle) * radius;
- var velocityY = -(Math.random() * 1 + 0.5); // Subtle upward motion
- var lifetime = Math.random() * 400 + 200; // Shorter lifetime for subtle effect
+ var lifetime = Math.random() * 400 + 200;
var elapsed = 0;
var interval = LK.setInterval(function () {
elapsed += 16; // Assume 16ms per frame
- sparkle.y += velocityY;
+ 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);
- };
- // Emit stars at a regular interval
- LK.setInterval(self.emitStars, 300); // Emit stars every 300ms
- // Variables
- self.harvestTime = 3000; // 3 seconds to harvest
- self.meatYield = 2; // Zombies provide 2 meat
- self.attackCooldown = 3000; // 3-second cooldown for attacks
- self.lastAttackTime = 0; // Tracks the last attack time
- self.speed = 2; // Movement speed for zombies
- self.inRadiusStartTime = null; // Tracks time inside radius
- self.isFleeing = false; // Tracks if the zombie is fleeing
- self.isChasing = false; // Tracks if the zombie is chasing Mishnu
- self.currentAgonySound = null;
- self.targetX = Math.random() * 2048; // Random initial roaming target
- self.targetY = Math.random() * 2432; // Random initial roaming target
- // Update method
+ }
+ // 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);
- // Handle fleeing logic
- if (self.isFleeing) {
- var targetDx = self.targetX - self.x;
- var targetDy = self.targetY - self.y;
- var targetDistance = Math.sqrt(targetDx * targetDx + targetDy * targetDy);
- if (targetDistance > 0) {
- self.x += targetDx / targetDistance * self.speed * 2;
- self.y += targetDy / targetDistance * self.speed * 2;
- }
- // Stop fleeing when far enough away
- if (targetDistance > radius.radiusSize * 1.5) {
- self.isFleeing = false;
- self.isChasing = false;
- self.targetX = Math.random() * 2048;
- self.targetY = Math.random() * 2432;
- }
- return;
+ 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 / 3) {
+ agonySound = getRandomSound(['Agony_Yell_1', 'Agony_Yell_2', 'Agony_Yell_3']);
+ 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) {
+ 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();
+ LK.getSound('Zombie_Attack').play(); // Play attack sound
+ }
+ } 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;
}
- // Handle chasing logic
- if (distance < radius.radiusSize && !self.isFleeing) {
- if (distance < 50 && Date.now() - self.lastAttackTime > self.attackCooldown) {
- // Attack Mishnu
- globalHealthBar.setHealth(globalHealthBar.currentHealth - 1);
- self.lastAttackTime = Date.now();
- // Trigger fleeing behavior after attack
- self.isFleeing = true;
- self.targetX = self.x + Math.cos(Math.random() * Math.PI * 2) * 500;
- self.targetY = self.y + Math.sin(Math.random() * Math.PI * 2) * 500;
- return;
- }
- // Chasing Mishnu
- self.x += dx / distance * self.speed * 1.5;
- self.y += dy / distance * self.speed * 1.5;
- } else {
- // Idle roaming behavior
- var roamDx = self.targetX - self.x;
- var roamDy = self.targetY - self.y;
- var roamDistance = Math.sqrt(roamDx * roamDx + roamDy * roamDy);
- if (roamDistance < 10) {
- self.targetX = Math.random() * 2048;
- self.targetY = Math.random() * 2432;
- } else {
- self.x += roamDx / roamDistance * self.speed;
- self.y += roamDy / roamDistance * self.speed;
- }
- }
};
+ // Set initial target
+ setRandomTarget();
return self;
});
/****
* Initialize Game
****/
// Modify game logic to include zombie spawning
+// Declare healthBar globally for accessibility
var game = new LK.Game({
backgroundColor: 0x000000
});
@@ -569,9 +640,9 @@
'Music_Level_1_5': false
};
// Update factory text
function updateFactoryText() {
- factoryText.setText("Level: " + factory.level + "\nMeat: " + factory.meat + "\nDog Food: " + factory.dogFood + "\nNext level at: " + factory.nextLevelRequirement);
+ factoryText.setText("Level: " + factory.level + "\nMeat: " + factory.meat + "\nMishnu Snax: " + factory.dogFood + "\nNext level at: " + factory.nextLevelRequirement);
}
// Function to randomly select a sound from a list
;
// Add a UI layer to ensure factory is rendered above the background and mask
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