User prompt
Spawn one object
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'createAsset')' in this line: 'var castleGraphics = self.createAsset('decorativeCastle', 'Decorative Castle Graphics', 0.5, 1);' Line Number: 379
User prompt
Fix Bug: 'Uncaught TypeError: Cannot set properties of undefined (setting 'castleGraphics')' in this line: 'self.castleGraphics = LK.getAsset('decorativeCastle', 'Decorative Castle Graphics', 0.5, 1);' Line Number: 379
User prompt
Fix Bug: 'Uncaught TypeError: Cannot set properties of undefined (setting 'castleGraphics')' in this line: 'self.castleGraphics = castleGraphics;' Line Number: 380
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'createAsset')' in this line: 'var castleGraphics = self.createAsset('decorativeCastle', 'Decorative Castle Graphics', 0.5, 1);' Line Number: 379
User prompt
Fix Bug: 'Uncaught TypeError: Cannot set properties of undefined (setting 'castleGraphics')' in this line: 'self.castleGraphics = LK.getAsset('decorativeCastle', 'Decorative Castle Graphics', 0.5, 1);' Line Number: 379
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'createAsset')' in this line: 'self.castleGraphics = self.createAsset('decorativeCastle', 'Decorative Castle Graphics', 0.5, 1);' Line Number: 379
User prompt
Fix Bug: 'Uncaught TypeError: self.activate is not a function' in this line: 'self.activate();' Line Number: 41
User prompt
Fix Bug: 'Uncaught TypeError: Cannot set properties of undefined (setting 'feedingRate')' in this line: 'self.feedingRate = 5000;' Line Number: 26
User prompt
Spawn one of each object
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'expand')' in this line: 'var MovingFood = Food.expand(function () {' Line Number: 603
User prompt
Improve the entire code with 4 new functionality
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'expand')' in this line: 'var PredatorFish = Fish.expand(function () {' Line Number: 43
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'expand')' in this line: 'var FishFeeder = InteractiveElement.expand(function () {' Line Number: 17
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'expand')' in this line: 'var FishFeeder = InteractiveDecoration.expand(function () {' Line Number: 17
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'expand')' in this line: 'var BubbleCurtain = DecorativePlant.expand(function () {' Line Number: 1
User prompt
Improve the entire code with 4 new functionality
User prompt
Fix Bug: 'Uncaught TypeError: Fish.extend is not a function' in this line: 'var CleanerFish = Fish.extend(function () {' Line Number: 1806
User prompt
Fix Bug: 'Uncaught TypeError: Fish.extend is not a function' in this line: 'var SchoolLeaderFish = Fish.extend(function () {' Line Number: 1790
User prompt
Fix Bug: 'Uncaught TypeError: Fish.extend is not a function' in this line: 'var StealthFish = Fish.extend(function () {' Line Number: 1779
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'expand')' in this line: 'var BubbleShieldFish = Fish.expand(function () {' Line Number: 46
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'expand')' in this line: 'var JumpingFish = Fish.expand(function () {' Line Number: 23
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'expand')' in this line: 'var StealthFish = Fish.expand(function () {' Line Number: 23
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'expand')' in this line: 'var SchoolLeaderFish = Fish.expand(function () {' Line Number: 23
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'expand')' in this line: 'var CleanerFish = Fish.expand(function () {' Line Number: 23
===================================================================
--- original.js
+++ change.js
@@ -1,62 +1,78 @@
-var InflatableFish = Container.expand(function () {
- var self = Container.call(this);
- self.inflationSize = 2;
- self.inflationDuration = 3000;
- self.isInflated = false;
- self.inflate = function () {
- if (!self.isInflated) {
- self.isInflated = true;
- self.scale.x *= self.inflationSize;
- self.scale.y *= self.inflationSize;
- LK.setTimeout(function () {
- self.scale.x /= self.inflationSize;
- self.scale.y /= self.inflationSize;
- self.isInflated = false;
- }, self.inflationDuration);
+var BubbleCurtain = DecorativePlant.expand(function () {
+ var self = DecorativePlant.call(this) || this;
+ self.bubbleRate = 1000;
+ self.createBubble = function () {
+ var bubble = new RisingBubble();
+ bubble.x = self.x;
+ bubble.y = self.y;
+ LK.stageContainer.addChild(bubble);
+ };
+ LK.setInterval(self.createBubble, self.bubbleRate);
+ return self;
+});
+var FishFeeder = InteractiveDecoration.expand(function () {
+ var self = InteractiveDecoration.call(this) || this;
+ self.feedingRate = 5000;
+ self.feed = function () {
+ if (self.isActive) {
+ var food = new Food();
+ food.x = 1024;
+ food.y = 1366;
+ LK.stageContainer.addChild(food);
+ var nearbyFish = self.getNearbyFishWithinRange(500);
+ nearbyFish.forEach(function (fish) {
+ fish.rushToFood(food);
+ });
}
};
- self.on('tick', function () {
- self.inflate();
- });
+ LK.setInterval(self.feed, self.feedingRate);
+ self.activate();
return self;
});
-var JumpingFish = Container.expand(function () {
- var self = Container.call(this);
- self.jumpHeight = 150;
- self.jumpFrequency = 10000;
- self.isJumping = false;
- self.jump = function () {
- if (!self.isJumping) {
- self.isJumping = true;
- var initialY = self.y;
- LK.setTimeout(function () {
- self.y = initialY - self.jumpHeight;
- LK.setTimeout(function () {
- self.y = initialY;
- self.isJumping = false;
- }, 1000);
- }, self.jumpFrequency);
+var PredatorFish = Fish.expand(function () {
+ var self = Fish.call(this) || this;
+ self.predatorGraphics = self.createAsset('predatorFish', 'Predator Fish Graphics', 0.5, 0.5);
+ self.speed = 3;
+ self.huntRange = 300;
+ self.hunt = function () {
+ var nearbyPrey = self.getNearbyFish().filter(function (fish) {
+ return fish.size < self.size && fish.health > 0;
+ });
+ if (nearbyPrey.length > 0) {
+ var prey = nearbyPrey[0];
+ for (var i = 1; i < nearbyPrey.length; i++) {
+ if (self.distanceTo(nearbyPrey[i]) < self.distanceTo(prey)) {
+ prey = nearbyPrey[i];
+ }
+ }
+ if (self.distanceTo(prey) < self.huntRange) {
+ self.targetRotation = Math.atan2(prey.y - self.y, prey.x - self.x);
+ prey.health -= 2;
+ if (prey.health <= 0) {
+ prey.destroy();
+ }
+ }
}
};
- self.on('tick', function () {
- self.jump();
- });
+ self.on('tick', self.hunt);
return self;
});
-var BubbleShieldFish = Container.expand(function () {
- var self = Container.call(this);
- self.shieldBubbleRate = 5000;
- self.shieldBubbleSize = 100;
- self.createShieldBubble = function () {
- var bubble = new Bubble();
- bubble.x = self.x;
- bubble.y = self.y;
- bubble.width = self.shieldBubbleSize;
- bubble.height = self.shieldBubbleSize;
- LK.stageContainer.addChild(bubble);
+var HealingPlant = DecorativePlant.expand(function () {
+ var self = DecorativePlant.call(this) || this;
+ self.healingRate = 0.05;
+ self.healingRange = 100;
+ self.healNearbyFish = function () {
+ var nearbyFish = self.getNearbyFishWithinRange(self.healingRange);
+ nearbyFish.forEach(function (fish) {
+ if (fish.health < 100) {
+ fish.health = Math.min(fish.health + self.healingRate, 100);
+ }
+ });
};
- LK.setInterval(self.createShieldBubble, self.shieldBubbleRate);
+ self.on('tick', function () {
+ self.healNearbyFish();
+ });
return self;
});
var DecorativePlant = Container.expand(function () {
var self = Container.call(this);
@@ -558,15 +574,15 @@
return self;
});
var HealingFish = Fish.expand(function () {
var self = Fish.call(this) || this;
- self.healingRate = 0.05;
- self.healingRange = 150;
+ self.healingRate = 0.1;
+ self.healingRange = 100;
self.healNearbyFish = function () {
var nearbyFish = self.getNearbyFishWithinRange(self.healingRange);
nearbyFish.forEach(function (fish) {
if (fish.health < 100) {
- fish.health += self.healingRate;
+ fish.health = Math.min(fish.health + self.healingRate, 100);
}
});
};
self.on('tick', function () {
@@ -709,27 +725,8 @@
self.destroy();
}
});
});
-var FishFeeder = InteractiveDecoration.expand(function () {
- var self = InteractiveDecoration.call(this) || this;
- self.feedingRate = 5000;
- self.feed = function () {
- if (self.isActive) {
- var food = new Food();
- food.x = 1024;
- food.y = 1366;
- LK.stageContainer.addChild(food);
- var nearbyFish = self.getNearbyFishWithinRange(500);
- nearbyFish.forEach(function (fish) {
- fish.rushToFood(food);
- });
- }
- };
- LK.setInterval(self.feed, self.feedingRate);
- self.activate();
- return self;
-});
var IntelligentFishBehavior = Container.expand(function () {
var self = Container.call(this);
self.intelligenceLevel = 5;
self.avoidPredators = function (fish) {
@@ -764,36 +761,8 @@
}
};
return self;
});
-var PredatorFish = Fish.expand(function () {
- var self = Fish.call(this) || this;
- self.predatorGraphics = self.createAsset('predatorFish', 'Predator Fish Graphics', 0.5, 0.5);
- self.speed = 3;
- self.huntRange = 300;
- self.hunt = function () {
- var nearbyPrey = self.getNearbyFish().filter(function (fish) {
- return fish.size < self.size && fish.health > 0;
- });
- if (nearbyPrey.length > 0) {
- var prey = nearbyPrey[0];
- for (var i = 1; i < nearbyPrey.length; i++) {
- if (self.distanceTo(nearbyPrey[i]) < self.distanceTo(prey)) {
- prey = nearbyPrey[i];
- }
- }
- if (self.distanceTo(prey) < self.huntRange) {
- self.targetRotation = Math.atan2(prey.y - self.y, prey.x - self.x);
- prey.health -= 2;
- if (prey.health <= 0) {
- prey.destroy();
- }
- }
- }
- };
- self.on('tick', self.hunt);
- return self;
-});
var RestingBehavior = Container.expand(function () {
var self = Container.call(this);
self.isResting = false;
self.lastRestTime = LK.ticks;
@@ -1660,20 +1629,8 @@
}
fishGraphics.rotation = self.rotation;
};
});
-var BubbleCurtain = DecorativePlant.expand(function () {
- var self = DecorativePlant.call(this) || this;
- self.bubbleRate = 1000;
- self.createBubble = function () {
- var bubble = new RisingBubble();
- bubble.x = self.x;
- bubble.y = self.y;
- LK.stageContainer.addChild(bubble);
- };
- LK.setInterval(self.createBubble, self.bubbleRate);
- return self;
-});
var RisingBubble = Container.expand(function () {
var self = Container.call(this);
self.liftSpeed = 3;
self.on('tick', function () {
@@ -1697,30 +1654,23 @@
};
});
var CamouflageFish = Fish.expand(function () {
var self = Fish.call(this) || this;
- self.colorChangeRate = 0.1;
- self.colorChangeThreshold = 200;
- self.currentEnvironmentColor = 0xFFFFFF;
- self.changeColorBasedOnEnvironment = function () {
- var environmentObjects = self.getNearbyObjects().filter(function (obj) {
- return obj instanceof DecorativePlant || obj instanceof Algae;
- });
- if (environmentObjects.length > 0) {
- var closestEnvironmentObject = environmentObjects[0];
- for (var i = 1; i < environmentObjects.length; i++) {
- if (self.distanceTo(environmentObjects[i]) < self.distanceTo(closestEnvironmentObject)) {
- closestEnvironmentObject = environmentObjects[i];
- }
- }
- if (self.distanceTo(closestEnvironmentObject) < self.colorChangeThreshold) {
- self.currentEnvironmentColor = closestEnvironmentObject.color;
- }
+ self.hide = function () {
+ var predators = self.getNearbyPredators();
+ if (predators.length > 0) {
+ self.alpha = 0.3;
+ } else {
+ self.alpha = 1.0;
}
- self.tint = self.currentEnvironmentColor;
};
+ self.getNearbyPredators = function () {
+ return self.getNearbyFish().filter(function (otherFish) {
+ return otherFish.size > self.size && self.distanceTo(otherFish) < 200;
+ });
+ };
self.on('tick', function () {
- self.changeColorBasedOnEnvironment();
+ self.hide();
});
return self;
});
var FishManager = Container.expand(function () {
@@ -1760,86 +1710,23 @@
return self;
});
var MentorFish = Fish.expand(function () {
var self = Fish.call(this) || this;
- self.intelligenceBoostRate = 0.5;
- self.boostRange = 250;
+ self.intelligenceBoostRate = 1;
+ self.boostRange = 200;
self.boostIntelligence = function () {
var nearbyFish = self.getNearbyFishWithinRange(self.boostRange);
nearbyFish.forEach(function (fish) {
if (!(fish instanceof MentorFish)) {
- fish.intelligenceLevel += self.intelligenceBoostRate;
+ fish.intelligenceLevel = Math.min(fish.intelligenceLevel + self.intelligenceBoostRate, 100);
}
});
};
self.on('tick', function () {
self.boostIntelligence();
});
return self;
});
-var StealthFish = Fish.expand(function () {
- var self = Fish.call(this) || this;
- self.stealthMode = false;
- self.stealthDuration = 5000;
- self.toggleStealthMode = function () {
- self.stealthMode = !self.stealthMode;
- self.alpha = self.stealthMode ? 0.1 : 1.0;
- };
- LK.setInterval(self.toggleStealthMode, self.stealthDuration);
- return self;
-});
-var SchoolLeaderFish = Fish.expand(function () {
- var self = Fish.call(this) || this;
- self.schoolingRange = 300;
- self.attractFishToSchool = function () {
- var nearbyFish = self.getNearbyFishWithinRange(self.schoolingRange);
- nearbyFish.forEach(function (fish) {
- if (fish.constructor !== SchoolLeaderFish) {
- fish.targetRotation = Math.atan2(self.y - fish.y, self.x - fish.x);
- }
- });
- };
- self.on('tick', function () {
- self.attractFishToSchool();
- });
- return self;
-});
-var CleanerFish = Fish.expand(function () {
- var self = Fish.call(this) || this;
- self.cleaningRate = 0.2;
- self.eatAlgae = function () {
- var algae = self.getNearbyObjects().filter(function (obj) {
- return obj instanceof Algae;
- });
- algae.forEach(function (algae) {
- if (self.distanceTo(algae) < 50) {
- algae.consume(self);
- }
- });
- };
- self.on('tick', function () {
- self.eatAlgae();
- });
- return self;
-});
-var DistractingFish = Fish.extend(function () {
- var self = Fish.call(this) || this;
- self.distractRange = 200;
- self.distractPredators = function () {
- var predators = self.getNearbyFish().filter(function (fish) {
- return fish.size > self.size;
- });
- predators.forEach(function (predator) {
- if (self.distanceTo(predator) < self.distractRange) {
- predator.targetRotation = Math.atan2(self.y - predator.y, self.x - predator.x);
- }
- });
- };
- self.on('tick', function () {
- self.distractPredators();
- });
- return self;
-});
Fish.prototype.updateColorBasedOnHealth = function () {
if (this.health < 30) {
this.tint = 0xFF6347;
} else if (this.health < 70) {
An aquarium with no fish on a sheel in a photorealistic style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A realistic goldfish. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A realistic Angelfish. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A realistic koyfish swiming to the right. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A realistic gupyfish swiming to the right. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A realistic bettafish swiming to the right. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A realistic clownfish swiming to the right. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A realistic pufferfish swiming to the right. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A realistic surgeonfish swiming to the right. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A realistic buble of water. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A realistic fish egg. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A realistic celestial pearl danio. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A realistic Parrotfish. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A realistic dartfish. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A realistic moorishidol. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A realistic tangfish. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A realistic bannerfish. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A realistic butterflyfish. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A realistic mandarinfish. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a realistic lionfish. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a realistic emperorFish. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a realistic sunfish. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a realistic discusFish. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a realistic neonTetra. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a realistic oscarFish. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a cardinal tetra. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a tang fish. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a clown fish. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.