User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'expand')' in this line: 'var DistractingFish = Fish.expand(function () {' Line Number: 23
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'expand')' in this line: 'var InflatableFish = Fish.expand(function () {' Line Number: 1
User prompt
Improve the entire code with 10 new functionality
User prompt
Improve the entire code with 4 new functionality
User prompt
Improve the entire code with 4 new functionality
User prompt
Make fish move
User prompt
Fix Bug: 'Uncaught TypeError: aquarium.getWaterBounds is not a function' in this line: 'var waterBounds = aquarium.getWaterBounds();' Line Number: 1630
User prompt
Improve the entire code with 6new functionality
User prompt
Fix Bug: 'Uncaught ReferenceError: Food is not defined' in this line: 'var SpeedyFood = Food.expand(function () {' Line Number: 535
User prompt
Fix Bug: 'Uncaught ReferenceError: DecorativePlant is not defined' in this line: 'var GrowingPlant = DecorativePlant.expand(function () {' Line Number: 444
User prompt
Fix Bug: 'Uncaught ReferenceError: Bubble is not defined' in this line: 'var CapturingBubble = Bubble.expand(function () {' Line Number: 83
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 BubbleProducingFish = Fish.expand(function () {' Line Number: 107
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'expand')' in this line: 'var FoodSpawningFish = Fish.expand(function () {' Line Number: 67
User prompt
Improve the entire code with 6 new functionality
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'expand')' in this line: 'var IntelligentFish = Fish.expand(function () {' Line Number: 31
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'expand')' in this line: 'var TreasureChest = InteractiveElement.expand(function () {' Line Number: 1
User prompt
Improve the entire code with 4 new functionality
User prompt
Improve the entire code with 8 new functionality
User prompt
Improve the entire code with 4 new functionality
User prompt
Improve the entire code with 4 new functionality
User prompt
Make fish move 3 time slower
User prompt
Improve the entire code with 4 new functionality
User prompt
Improve the entire code with two new functionality
User prompt
Improve the entire code with two new functionality
===================================================================
--- original.js
+++ change.js
@@ -593,11 +593,14 @@
var foodSources = fish.getNearbyObjects().filter(function (obj) {
return obj instanceof Food;
});
if (foodSources.length > 0) {
- var closestFood = foodSources.reduce(function (closest, food) {
- return fish.distanceTo(food) < fish.distanceTo(closest) ? food : closest;
- }, foodSources[0]);
+ var closestFood = foodSources[0];
+ for (var i = 1; i < foodSources.length; i++) {
+ if (fish.distanceTo(foodSources[i]) < fish.distanceTo(closestFood)) {
+ closestFood = foodSources[i];
+ }
+ }
fish.targetRotation = Math.atan2(closestFood.y - fish.y, closestFood.x - fish.x);
}
};
return self;
@@ -645,8 +648,9 @@
} else if (self.isResting && LK.ticks - self.lastRestTime > self.restInterval) {
self.isResting = false;
}
};
+ return self;
});
var ReproductionBehavior = Container.expand(function () {
var self = Container.call(this);
self.isMating = false;
@@ -655,15 +659,18 @@
self.isLayingEggs = false;
self.lastEggTime = LK.ticks;
self.eggInterval = Math.random() * 3000 + 2000;
self.mate = function (fish, partner) {
- if (self.isMating && LK.ticks - self.lastMateTime > self.mateInterval) {
+ if (!self.isMating && LK.ticks - self.lastMateTime > self.mateInterval) {
+ self.isMating = true;
+ partner.isMating = true;
+ self.lastMateTime = LK.ticks;
+ partner.lastMateTime = LK.ticks;
var egg = new Egg();
egg.x = (fish.x + partner.x) / 2;
egg.y = (fish.y + partner.y) / 2;
LK.stageContainer.addChild(egg);
- self.lastMateTime = LK.ticks;
- partner.lastMateTime = LK.ticks;
+ } else if (self.isMating && LK.ticks - self.lastMateTime > self.mateInterval) {
self.isMating = false;
partner.isMating = false;
}
};
@@ -674,10 +681,13 @@
var egg = new Egg();
egg.x = fish.x;
egg.y = fish.y;
LK.stageContainer.addChild(egg);
+ } else if (self.isLayingEggs && LK.ticks - self.lastEggTime > self.eggInterval) {
+ self.isLayingEggs = false;
}
};
+ return self;
});
var FeedingBehavior = Container.expand(function () {
var self = Container.call(this);
self.hunger = 100;
@@ -713,8 +723,9 @@
}
});
return closestFood;
};
+ return self;
});
var PlayfulBehavior = Container.expand(function () {
var self = Container.call(this);
PlayfulBehavior.prototype.playWithObject = function (fish, target) {
@@ -748,55 +759,53 @@
var SchoolingBehavior = Container.expand(function () {
var self = Container.call(this);
self.schoolWith = function (fish, similarFish) {
if (similarFish.length > 1) {
- var schoolCenterX = 0;
- var schoolCenterY = 0;
- similarFish.forEach(function (fish) {
- schoolCenterX += fish.x;
- schoolCenterY += fish.y;
- });
- schoolCenterX /= similarFish.length;
- schoolCenterY /= similarFish.length;
+ var schoolCenterX = similarFish.reduce((sum, fish) => sum + fish.x, 0) / similarFish.length;
+ var schoolCenterY = similarFish.reduce((sum, fish) => sum + fish.y, 0) / similarFish.length;
fish.targetRotation = Math.atan2(schoolCenterY - fish.y, schoolCenterX - fish.x);
fish.directionChangeTime = LK.ticks;
fish.directionChangeInterval = 30;
}
};
+ return self;
});
var EvasionBehavior = Container.expand(function () {
var self = Container.call(this);
self.evadePredators = function (fish, predators) {
- var evadeAngle = 0;
- predators.forEach(function (predator) {
- var angleToPredator = Math.atan2(predator.y - fish.y, predator.x - fish.x);
- evadeAngle += angleToPredator + Math.PI;
- });
- evadeAngle /= predators.length;
- fish.targetRotation = evadeAngle + (Math.random() * Math.PI - Math.PI / 2);
- fish.directionChangeTime = LK.ticks;
- fish.directionChangeInterval = 10;
+ if (predators.length > 0) {
+ var evadeAngle = predators.reduce(function (sum, predator) {
+ var angleToPredator = Math.atan2(predator.y - fish.y, predator.x - fish.x);
+ return sum + angleToPredator + Math.PI;
+ }, 0) / predators.length;
+ fish.targetRotation = evadeAngle + (Math.random() * Math.PI - Math.PI / 2);
+ fish.directionChangeTime = LK.ticks;
+ fish.directionChangeInterval = 10;
+ }
};
+ return self;
});
var LeadershipBehavior = Container.expand(function () {
var self = Container.call(this);
self.followLeader = function (fish, leaderFish) {
var followDistance = 50;
- var dx = leaderFish.x - fish.x;
- var dy = leaderFish.y - fish.y;
- var distance = Math.sqrt(dx * dx + dy * dy);
+ var distance = fish.distanceTo(leaderFish);
if (distance > followDistance) {
- fish.targetRotation = Math.atan2(dy, dx);
+ fish.targetRotation = Math.atan2(leaderFish.y - fish.y, leaderFish.x - fish.x);
fish.directionChangeTime = LK.ticks;
fish.directionChangeInterval = 10;
}
};
+ return self;
});
var MortalityBehavior = Container.expand(function () {
var self = Container.call(this);
self.die = function (fish) {
- fish.destroy();
+ if (fish.health <= 0) {
+ fish.destroy();
+ }
};
+ return self;
});
var Surgeonfish = Fish.expand(function () {
var self = Fish.call(this) || this;
Surgeonfish.prototype.findNearestCleaner = function () {
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.