Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: originalUpdate is undefined' in or related to this line: 'originalUpdate.call(this); // Call the original update logic' Line Number: 480
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: originalUpdate is undefined' in or related to this line: 'originalUpdate.call(this); // Call the original update logic' Line Number: 482
User prompt
Please fix the bug: 'TypeError: originalUpdate is undefined' in or related to this line: 'originalUpdate.call(this); // Call the original update logic' Line Number: 480
Code edit (2 edits merged)
Please save this source code
User prompt
no, still not a single human respawning.
User prompt
Our humans are still not spawning at all. As you can see we tried to implement logic with maximum number on screen and a rate of spawning. minimum number on screen. Right now humans are not spawning back in at all after being harvested.
User prompt
Humans are still not being repopulated. So far no new humans have spawned and come into the viewport. We also need it to follow the logic we attempted to create to control the human population. but at the moment there seems to just be a problem with the fact there is no new human spawns at all.
User prompt
Check to see why our spawn function is not working, as we are not getting any new humans in the game. Fix this while maintaining the mechanics we attempted for the spawn function and such
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: originalUpdate is undefined' in or related to this line: 'game.update = function (deltaTime) {' Line Number: 520
User prompt
Please fix the bug: 'TypeError: originalUpdate is undefined' in or related to this line: 'originalUpdate.call(this); // Call the original update logic' Line Number: 519
User prompt
Please fix the bug: 'TypeError: originalUpdate is undefined' in or related to this line: 'originalUpdate.call(this); // Call the original update logic' Line Number: 480
Code edit (1 edits merged)
Please save this source code
User prompt
no mishnu is still frozen
User prompt
not sure why, our mishnu movement is frozen. make sure to fix it without breaking the mechanics we intended
User prompt
Please fix the bug: 'ReferenceError: currentMusic is not defined' in or related to this line: 'currentMusic = currentMusic === 'Music_Level_1_5' ? 'Music_Level_1_4' : 'Music_Level_1_5';' Line Number: 415
Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: originalUpdate is undefined' in or related to this line: 'originalUpdate.call(this); // Call the original update logic' Line Number: 482
User prompt
Please fix the bug: 'TypeError: originalUpdate is undefined' in or related to this line: 'originalUpdate.call(this); // Call the original update logic' Line Number: 480
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'InternalError: too much recursion' in or related to this line: 'originalUpdate.call(this, deltaTime); // Call the original update logic with deltaTime' Line Number: 417
User prompt
Please fix the bug: 'TypeError: originalUpdate is undefined' in or related to this line: 'originalUpdate.call(this); // Call the original update logic' Line Number: 482
User prompt
Please fix the bug: 'TypeError: originalUpdate is undefined' in or related to this line: 'originalUpdate.call(this); // Call the original update logic' Line Number: 480
===================================================================
--- original.js
+++ change.js
@@ -41,8 +41,9 @@
self.processInterval = null;
self.rumbleTimer = 0; // Timer for rumble effect
self.level = 1; // Current level
self.nextLevelRequirement = 5; // Starting requirement for level 2
+ // Start processing meat into dog food
self.startProcessing = function () {
if (!self.processing && self.meat >= 5) {
self.processing = true;
LK.getSound('Factory_Operation').play({
@@ -59,66 +60,77 @@
}
}, 5000);
}
};
+ // Stop processing
self.stopProcessing = function () {
if (self.processing) {
self.processing = false;
LK.clearInterval(self.processInterval);
LK.getSound('Factory_Operation').stop();
}
};
+ // Update the factory
self.update = function () {
+ // Check for Mishnu depositing cargo
if (mishnu.humansHarvested > 0 && self.intersects(mishnu)) {
+ // Mishnu deposits cargo
self.meat += mishnu.humansHarvested;
mishnu.humansHarvested = 0;
- LK.getSound('Factory_Deposit').play();
+ LK.getSound('Factory_Deposit').play(); // Play deposit sound
updateFactoryText();
self.startProcessing();
}
+ // Add rumble effect when processing
if (self.processing) {
- self.rumbleTimer += 16;
+ self.rumbleTimer += 16; // Assume 16ms per frame
if (self.rumbleTimer >= 100) {
- factoryGraphics.x = Math.random() * 6 - 3;
- factoryGraphics.y = Math.random() * 6 - 3;
+ // Rumble every 100ms
+ factoryGraphics.x = Math.random() * 6 - 3; // Horizontal rumble
+ factoryGraphics.y = Math.random() * 6 - 3; // Vertical rumble
self.rumbleTimer = 0;
}
} else {
+ // Reset position when not processing
factoryGraphics.x = 0;
factoryGraphics.y = 0;
}
+ // Stop processing if out of meat
if (self.meat < 5 && self.processing) {
self.stopProcessing();
}
};
+ // Check for level progression
function checkLevelProgression() {
if (self.dogFood >= self.nextLevelRequirement) {
self.level++;
- LK.getSound('Ding_1').play();
- self.nextLevelRequirement += Math.round(self.nextLevelRequirement * 0.75);
+ LK.getSound('Ding_1').play(); // Play level-up sound
+ self.nextLevelRequirement += Math.round(self.nextLevelRequirement * 0.75); // Increase requirement by 75%
updateFactoryText();
}
}
return self;
});
-// HarvestRadius Class
+// Class for Mishnu's harvest radius
var HarvestRadius = Container.expand(function () {
var self = Container.call(this);
var radiusGraphics = self.attachAsset('radius', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 10,
scaleY: 10
});
- var rotationSpeed = 0.001;
+ self.radiusSize = 300; // Effective radius size
+ var rotationSpeed = 0.001; // Extremely slow rotation speed
self.update = function () {
self.x = mishnu.x;
self.y = mishnu.y;
+ // Apply slow rotation to the radius
radiusGraphics.rotation += rotationSpeed;
};
return self;
});
-// Human Class
+// Class for Humans
var Human = Container.expand(function () {
var self = Container.call(this);
var humanGraphics = self.attachAsset('human', {
anchorX: 0.5,
@@ -130,86 +142,136 @@
self.isBeingHarvested = false;
self.inRadiusStartTime = null;
self.currentAgonySound = null;
self.currentCrunchSound = null;
- self.yellStarted = false;
- self.yellShouldPlay = Math.random() < 1 / 3;
- self.crunchShouldPlay = Math.random() < 1 / 6;
- self.flashTimer = 0;
- self.flashInterval = 500;
+ 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 the viewport margins
var margin = 50;
- var bottomMargin = 300;
- 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 - bottomMargin) {
+ 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 (mishnu.humansHarvested >= mishnu.cargoMax * 1.5) {
+ // Stop all sounds when cargo exceeds 150% capacity
+ if (self.currentAgonySound) {
+ 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 (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;
- var intensity = Math.min(1, elapsedTime / 3000);
+ 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;
- self.flashTimer += 16;
+ // 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']);
self.currentAgonySound.volume = 0.3;
self.currentAgonySound.play();
}
if (elapsedTime >= 3000) {
- game.removeChild(self);
- humans.splice(humans.indexOf(self), 1);
- mishnu.humansHarvested++;
- if (self.currentAgonySound) {
- self.currentAgonySound.stop();
+ // 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);
+ }
}
- LK.getSound('Ding_1').play();
- getRandomSound(['Squish_1', 'Squish_2', 'Squish_3', 'Squish_4']).play();
- for (var i = 0; i < 10; i++) {
- var bloodSplash = game.addChild(new BloodSplash(self.x, self.y, true));
- 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;
- humanGraphics.tint = 0xFFFFFF;
+ humanGraphics.tint = 0xFFFFFF; // Reset flashing
bloodSplashes.forEach(function (splash) {
game.removeChild(splash);
});
}
};
return self;
});
-// Mishnu Class
+// Class for Mishnu
var Mishnu = Container.expand(function () {
var self = Container.call(this);
var mishnuGraphics = self.attachAsset('mishnu', {
anchorX: 0.5,
@@ -224,20 +286,22 @@
self.update = function () {
var dx = self.targetX - self.x;
var dy = self.targetY - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
+ // Adjust speed based on cargo
if (self.humansHarvested > self.cargoMax) {
var overCapacityFactor = (self.humansHarvested - self.cargoMax) / (self.cargoMax * 0.5);
- self.speed = Math.max(1, 4 - 3 * overCapacityFactor);
+ self.speed = Math.max(1, 4 - 3 * overCapacityFactor); // Minimum speed of 1
} else {
- self.speed = 4;
+ self.speed = 4; // Full speed
}
if (distance > 0) {
self.x += dx / distance * self.speed;
self.y += dy / distance * self.speed;
}
+ // Keep Mishnu within viewport margins
var margin = 50;
- var bottomMargin = 300;
+ var bottomMargin = 300; // Extra margin for bottom text box
self.x = Math.max(margin, Math.min(2048 - margin, self.x));
self.y = Math.max(margin, Math.min(2432 - bottomMargin, self.y));
};
return self;
@@ -245,73 +309,93 @@
/****
* Initialize Game
****/
-// Initialize Game
var game = new LK.Game({
backgroundColor: 0x000000
});
/****
* Game Code
****/
-// UI Layer
+// Update factory text
+function updateFactoryText() {
+ factoryText.setText("Level: " + factory.level + "\nMeat: " + factory.meat + "\nDog Food: " + 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;
+uiLayer.zIndex = 10; // Ensure it's above the background and mask
game.addChild(uiLayer);
+// Add the factory to the UI layer
var factory = uiLayer.addChild(new Factory());
+// Initialize factory text
var factoryText = new Text2('Meat: 0\nDog Food: 0\nNext level at: 100', {
size: 50,
fill: 0xFFFFFF,
align: 'left'
});
factoryText.anchor.set(0, 1);
LK.gui.bottomLeft.addChild(factoryText);
-var humans = [];
+var nextLevel = 100; // Placeholder for next level goal
+// Function to randomly spawn a human at the edges of the viewport
function spawnHumans(count, maxHumansOnScreen) {
for (var i = 0; i < count; i++) {
+ // Check if we've reached the max humans allowed on screen
if (humans.length >= maxHumansOnScreen) {
break;
}
- var spawnEdge = Math.floor(Math.random() * 4);
+ // Randomly determine spawn location
+ var spawnEdge = Math.floor(Math.random() * 4); // 0: top, 1: bottom, 2: left, 3: right
var spawnX, spawnY;
switch (spawnEdge) {
case 0:
+ // Top
spawnX = Math.random() * 2048;
- spawnY = -50;
+ spawnY = -50; // Just outside top boundary
break;
case 1:
+ // Bottom
spawnX = Math.random() * 2048;
- spawnY = 2432 + 50;
+ spawnY = 2432 + 50; // Just outside bottom boundary
break;
case 2:
- spawnX = -50;
+ // Left
+ spawnX = -50; // Just outside left boundary
spawnY = Math.random() * 2432;
break;
case 3:
- spawnX = 2048 + 50;
+ // Right
+ spawnX = 2048 + 50; // Just outside right boundary
spawnY = Math.random() * 2432;
break;
}
+ // Create and add a new human
var newHuman = new Human();
newHuman.x = spawnX;
newHuman.y = spawnY;
humans.push(newHuman);
game.addChild(newHuman);
}
}
-var cargoText = new Text2('Level: 1 Cargo: 0 / 10', {
- size: 50,
- fill: 0xFFFFFF
-});
-cargoText.anchor.set(1, 1);
-LK.gui.bottomRight.addChild(cargoText);
-function updateFactoryText() {
- factoryText.setText("Level: " + factory.level + "\nMeat: " + factory.meat + "\nDog Food: " + factory.dogFood + "\nNext level at: " + factory.nextLevelRequirement);
-}
+// 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 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 () {
@@ -328,44 +412,65 @@
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 * 5; // Initial spawn limit for level 1
}
-var spawnCooldown = 100;
-var spawnElapsedTime = 0;
-var nextLevel = 100;
-var currentMusic = 'Music_Level_1_5'; // Initialize currentMusic variable
-var originalUpdate = game.update;
+var spawnCooldown = 100; // Time (in ms) between spawn attempts
+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('Level: 1 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 (deltaTime) {
- if (originalUpdate) {
- originalUpdate.call(game, deltaTime);
- }
+ originalUpdate.call(this); // Call the original update logic
+ // Update entities
humans.forEach(function (human) {
human.update();
});
- if (mishnu) {
- mishnu.update();
- }
+ mishnu.update();
radius.update();
+ // Calculate dynamic minimum and maximum humans
var minHumansOnScreen = Math.max((factory.nextLevelRequirement - factory.dogFood) * 5, 10);
var maxHumansOnScreen = Math.ceil(minHumansOnScreen * 1.25);
+ // Increment spawn timer
spawnElapsedTime += deltaTime;
+ // Spawn humans if below minimum threshold and cooldown is met
if (humans.length < minHumansOnScreen && spawnElapsedTime >= spawnCooldown) {
- spawnHumans(1, maxHumansOnScreen);
- spawnElapsedTime = 0;
+ spawnHumans(1, maxHumansOnScreen); // Spawn one human at a time
+ spawnElapsedTime = 0; // Reset cooldown timer
}
+ // Cap humans to `maxHumansOnScreen`
if (humans.length > maxHumansOnScreen) {
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, {
@@ -376,13 +481,15 @@
LK.gui.bottomRight.addChild(cargoText);
} else {
cargoText.setText('Cargo: ' + mishnu.humansHarvested + ' / ' + mishnu.cargoMax);
}
+ // Update factory and handle level progression
factory.update();
if (factory.dogFood >= nextLevel) {
- nextLevel += 100;
+ nextLevel += 100; // Example: increment level goal
updateFactoryText();
}
+ // Alternate music
if (LK.ticks % 1000 === 0) {
currentMusic = currentMusic === 'Music_Level_1_5' ? 'Music_Level_1_4' : 'Music_Level_1_5';
LK.playMusic(currentMusic);
}
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