Code edit (3 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Graphics is not a constructor' in or related to this line: 'var maskGraphics = new Graphics();' Line Number: 45
Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Graphics is not a constructor' in or related to this line: 'self.maskColor = new Graphics();' Line Number: 41
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: LK.getDelta is not a function' in or related to this line: 'self.flashTimer += LK.getDelta();' Line Number: 138
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: LK.getDelta is not a function' in or related to this line: 'self.flashTimer += LK.getDelta();' Line Number: 138
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: LK.getDelta is not a function' in or related to this line: 'self.flashTimer += LK.getDelta();' Line Number: 138
Code edit (12 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: LK.getDelta is not a function' in or related to this line: 'self.flashTimer += LK.getDelta();' Line Number: 137
Code edit (3 edits merged)
Please save this source code
User prompt
Why is dong panting sound not continuously playing in a loop? it shouldn't just play once it should play in a loop
Code edit (1 edits merged)
Please save this source code
Code edit (7 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: fadeOutSound is not defined' in or related to this line: 'fadeOutSound(LK.getSound('Agony_Yell_1'), 1000); // Fade out over 1 second' Line Number: 87
Code edit (2 edits merged)
Please save this source code
User prompt
No the sound needs to start playing at a random point in the sound. It shouldn't start from the start of our 10 second sound. It needs to start at random part of the sound
User prompt
No, When the human enters the radius the sound plays, when he exits the radius or is harvested the sound stops.
User prompt
Whenever a human is being harvested he will emit sound Agony_Yell_1. However the sound starts at a random point of it's 10 second duration
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: LK.playSound is not a function' in or related to this line: 'LK.playSound('Music_Level_1_5');' Line Number: 175
User prompt
Its no lk current music its lk sound. just play them on after the other, and do this in a loop
===================================================================
--- original.js
+++ change.js
@@ -39,37 +39,41 @@
}
if (self.y < 50 || self.y > 2732 - 200) {
self.speedY *= -1;
self.y = self.y < 50 ? 50 : 2732 - 200; // Keep humans above the text area
- } // Avoid bottom reserved area
+ }
// Check if this human is in Mishnu's radius
var dx = self.x - mishnu.x;
var dy = self.y - mishnu.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < radius.radiusSize) {
// Mishnu's radius
- var runSpeed = 2; // Further reduce speed to make escape less frequent
+ var runSpeed = 2;
self.x += dx / distance * runSpeed;
self.y += dy / distance * runSpeed;
if (!self.isBeingHarvested) {
self.isBeingHarvested = true;
self.inRadiusStartTime = Date.now();
- // Play Agony_Yell_1 sound at a random point of its 10 second duration
- LK.getSound('Agony_Yell_1').play({
- start: Math.random() * 0.9 // Random start point between 0 and 0.9
+ // Play Agony_Yell_1 at a random start point
+ var agonySound = LK.getSound('Agony_Yell_1');
+ agonySound.play({
+ start: Math.random() * 0.585 // Random start point
});
+ agonySound.volume = 0.3; // Reset volume to ensure it starts correctly
} else if (Date.now() - self.inRadiusStartTime >= 2000) {
// Harvest the human
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++;
- LK.getSound('Agony_Yell_1').stop(); // Stop sound when harvested
+ // Fade out Agony_Yell_1 when the human is harvested
+ fadeOutSound(LK.getSound('Agony_Yell_1'), 1000); // Fade out over 1 second
}
}
} else {
if (self.isBeingHarvested) {
- LK.getSound('Agony_Yell_1').stop(); // Stop sound when exiting radius
+ // Fade out Agony_Yell_1 when human exits the radius
+ fadeOutSound(LK.getSound('Agony_Yell_1'), 1000); // Fade out over 1 second
}
self.isBeingHarvested = false; // Reset harvesting if out of radius
self.inRadiusStartTime = null;
}
@@ -91,15 +95,13 @@
self.cargoMax = 10; // Maximum cargo
self.targetX = 2048 / 2;
self.targetY = 2732 - 200;
self.update = function () {
- // Adjust speed only when over 100% cargo
var effectiveSpeed = self.speed;
if (self.humansHarvested > self.cargoMax) {
- var overCapacityFactor = (self.humansHarvested - self.cargoMax) / (self.cargoMax * 0.5); // Normalize overcapacity
+ var overCapacityFactor = (self.humansHarvested - self.cargoMax) / (self.cargoMax * 0.5);
effectiveSpeed *= Math.max(0.5, 1 - overCapacityFactor); // Decrease speed down to 50%
}
- // Move Mishnu towards the cursor at adjusted speed
var dx = self.targetX - self.x;
var dy = self.targetY - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance > 0) {
@@ -113,15 +115,28 @@
/****
* Initialize Game
****/
var game = new LK.Game({
- backgroundColor: 0x000000 //Init game with black background
+ backgroundColor: 0x000000 // Init game with black background
});
/****
* Game Code
****/
+// Function to fade out a sound over a specified duration
// Initialize Mishnu's harvest radius
+function fadeOutSound(sound, duration) {
+ var initialVolume = sound.volume;
+ var fadeStep = initialVolume / (duration / 100); // Calculate the fade step based on duration
+ var fadeInterval = LK.setInterval(function () {
+ if (sound.volume > 0) {
+ sound.volume = Math.max(0, sound.volume - fadeStep); // Decrease volume
+ } else {
+ LK.clearInterval(fadeInterval); // Clear interval when volume reaches 0
+ sound.stop(); // Stop the sound
+ }
+ }, 100); // Adjust volume every 100ms
+}
var radius = game.addChild(new HarvestRadius());
// Initialize Mishnu
var mishnu = game.addChild(new Mishnu());
mishnu.x = 2048 / 2;
@@ -129,62 +144,50 @@
radius.x = mishnu.x;
radius.y = mishnu.y;
// Array to hold humans
var humans = [];
-// Create humans at random positions
for (var i = 0; i < 50; i++) {
- // Increased number of humans to spawn more
var human = new Human();
human.x = Math.random() * 2048;
human.y = Math.random() * 2732 - 100; // Avoid bottom reserved area
humans.push(human);
game.addChild(human);
}
+// Play looping Dog Panting sound
+LK.getSound('Dog_panting').play({
+ loop: true
+});
// Handle mouse movement to set Mishnu's target position
game.move = function (x, y, obj) {
if (y < 2732 - 100) {
- // Avoid bottom reserved area
mishnu.targetX = x;
mishnu.targetY = y;
}
};
-// Add a new text field to display the number of humans harvested by Mishnu
+// Text field to display the number of humans harvested
var cargoText = new Text2('Cargo: 0 / 10', {
size: 50,
fill: 0xFFFFFF
});
cargoText.anchor.set(1, 1); // Anchor to the bottom right corner
LK.gui.bottomRight.addChild(cargoText);
-// Update game logic
+// Declare currentMusic to alternate music
+var currentMusic = 'Music_Level_1_5';
game.update = function () {
humans.forEach(function (human) {
human.update();
});
mishnu.update();
- radius.update(); // Update the harvest radius
+ radius.update();
// Update the cargo text field
cargoText.setText('Cargo: ' + mishnu.humansHarvested + ' / 10');
- // Play Music_Level_1_5 and Music_Level_1_4 in a loop
- // Declare currentMusic outside of any function to ensure it's preserved
- // Declare currentMusic outside the game.update function
- var currentMusic = 'Music_Level_1_5'; // Initialize with the first music track
- game.update = function () {
- humans.forEach(function (human) {
- human.update();
- });
- mishnu.update();
- radius.update(); // Update the harvest radius
- // Update the cargo text field
- cargoText.setText('Cargo: ' + mishnu.humansHarvested + ' / 10');
- // Alternate between Music_Level_1_5 and Music_Level_1_4
- if (LK.ticks % 120 === 0) {
- // Every 120 ticks
- if (currentMusic === 'Music_Level_1_5') {
- LK.playMusic('Music_Level_1_4');
- currentMusic = 'Music_Level_1_4'; // Update the current music
- } else {
- LK.playMusic('Music_Level_1_5');
- currentMusic = 'Music_Level_1_5'; // Update the current music
- }
+ // Alternate between Music_Level_1_5 and Music_Level_1_4
+ if (LK.ticks % 1000 === 0) {
+ if (currentMusic === 'Music_Level_1_5') {
+ LK.playMusic('Music_Level_1_4');
+ currentMusic = 'Music_Level_1_4';
+ } else {
+ LK.playMusic('Music_Level_1_5');
+ currentMusic = 'Music_Level_1_5';
}
- };
+ }
};
\ 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