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
@@ -51,16 +51,15 @@
// Adjusted yellow
effect: 'increaseMovementSpeed',
text: '+10% Movement Speed',
rarity: 0.15 // Neutral rarity
- },
- //color: 0xb733b7,
- // Adjusted purple
- //effect: 'increaseProductionSpeed',
- //text: '+10% Production Speed',
- //rarity: 0.15 // Neutral rarity
- //},
- {
+ }, {
+ color: 0xb733b7,
+ // Adjusted purple
+ effect: 'increaseProductionSpeed',
+ text: '+10% Production Speed',
+ rarity: 0.15 // Neutral rarity
+ }, {
color: 0x676767,
// Adjusted grey
effect: 'fillCargo',
text: 'Cargo Filled!',
@@ -326,10 +325,8 @@
// Trigger level-up animation
triggerLevelTextShake();
updateFactoryText();
spawnZombies(1, maxZombiesOnScreen); // Spawn a zombie when leveling up
- // Trigger upgrades every 5 levels
- upgradeStatsAtMilestone();
}
}
});
// GlobalHealthBar Class
@@ -404,150 +401,82 @@
};
return self;
});
// Class for Humans
+// Updated Human class with sounds, graphics, and leveling
var Human = Container.expand(function () {
var self = Container.call(this);
- self.humanGraphics = self.attachAsset('human', {
+ 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
+ anchorY: 0.5,
+ tint: humanColor
});
- self.humanGraphics = self.attachAsset('human', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- var bloodSplashes = [];
- self.speedX = (Math.random() * 2 - 1) * 2;
- self.speedY = (Math.random() * 2 - 1) * 2;
+ // 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
self.isBeingHarvested = false;
self.inRadiusStartTime = null;
- 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.flashTimer = 0;
+ self.flashInterval = 500;
+ var bloodSplashes = [];
self.update = function () {
- // Escape logic
self.x += self.speedX;
self.y += self.speedY;
- // Keep humans within the viewport margins
+ // Keep humans within viewport margins
var margin = 50;
- var bottomMargin = 300; // Extra margin for bottom text box
- if (self.x <= margin) {
- self.x = margin;
+ if (self.x <= margin || self.x >= 2048 - margin) {
self.speedX *= -1;
- } else if (self.x >= 2048 - margin) {
- self.x = 2048 - margin;
- self.speedX *= -1;
}
- if (self.y <= margin) {
- self.y = margin;
+ if (self.y <= margin || self.y >= 2432 - 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 (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;
- self.humanGraphics.tint = 0xFFFFFF; // Reset flashing
- return;
- }
- if (distance < radius.radiusSize - 2) {
+ if (distance < radius.radiusSize) {
if (!self.isBeingHarvested) {
self.isBeingHarvested = true;
self.inRadiusStartTime = Date.now();
self.flashTimer = 0;
bloodSplashes = [];
- self.yellStarted = false;
// Play crunch sound if applicable
- if (self.crunchShouldPlay) {
- self.currentCrunchSound = getRandomSound(['Dog_Crunch', 'Dog_Crunch_2', 'Dog_Crunch_3']);
- self.currentCrunchSound.volume = 0.3;
- self.currentCrunchSound.play();
+ if (Math.random() < 0.5) {
+ var crunchSound = getRandomSound(['Dog_Crunch', 'Dog_Crunch_2', 'Dog_Crunch_3']);
+ crunchSound.volume = 0.3;
+ crunchSound.play();
}
} else {
- // Calculate vibration intensity based on time in the radius
var elapsedTime = Date.now() - self.inRadiusStartTime;
- var intensity = Math.min(1, elapsedTime / 3000); // Max intensity at 3 seconds
- self.humanGraphics.x = Math.random() * intensity * 10 - intensity * 5;
- self.humanGraphics.y = Math.random() * intensity * 10 - intensity * 5;
- // Add vibration effect
- self.humanGraphics.x = Math.random() * intensity * 10 - intensity * 5;
- self.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;
- self.humanGraphics.tint = self.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);
- }
+ 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);
}
+ } 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;
- self.flashTimer = 0;
- self.humanGraphics.tint = 0xFFFFFF; // Reset flashing
- bloodSplashes.forEach(function (splash) {
- game.removeChild(splash);
- });
+ humanGraphics.tint = humanColor; // Reset color
}
};
return self;
});
@@ -590,187 +519,63 @@
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);
- // Add the zombie graphics
- self.zombieGraphics = self.attachAsset('Zombie', {
+ var levelGroup = Math.floor(factory.level / 5);
+ // Colors based on level
+ var zombieColors = [0x30a330, 0xd93838, 0x2f53b4, 0xe9d735, 0xb733b7];
+ var zombieColor = zombieColors[levelGroup % zombieColors.length];
+ var zombieGraphics = self.attachAsset('Zombie', {
anchorX: 0.5,
- anchorY: 0.5
+ anchorY: 0.5,
+ tint: zombieColor
});
- self.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 = self.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
+ // 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
self.update = function () {
var dx = mishnu.x - self.x;
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();
- }
+ 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();
}
- 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));
+ }
+ } 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) {
self.state = 'roaming';
- setRandomTarget();
- break;
+ }
}
};
- // Set initial target
- setRandomTarget();
return self;
});
/****
@@ -784,350 +589,337 @@
/****
* Game Code
****/
-// Temporary function to increase meat in the factory
-function increaseMeatOnClick() {
- factory.meat += 10; // Increase meat by 10 units
- factory.startProcessing(); // Start processing to convert meat to dog food
- updateFactoryText(); // Update the factory text to reflect the change
-}
-// Add event listener for click to trigger the increaseMeatOnClick function
+// Admin tool to increase dog food on click
game.down = function (x, y, obj) {
- increaseMeatOnClick();
- // Booster spawning logic
- var boosters = [];
- function spawnBooster() {
- var booster = new Booster();
- boosters.push(booster);
- game.addChild(booster);
+ // Check if click is within a specific area (e.g., top-left corner)
+ if (x < 100 && y < 100) {
+ factory.dogFood += 10; // Increase dog food by 10
+ updateFactoryText(); // Update the factory text to reflect the change
}
- // Integrate boosters with Mishnu Snax increase
- var uiLayer = new Container();
- uiLayer.zIndex = 10; // Ensure it's above the background and mask
- game.addChild(uiLayer);
- var factory = uiLayer.addChild(new Factory());
- var originalIncreaseDogFood = factory.startProcessing;
- factory.startProcessing = function () {
- originalIncreaseDogFood.call(factory);
- // Reduce booster spawn rate as levels increase
- if (factory.level % Math.max(1, Math.floor(factory.level / 3)) === 0) {
- spawnBooster(); // Spawn boosters less frequently as level increases
- }
- };
- // Mishnu pickup logic
- function checkBoosterPickup() {
- boosters.forEach(function (booster) {
- var dx = booster.x - mishnu.x;
- var dy = booster.y - mishnu.y;
- if (Math.sqrt(dx * dx + dy * dy) < 50) {
- booster.pickUp();
- boosters.splice(boosters.indexOf(booster), 1);
- }
- });
+}; //{admin tool}
+// Declare healthBar globally for accessibility
+// Booster spawning logic
+// Booster spawning logic
+var boosters = [];
+function spawnBooster() {
+ var booster = new Booster();
+ boosters.push(booster);
+ game.addChild(booster);
+}
+// Integrate boosters with Mishnu Snax increase
+var uiLayer = new Container();
+uiLayer.zIndex = 10; // Ensure it's above the background and mask
+game.addChild(uiLayer);
+var factory = uiLayer.addChild(new Factory());
+var originalIncreaseDogFood = factory.startProcessing;
+factory.startProcessing = function () {
+ originalIncreaseDogFood.call(factory);
+ // Reduce booster spawn rate as levels increase
+ if (factory.level % Math.max(1, Math.floor(factory.level / 3)) === 0) {
+ spawnBooster(); // Spawn boosters less frequently as level increases
}
- // Add to game update loop
- var originalGameUpdate = game.update;
- game.update = function () {
- originalGameUpdate.call(this);
- boosters.forEach(function (booster) {
- booster.update();
- });
- checkBoosterPickup();
- };
- var globalHealthBar = new GlobalHealthBar(100, 100);
- function spawnZombies(count, maxZombiesOnScreen) {
- for (var i = 0; i < count; i++) {
- if (zombies.length >= maxZombiesOnScreen) {
- break;
- }
- var spawnEdge = Math.floor(Math.random() * 3); // 0: top, 1: left, 2: right
- var spawnX, spawnY;
- switch (spawnEdge) {
- case 0:
- spawnX = Math.random() * 2048;
- spawnY = -50;
- break;
- case 1:
- spawnX = -50;
- spawnY = Math.random() * (2432 - 300);
- break;
- case 2:
- spawnX = 2048 + 50;
- spawnY = Math.random() * (2432 - 300);
- break;
- }
- var newZombie;
- newZombie = new Zombie(); // Use base zombie class
- if (currentLevelGroup > 0) {
- // Upgrade stats for higher levels
- newZombie.speed *= 1.1 * currentLevelGroup; // Increase speed by 10% per level group
- newZombie.harvestTime = (newZombie.harvestTime || 4000) * Math.pow(2, currentLevelGroup); // Increase harvest time exponentially
- newZombie.zombieGraphics.tint = 0xff0000; // Red tint for upgraded zombies
- }
- newZombie.x = spawnX;
- newZombie.y = spawnY;
- zombies.push(newZombie);
- game.addChild(newZombie);
+};
+// Mishnu pickup logic
+function checkBoosterPickup() {
+ boosters.forEach(function (booster) {
+ var dx = booster.x - mishnu.x;
+ var dy = booster.y - mishnu.y;
+ if (Math.sqrt(dx * dx + dy * dy) < 50) {
+ booster.pickUp();
+ boosters.splice(boosters.indexOf(booster), 1);
}
- }
- // Initialize zombies
- var zombies = [];
- var zombieSpawnCooldown = 3000; // Time (ms) between zombie spawn attempts
- var zombieSpawnElapsedTime = 0;
- var maxZombiesOnScreen = 10;
- // Update game loop to handle zombies
- var originalGameUpdate = game.update;
- game.update = function () {
- originalGameUpdate.call(this);
- // Update zombies
- zombies.forEach(function (zombie) {
- zombie.update();
- });
- // Spawn zombies if needed
- zombieSpawnElapsedTime += 16; // Assume 16ms per frame
- if (zombieSpawnElapsedTime >= zombieSpawnCooldown && zombies.length < maxZombiesOnScreen) {
- spawnZombies(1, maxZombiesOnScreen); // Spawn one zombie at a time
- zombieSpawnElapsedTime = 0;
+ });
+}
+// Add to game update loop
+var originalGameUpdate = game.update;
+game.update = function () {
+ originalGameUpdate.call(this);
+ boosters.forEach(function (booster) {
+ booster.update();
+ });
+ checkBoosterPickup();
+};
+var globalHealthBar = new GlobalHealthBar(100, 100);
+function spawnZombies(count, maxZombiesOnScreen) {
+ for (var i = 0; i < count; i++) {
+ if (zombies.length >= maxZombiesOnScreen) {
+ break;
}
- // Ensure zombie count does not exceed maximum
- if (zombies.length > maxZombiesOnScreen) {
- while (zombies.length > maxZombiesOnScreen) {
- var zombieToRemove = zombies.pop();
- game.removeChild(zombieToRemove);
- }
+ var spawnEdge = Math.floor(Math.random() * 3); // 0: top, 1: left, 2: right
+ var spawnX, spawnY;
+ switch (spawnEdge) {
+ case 0:
+ spawnX = Math.random() * 2048;
+ spawnY = -50;
+ break;
+ case 1:
+ spawnX = -50;
+ spawnY = Math.random() * (2432 - 300);
+ break;
+ case 2:
+ spawnX = 2048 + 50;
+ spawnY = Math.random() * (2432 - 300);
+ break;
}
- };
- var isMusicPlaying = {
- 'Music_Level_1_4': false,
- 'Music_Level_1_5': false
- };
- // Update factory text
- function updateFactoryText() {
- factoryText.setText("Level: " + factory.level + "\nMeat: " + factory.meat + "\nMishnu Snax: " + factory.dogFood + "\nNext level at: " + factory.nextLevelRequirement);
+ var newZombie = new Zombie();
+ newZombie.x = spawnX;
+ newZombie.y = spawnY;
+ zombies.push(newZombie);
+ game.addChild(newZombie);
}
- // Function to randomly select a sound from a list
- ;
- // Add a UI layer to ensure factory is rendered above the background and mask
- var uiLayer = new Container();
- uiLayer.zIndex = 10; // Ensure it's above the background and mask
- game.addChild(uiLayer);
- // Create and position the health bar at the top center of the viewport
- var globalHealthBar = new GlobalHealthBar(5, 5); // Initialize with initial and max health of 5
- globalHealthBar.x = 1820; // Center horizontally
- globalHealthBar.y = 2560; // Position at the top center
- // Add text label 'Health' above the global health bar
- var healthLabel = new Text2('Health', {
- size: 50,
- fill: 0xFFFFFF
+}
+// Initialize zombies
+var zombies = [];
+var zombieSpawnCooldown = 3000; // Time (ms) between zombie spawn attempts
+var zombieSpawnElapsedTime = 0;
+var maxZombiesOnScreen = 10;
+// Update game loop to handle zombies
+var originalGameUpdate = game.update;
+game.update = function () {
+ originalGameUpdate.call(this);
+ // Update zombies
+ zombies.forEach(function (zombie) {
+ zombie.update();
});
- healthLabel.anchor.set(0.5, 1);
- healthLabel.x = globalHealthBar.x;
- healthLabel.y = globalHealthBar.y - 60; // Position above the health bar
- uiLayer.addChild(healthLabel);
- uiLayer.addChild(globalHealthBar); // Add to the UI layer to ensure visibility
- // Add the factory to the UI layer
- var factory = uiLayer.addChild(new Factory());
- // Initialize factory text
- var factoryText = new Text2('Meat: 0\nMishnu Snax: 0\nNext level at: ', {
- size: 50,
- fill: 0xFFFFFF,
- align: 'left'
- });
- factoryText.anchor.set(0, 1);
- LK.gui.bottomLeft.addChild(factoryText);
- var nextLevel = 100; // Placeholder for next level goal
- // Function to randomly spawn a human at the edges of the viewport
- function spawnHumans(count, maxHumansOnScreen) {
- var hardCap = 100; // Maximum number of humans allowed
- for (var i = 0; i < count; i++) {
- if (humans.length >= maxHumansOnScreen || humans.length >= hardCap) {
- break;
- }
- // Randomly select a spawn edge (excluding the bottom)
- var spawnEdge = Math.floor(Math.random() * 3); // 0: top, 1: left, 2: right
- var spawnX, spawnY;
- switch (spawnEdge) {
- case 0:
- // Top
- spawnX = Math.random() * 2048;
- spawnY = -50; // Just outside the top boundary
- break;
- case 1:
- // Left
- spawnX = -50; // Just outside the left boundary
- spawnY = Math.random() * (2432 - 300); // Exclude bottom UI area
- break;
- case 2:
- // Right
- spawnX = 2048 + 50; // Just outside the right boundary
- spawnY = Math.random() * (2432 - 300); // Exclude bottom UI area
- break;
- }
- // Create a new human and add it to the game
- var newHuman;
- if (currentLevelGroup === 0) {
- newHuman = new Human(); // Base human
- } else {
- newHuman = new UpgradedHuman(); // Upgraded human for higher levels
- }
- newHuman.x = spawnX;
- newHuman.y = spawnY;
- humans.push(newHuman);
- game.addChild(newHuman);
+ // Spawn zombies if needed
+ zombieSpawnElapsedTime += 16; // Assume 16ms per frame
+ if (zombieSpawnElapsedTime >= zombieSpawnCooldown && zombies.length < maxZombiesOnScreen) {
+ spawnZombies(1, maxZombiesOnScreen); // Spawn one zombie at a time
+ zombieSpawnElapsedTime = 0;
+ }
+ // Ensure zombie count does not exceed maximum
+ if (zombies.length > maxZombiesOnScreen) {
+ while (zombies.length > maxZombiesOnScreen) {
+ var zombieToRemove = zombies.pop();
+ game.removeChild(zombieToRemove);
}
}
- // Update game loop
- var originalUpdate = game.update;
- game.update = function () {
- originalUpdate.call(this);
- // Update factory
- factory.update();
- // Check for level progression
- if (factory.dogFood >= nextLevel) {
- // Handle level progression logic here
- nextLevel += 100; // Example: increase next level goal
- updateFactoryText();
+};
+var isMusicPlaying = {
+ 'Music_Level_1_4': false,
+ 'Music_Level_1_5': false
+};
+// Update factory text
+function updateFactoryText() {
+ 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
+var uiLayer = new Container();
+uiLayer.zIndex = 10; // Ensure it's above the background and mask
+game.addChild(uiLayer);
+// Create and position the health bar at the top center of the viewport
+var globalHealthBar = new GlobalHealthBar(5, 5); // Initialize with initial and max health of 5
+globalHealthBar.x = 1820; // Center horizontally
+globalHealthBar.y = 2560; // Position at the top center
+// Add text label 'Health' above the global health bar
+var healthLabel = new Text2('Health', {
+ size: 50,
+ fill: 0xFFFFFF
+});
+healthLabel.anchor.set(0.5, 1);
+healthLabel.x = globalHealthBar.x;
+healthLabel.y = globalHealthBar.y - 60; // Position above the health bar
+uiLayer.addChild(healthLabel);
+uiLayer.addChild(globalHealthBar); // Add to the UI layer to ensure visibility
+// Add the factory to the UI layer
+var factory = uiLayer.addChild(new Factory());
+// Initialize factory text
+var factoryText = new Text2('Meat: 0\nMishnu Snax: 0\nNext level at: ', {
+ size: 50,
+ fill: 0xFFFFFF,
+ align: 'left'
+});
+factoryText.anchor.set(0, 1);
+LK.gui.bottomLeft.addChild(factoryText);
+var nextLevel = 100; // Placeholder for next level goal
+// Function to randomly spawn a human at the edges of the viewport
+function spawnHumans(count, maxHumansOnScreen) {
+ var hardCap = 100; // Maximum number of humans allowed
+ for (var i = 0; i < count; i++) {
+ if (humans.length >= maxHumansOnScreen || humans.length >= hardCap) {
+ break;
}
- };
- function flashGreyMask(targets, duration, flashes) {
- var flashInterval = duration / (flashes * 2); // Time for each flash on/off
- var flashCount = 0;
- var interval = LK.setInterval(function () {
- if (flashCount >= flashes * 2) {
- // End the flashing effect
- targets.forEach(function (target) {
- if (target && typeof target.tint !== 'undefined') {
- target.tint = 0xFFFFFF;
- }
- }); // Reset tint
- LK.clearInterval(interval);
- } else {
- var isOn = flashCount % 2 === 0; // Toggle between grey and normal
- var tintColor = isOn ? 0x808080 : 0xFFFFFF; // Grey tint or original
- targets.forEach(function (target) {
- if (target && typeof target.tint !== 'undefined') {
- target.tint = tintColor;
- }
- }); // Apply tint
- flashCount++;
- }
- }, flashInterval);
+ // Randomly select a spawn edge (excluding the bottom)
+ var spawnEdge = Math.floor(Math.random() * 3); // 0: top, 1: left, 2: right
+ var spawnX, spawnY;
+ switch (spawnEdge) {
+ case 0:
+ // Top
+ spawnX = Math.random() * 2048;
+ spawnY = -50; // Just outside the top boundary
+ break;
+ case 1:
+ // Left
+ spawnX = -50; // Just outside the left boundary
+ spawnY = Math.random() * (2432 - 300); // Exclude bottom UI area
+ break;
+ case 2:
+ // Right
+ spawnX = 2048 + 50; // Just outside the right boundary
+ spawnY = Math.random() * (2432 - 300); // Exclude bottom UI area
+ break;
+ }
+ // Create a new human and add it to the game
+ var newHuman = new Human();
+ newHuman.x = spawnX;
+ newHuman.y = spawnY;
+ humans.push(newHuman);
+ game.addChild(newHuman);
}
- function getRandomSound(soundList) {
- return LK.getSound(soundList[Math.floor(Math.random() * soundList.length)]);
+}
+// Update game loop
+var originalUpdate = game.update;
+game.update = function () {
+ originalUpdate.call(this);
+ // Update factory
+ factory.update();
+ // Check for level progression
+ if (factory.dogFood >= nextLevel) {
+ // Handle level progression logic here
+ nextLevel += 100; // Example: increase next level goal
+ updateFactoryText();
}
- // Function to fade out a sound
- function fadeOutSound(sound, duration) {
- var initialVolume = sound.volume;
- var fadeStep = initialVolume / (duration / 100);
- var fadeInterval = LK.setInterval(function () {
- if (sound.volume > 0) {
- sound.volume = Math.max(0, sound.volume - fadeStep);
- } else {
- LK.clearInterval(fadeInterval);
- sound.stop();
- }
- }, 100);
- }
- var radius = game.addChild(new HarvestRadius());
- var mishnu = game.addChild(new Mishnu());
- mishnu.harvestSpeed = 1; // Initialize harvest speed
- mishnu.x = 2048 / 2;
- mishnu.y = 2432 - 200;
- radius.x = mishnu.x;
- radius.y = mishnu.y;
- // Initialize humans
- var humans = [];
- for (var i = 0; i < 50; i++) {
- var human = new Human();
- human.x = Math.random() * 2048;
- human.y = Math.random() * (2432 - 100);
- humans.push(human);
- game.addChild(human);
- var humansSpawnedThisLevel = 0; // Tracks how many humans have spawned in the current level
- var humanSpawnLimit = factory.nextLevelRequirement * 7; // Set minimum spawn limit to nextLevelRequirement * 7
- var currentLevelGroup = Math.floor(factory.level / 5); // Determine the current level group
- }
- var spawnCooldown = 20; // Reduced time (in ms) between spawn attempts for faster spawning
- var spawnElapsedTime = 0; // Tracks time elapsed since the last spawn attempt
- // Play looping Dog Panting sound
- LK.getSound('Dog_panting').play({
- loop: true
- });
- // Handle mouse movement
- game.move = function (x, y, obj) {
- mishnu.targetX = x;
- mishnu.targetY = y;
- };
- // Display cargo count
- var cargoText = new Text2('Cargo: 0 / 10', {
- size: 50,
- fill: 0xFFFFFF
- });
- cargoText.anchor.set(1, 1);
- LK.gui.bottomRight.addChild(cargoText);
- // Music alternation logic
- var currentMusic = 'Music_Level_1_5';
- game.update = function () {
- humans.forEach(function (human) {
- human.update();
- });
- mishnu.update();
- zombies.forEach(function (zombie) {
- zombie.update();
- });
- radius.update();
- boosters.forEach(function (booster) {
- booster.update();
- });
- checkBoosterPickup();
- // 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
- if (humans.length < minHumansOnScreen) {
- spawnElapsedTime += 16; // Assume 16ms per frame
- if (spawnElapsedTime >= spawnCooldown) {
- spawnHumans(minHumansOnScreen - humans.length, maxHumansOnScreen); // Pass the maxHumansOnScreen value
- spawnElapsedTime = 0; // Reset spawn elapsed time
- }
+};
+function flashGreyMask(targets, duration, flashes) {
+ var flashInterval = duration / (flashes * 2); // Time for each flash on/off
+ var flashCount = 0;
+ var interval = LK.setInterval(function () {
+ if (flashCount >= flashes * 2) {
+ // End the flashing effect
+ targets.forEach(function (target) {
+ if (target && typeof target.tint !== 'undefined') {
+ target.tint = 0xFFFFFF;
+ }
+ }); // Reset tint
+ LK.clearInterval(interval);
+ } else {
+ var isOn = flashCount % 2 === 0; // Toggle between grey and normal
+ var tintColor = isOn ? 0x808080 : 0xFFFFFF; // Grey tint or original
+ targets.forEach(function (target) {
+ if (target && typeof target.tint !== 'undefined') {
+ target.tint = tintColor;
+ }
+ }); // Apply tint
+ flashCount++;
}
- // Cap the number of humans to maxHumansOnScreen
- if (humans.length > maxHumansOnScreen) {
- // Remove excess humans from the game
- while (humans.length > maxHumansOnScreen) {
- var humanToRemove = humans.pop();
- game.removeChild(humanToRemove);
- }
- }
- // Update cargo text
- var textColor = mishnu.humansHarvested > mishnu.cargoMax ? 0xFF0000 : 0xFFFFFF;
- if (cargoText.fill !== textColor) {
- LK.gui.bottomRight.removeChild(cargoText);
- cargoText = new Text2('Cargo: ' + mishnu.humansHarvested + ' / ' + mishnu.cargoMax, {
- size: 50,
- fill: textColor
- });
- cargoText.anchor.set(1, 1);
- LK.gui.bottomRight.addChild(cargoText);
+ }, flashInterval);
+}
+function getRandomSound(soundList) {
+ return LK.getSound(soundList[Math.floor(Math.random() * soundList.length)]);
+}
+// Function to fade out a sound
+function fadeOutSound(sound, duration) {
+ var initialVolume = sound.volume;
+ var fadeStep = initialVolume / (duration / 100);
+ var fadeInterval = LK.setInterval(function () {
+ if (sound.volume > 0) {
+ sound.volume = Math.max(0, sound.volume - fadeStep);
} else {
- cargoText.setText('Cargo: ' + mishnu.humansHarvested + ' / ' + mishnu.cargoMax);
+ LK.clearInterval(fadeInterval);
+ sound.stop();
}
- // Play Music_Level_1_4 in a loop
- if (!isMusicPlaying['Music_Level_1_4']) {
- LK.playMusic('Music_Level_1_4', {
- loop: true
- });
- isMusicPlaying['Music_Level_1_4'] = true; // Track music state
+ }, 100);
+}
+var radius = game.addChild(new HarvestRadius());
+var mishnu = game.addChild(new Mishnu());
+mishnu.harvestSpeed = 1; // Initialize harvest speed
+mishnu.x = 2048 / 2;
+mishnu.y = 2432 - 200;
+radius.x = mishnu.x;
+radius.y = mishnu.y;
+// Initialize humans
+var humans = [];
+for (var i = 0; i < 50; i++) {
+ var human = new Human();
+ human.x = Math.random() * 2048;
+ human.y = Math.random() * (2432 - 100);
+ humans.push(human);
+ game.addChild(human);
+ var humansSpawnedThisLevel = 0; // Tracks how many humans have spawned in the current level
+ var humanSpawnLimit = factory.nextLevelRequirement * 7; // Set minimum spawn limit to nextLevelRequirement * 7
+}
+var spawnCooldown = 20; // Reduced time (in ms) between spawn attempts for faster spawning
+var spawnElapsedTime = 0; // Tracks time elapsed since the last spawn attempt
+// Play looping Dog Panting sound
+LK.getSound('Dog_panting').play({
+ loop: true
+});
+// Handle mouse movement
+game.move = function (x, y, obj) {
+ mishnu.targetX = x;
+ mishnu.targetY = y;
+};
+// Display cargo count
+var cargoText = new Text2('Cargo: 0 / 10', {
+ size: 50,
+ fill: 0xFFFFFF
+});
+cargoText.anchor.set(1, 1);
+LK.gui.bottomRight.addChild(cargoText);
+// Music alternation logic
+var currentMusic = 'Music_Level_1_5';
+game.update = function () {
+ humans.forEach(function (human) {
+ human.update();
+ });
+ mishnu.update();
+ zombies.forEach(function (zombie) {
+ zombie.update();
+ });
+ radius.update();
+ boosters.forEach(function (booster) {
+ booster.update();
+ });
+ checkBoosterPickup();
+ // 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
+ if (humans.length < minHumansOnScreen) {
+ spawnElapsedTime += 16; // Assume 16ms per frame
+ if (spawnElapsedTime >= spawnCooldown) {
+ spawnHumans(minHumansOnScreen - humans.length, maxHumansOnScreen); // Pass the maxHumansOnScreen value
+ spawnElapsedTime = 0; // Reset spawn elapsed time
}
- // Play Music_Level_1_5 in a loop
- if (!isMusicPlaying['Music_Level_1_5']) {
- LK.playMusic('Music_Level_1_5', {
- loop: true
- });
- isMusicPlaying['Music_Level_1_5'] = true; // Track music state
+ }
+ // Cap the number of humans to maxHumansOnScreen
+ if (humans.length > maxHumansOnScreen) {
+ // Remove excess humans from the game
+ while (humans.length > maxHumansOnScreen) {
+ var humanToRemove = humans.pop();
+ game.removeChild(humanToRemove);
}
- // Update factory
- factory.update();
- };
+ }
+ // Update cargo text
+ var textColor = mishnu.humansHarvested > mishnu.cargoMax ? 0xFF0000 : 0xFFFFFF;
+ if (cargoText.fill !== textColor) {
+ LK.gui.bottomRight.removeChild(cargoText);
+ cargoText = new Text2('Cargo: ' + mishnu.humansHarvested + ' / ' + mishnu.cargoMax, {
+ size: 50,
+ fill: textColor
+ });
+ cargoText.anchor.set(1, 1);
+ LK.gui.bottomRight.addChild(cargoText);
+ } else {
+ cargoText.setText('Cargo: ' + mishnu.humansHarvested + ' / ' + mishnu.cargoMax);
+ }
+ // Play Music_Level_1_4 in a loop
+ if (!isMusicPlaying['Music_Level_1_4']) {
+ LK.playMusic('Music_Level_1_4', {
+ loop: true
+ });
+ isMusicPlaying['Music_Level_1_4'] = true; // Track music state
+ }
+ // Play Music_Level_1_5 in a loop
+ if (!isMusicPlaying['Music_Level_1_5']) {
+ LK.playMusic('Music_Level_1_5', {
+ loop: true
+ });
+ isMusicPlaying['Music_Level_1_5'] = true; // Track music state
+ }
+ // Update factory
+ factory.update();
};
\ No newline at end of file
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