User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'expand')' in this line: 'var HealingBubble = Bubble.expand(function () {' Line Number: 20
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'expand')' in this line: 'var GrowingPlant = Decoration.expand(function () {' Line Number: 1
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'expand')' in this line: 'var CastleHidingFish = Fish.expand(function () {' Line Number: 1
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'expand')' in this line: 'var CleanerFish = Fish.expand(function () {' Line Number: 1
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'expand')' in this line: 'var JumpingFish = Fish.expand(function () {' Line Number: 1
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'expand')' in this line: 'var CamouflageFish = Fish.expand(function () {' Line Number: 1
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'expand')' in this line: 'var SchoolingFish = Fish.expand(function () {' Line Number: 1
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'expand')' in this line: 'var PlayfulFish = Fish.expand(function () {' Line Number: 1
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'expand')' in this line: 'var BreedingFish = Fish.expand(function () {' Line Number: 1
User prompt
Improve the entire code with 10 new functionality
User prompt
Fix Bug: 'TypeError: self.getNearbyFishWithinRange is not a function' in this line: 'var nearbyPredators = self.getNearbyFishWithinRange(200).filter(function (fish) {' Line Number: 942
User prompt
Fix Bug: 'TypeError: self.getNearbyFishWithinRange is not a function' in this line: 'var nearbyPredators = self.getNearbyFishWithinRange(200).filter(function (fish) {' Line Number: 942
User prompt
Fix Bug: 'TypeError: self.getNearbyFish is not a function' in this line: 'var nearbyPredators = self.getNearbyFish().filter(function (fish) {' Line Number: 942
User prompt
Fix Bug: 'Uncaught ReferenceError: Fish is not defined' in this line: 'var PeacefulFish = Fish.expand(function () {' Line Number: 54
User prompt
Add 50 new line of code
User prompt
Improve the entire code with two new functionality
User prompt
Improve the entire code with two new functionality
User prompt
Fix Bug: 'Uncaught TypeError: self.getWaterBounds is not a function' in this line: 'var waterBounds = self.getWaterBounds();' Line Number: 1438
User prompt
Fix Bug: 'Uncaught TypeError: self.getWaterBounds is not a function' in this line: 'var waterBounds = self.getWaterBounds();' Line Number: 1438
User prompt
Fix Bug: 'Uncaught TypeError: self.getWaterBounds is not a function' in this line: 'var waterBounds = self.getWaterBounds();' Line Number: 1438
User prompt
Fix Bug: 'Uncaught TypeError: self.getWaterBounds is not a function' in this line: 'var waterBounds = self.getWaterBounds();' Line Number: 1438
User prompt
Fix Bug: 'Uncaught ReferenceError: aquarium is not defined' in this line: 'var waterBounds = aquarium.getWaterBounds();' Line Number: 1447
User prompt
Improve the entire code with two new functionality
User prompt
Improve the entire code with a new functionality
User prompt
Fix Bug: 'Uncaught TypeError: this.addChild is not a function' in this line: 'self.cleanObject = function (obj, rate) {' Line Number: 272
===================================================================
--- original.js
+++ change.js
@@ -50,179 +50,30 @@
});
return nearbyPredators.length > 0;
};
});
-var Fish = Container.expand(function () {
- var self = Container.call(this);
- self.rushToFood = function (food) {
- self.targetRotation = Math.atan2(food.y - self.y, food.x - self.x);
- self.directionChangeTime = LK.ticks;
- self.directionChangeInterval = 5;
- };
- self.hunger = 100;
- Fish.prototype.restingBehavior = new RestingBehavior();
- Fish.prototype.reproductionBehavior = new ReproductionBehavior();
- self.hungerDecayRate = 0.1;
- Fish.prototype.feedingBehavior = new FeedingBehavior();
- self.updateHunger = function () {
- var closestFood = self.feedingBehavior.findClosestFood();
- if (closestFood && self.distanceTo(closestFood) <= self.feedingBehavior.feedingRange) {
- self.feedingBehavior.eatFood(closestFood);
- self.hunger += closestFood.nutrition;
- }
- self.hunger -= self.hungerDecayRate;
- if (self.hunger <= 0) {
- self.health -= self.hungerDecayRate;
- if (self.health <= 0) {
- self.die();
- }
- }
- self.hunger = Math.max(self.hunger, 0);
- self.hunger = Math.min(self.hunger, 100);
- };
- self.greetFish = function (otherFish) {
- if (!self.memory.includes(otherFish)) {
- self.targetRotation = Math.atan2(otherFish.y - self.y, otherFish.x - self.x);
+var PeacefulFish = Fish.expand(function () {
+ var self = Fish.call(this);
+ var peacefulGraphics = self.createAsset('peacefulFish', 'Peaceful Fish Graphics', .5, .5);
+ self.speed = Math.random() * 0.3 + 0.8;
+ self.fleeRange = 300;
+ self.flee = function (predator) {
+ if (self.distanceTo(predator) < self.fleeRange) {
+ self.targetRotation = Math.atan2(self.y - predator.y, self.x - predator.x);
self.directionChangeTime = LK.ticks;
- self.directionChangeInterval = 5;
- self.rememberObject(otherFish);
+ self.directionChangeInterval = 10;
}
};
- Fish.prototype.playfulBehavior = new PlayfulBehavior();
- self.memory = [];
- self.rememberObject = function (target) {
- if (!self.memory.includes(target)) {
- self.memory.push(target);
- }
- };
- Fish.prototype.foragingBehavior = new ForagingBehavior();
- self.forgetObject = function (target) {
- var index = self.memory.indexOf(target);
- if (index > -1) {
- self.memory.splice(index, 1);
- }
- };
- self.getNearbyObjects = function () {
- var nearbyObjects = [];
- LK.stageContainer.children.forEach(function (child) {
- if (!(child instanceof Fish) && child !== self) {
- var dx = child.x - self.x;
- var dy = child.y - self.y;
- var distance = Math.sqrt(dx * dx + dy * dy);
- if (distance < 300) {
- nearbyObjects.push(child);
- }
- }
+ self.move = function () {
+ var nearbyPredators = self.getNearbyFish().filter(function (fish) {
+ return fish.size > self.size;
});
- return nearbyObjects;
- };
- self.findCuriosityTarget = function () {
- var possibleTargets = self.getNearbyObjects();
- if (possibleTargets.length > 0) {
- self.curiosityTarget = possibleTargets[Math.floor(Math.random() * possibleTargets.length)];
+ if (nearbyPredators.length > 0) {
+ self.flee(nearbyPredators[0]);
}
+ Fish.prototype.move.call(self);
};
- self.investigateCuriosity = function (target) {
- self.targetRotation = Math.atan2(target.y - self.y, target.x - self.x);
- self.directionChangeTime = LK.ticks;
- self.directionChangeInterval = 10;
- };
- self.distanceTo = function (target) {
- var dx = target.x - self.x;
- var dy = target.y - self.y;
- return Math.sqrt(dx * dx + dy * dy);
- };
- Fish.prototype.evasionBehavior = new EvasionBehavior();
- Fish.prototype.leadershipBehavior = new LeadershipBehavior();
- self.findMate = function (nearbyFish) {
- var potentialMate = null;
- var minDistance = Infinity;
- nearbyFish.forEach(function (fish) {
- if (fish.constructor === self.constructor && fish !== self && !fish.isMating) {
- var distance = self.distanceTo(fish);
- if (distance < minDistance) {
- minDistance = distance;
- potentialMate = fish;
- }
- }
- });
- if (potentialMate && minDistance < 100) {
- self.isMating = true;
- potentialMate.isMating = true;
- var egg = new Egg();
- egg.x = (self.x + potentialMate.x) / 2;
- egg.y = (self.y + potentialMate.y) / 2;
- LK.stageContainer.addChild(egg);
- }
- };
- self.evadeLargerFish = function (largerFish) {};
- self.getNearbyFish = function () {
- var nearbyFish = [];
- LK.stageContainer.children.forEach(function (child) {
- if (child instanceof Fish && child !== self) {
- var dx = child.x - self.x;
- var dy = child.y - self.y;
- var distance = Math.sqrt(dx * dx + dy * dy);
- if (distance < 300) {
- nearbyFish.push(child);
- }
- }
- });
- return nearbyFish;
- };
- self.avoidObstacles = function (obstacles) {
- if (obstacles.length > 0) {
- var sumAngles = 0;
- var count = 0;
- for (var i = 0; i < obstacles.length; i++) {
- var obstacle = obstacles[i];
- var angleToObstacle = Math.atan2(obstacle.y - self.y, obstacle.x - self.x);
- sumAngles += angleToObstacle + Math.PI;
- count++;
- }
- if (count > 0) {
- var averageAvoidAngle = sumAngles / count;
- self.targetRotation = averageAvoidAngle;
- self.directionChangeTime = LK.ticks;
- self.directionChangeInterval = Math.random() * 50 + 30;
- }
- }
- };
- self.isPathBlocked = function (newX, newY, obstacles) {
- for (var i = 0; i < obstacles.length; i++) {
- var obstacle = obstacles[i];
- var dx = obstacle.x - newX;
- var dy = obstacle.y - newY;
- if (Math.sqrt(dx * dx + dy * dy) < obstacle.radius + self.radius) {
- return true;
- }
- }
- return false;
- };
- Fish.prototype.mortalityBehavior = new MortalityBehavior();
- self.getNearbyObstacles = function () {
- var nearbyObstacles = [];
- LK.stageContainer.children.forEach(function (child) {
- if (typeof Obstacle !== 'undefined' && child instanceof Obstacle) {
- var dx = child.x - self.x;
- var dy = child.y - self.y;
- var distance = Math.sqrt(dx * dx + dy * dy);
- if (distance < 300) {
- nearbyObstacles.push(child);
- }
- }
- });
- return nearbyObstacles;
- };
- this.getWaterBounds = function () {
- var waterGraphics = LK.getAsset('water', 'Water Graphics', 0, 0);
- return {
- left: (2048 - waterGraphics.width) / 2,
- right: (2048 + waterGraphics.width) / 2,
- top: (2732 - waterGraphics.height) / 2 - 150,
- bottom: (2732 + waterGraphics.height) / 2 - 150
- };
- };
+ LK.setInterval(self.move, 500);
});
var Lighting = Container.expand(function () {
var self = Container.call(this);
self.light = function () {};
@@ -529,19 +380,19 @@
self.feedingFrenzy();
Fish.prototype.move.call(self);
};
});
-var AggressiveHunterFish = Fish.expand(function () {
+var PredatorFish = Fish.expand(function () {
var self = Fish.call(this) || this;
- var hunterGraphics = self.createAsset('aggressiveHunterFish', 'Aggressive Hunter Fish Graphics', .5, .5);
- self.speed = Math.random() * 0.5 + 1;
- self.huntRange = 400;
+ var predatorGraphics = self.createAsset('predatorFish', 'Predator Fish Graphics', .5, .5);
+ self.speed = Math.random() * 0.5 + 1.5;
+ self.huntRange = 500;
self.hunt = function (prey) {
if (self.distanceTo(prey) < self.huntRange) {
self.targetRotation = Math.atan2(prey.y - self.y, prey.x - self.x);
self.directionChangeTime = LK.ticks;
- self.directionChangeInterval = 3;
- prey.health -= 1;
+ self.directionChangeInterval = 2;
+ prey.health -= 2;
if (prey.health <= 0) {
prey.die();
}
}
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.