User prompt
Create 4 new race of fish
User prompt
Spawn one fish of each race
User prompt
Create 4 new race of fish
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'expand')' in this line: 'var RoyalGramma = Fish.expand(function () {' Line Number: 1
User prompt
Create 6 new race of fish
User prompt
Fish move 10 time faster
User prompt
Fix movement
User prompt
Spawn 4 fish of diferent race
User prompt
Spawn 2 fish
User prompt
Spawn only one fish
User prompt
Improve movement with 15 new functionality
User prompt
Fix fish not Moving
User prompt
Fix fish not Moving
User prompt
Fix fish not Moving
User prompt
Fix fish not Moving
User prompt
Fix fish not Moving
User prompt
Make all fish move
User prompt
Optimise
User prompt
Optimise
User prompt
Improve fish movement a lot
User prompt
Improve fish movement
User prompt
Fix move
User prompt
Spawn one of every class at begining
User prompt
Add a new race
User prompt
Spawn two différent object at begining
===================================================================
--- original.js
+++ change.js
@@ -77,8 +77,130 @@
self.speed = 2;
self.direction = Math.random() * Math.PI * 2;
self.moveBehavior = new FishMoveBehavior(self);
self.move = function () {
+ if (self.hunger < 30) {
+ var similarFish = self.getNearbyFish().filter(function (fish) {
+ var obstacles = self.getNearbyObstacles();
+ if (self.hunger > 70 && Math.random() < 0.05) {
+ var toys = self.getNearbyObjects().filter(function (obj) {
+ if (self.hunger > 50 && !self.isMating && Math.random() < 0.05) {
+ if (Math.random() < 0.05) {
+ var largerFish = self.getNearbyFish().filter(function (fish) {
+ var leaderFish = self.getNearbyFish().find(function (fish) {
+ var threats = self.getNearbyFish().filter(function (fish) {
+ if (self.health < 30) {
+ if (Math.random() < 0.01 && self.canJump) {
+ self.canJump = false;
+ var jumpHeight = Math.random() * 100 + 50;
+ LK.effects.flashObject(self, 0xFFFFFF, 300);
+ self.y -= jumpHeight;
+ LK.setTimeout(function () {
+ self.y += jumpHeight;
+ self.canJump = true;
+ }, 1000);
+ }
+ var shelters = self.getNearbyObjects().filter(function (obj) {
+ return obj instanceof DecorativePlant;
+ });
+ if (shelters.length > 0) {
+ var closestShelter = shelters.reduce(function (closest, shelter) {
+ var distanceToShelter = self.distanceTo(shelter);
+ return distanceToShelter < self.distanceTo(closest) ? shelter : closest;
+ }, shelters[0]);
+ self.targetRotation = Math.atan2(closestShelter.y - self.y, closestShelter.x - self.x);
+ }
+ }
+ return fish.size > self.size && self.distanceTo(fish) < 100;
+ });
+ if (threats.length > 0) {
+ var hidingSpots = self.getNearbyObjects().filter(function (obj) {
+ return obj instanceof DecorativePlant;
+ });
+ if (hidingSpots.length > 0) {
+ var hidingSpot = hidingSpots[Math.floor(Math.random() * hidingSpots.length)];
+ self.targetRotation = Math.atan2(hidingSpot.y - self.y, hidingSpot.x - self.x);
+ }
+ }
+ return fish.isLeader;
+ });
+ if (leaderFish) {
+ var followDistance = 50;
+ var distance = self.distanceTo(leaderFish);
+ if (distance > followDistance) {
+ self.targetRotation = Math.atan2(leaderFish.y - self.y, leaderFish.x - self.x);
+ }
+ }
+ return fish.size > self.size;
+ });
+ if (largerFish.length > 0) {
+ var evadeVector = {
+ x: 0,
+ y: 0
+ };
+ largerFish.forEach(function (fish) {
+ var angle = Math.atan2(self.y - fish.y, self.x - fish.x);
+ evadeVector.x += Math.cos(angle);
+ evadeVector.y += Math.sin(angle);
+ });
+ self.targetRotation = Math.atan2(evadeVector.y, evadeVector.x);
+ }
+ var curiousObjects = self.getNearbyObjects().filter(function (obj) {
+ return !(obj instanceof Food) && !(obj instanceof Fish);
+ });
+ if (curiousObjects.length > 0) {
+ var curiousObject = curiousObjects[Math.floor(Math.random() * curiousObjects.length)];
+ self.targetRotation = Math.atan2(curiousObject.y - self.y, curiousObject.x - self.x);
+ }
+ }
+ var potentialMates = self.getNearbyFish().filter(function (fish) {
+ return fish.constructor === self.constructor && fish !== self && fish.hunger > 50;
+ });
+ if (potentialMates.length > 0) {
+ var mate = potentialMates[Math.floor(Math.random() * potentialMates.length)];
+ self.matingDance(mate);
+ self.isMating = true;
+ mate.isMating = true;
+ }
+ }
+ return obj instanceof InteractiveElement;
+ });
+ if (toys.length > 0 && Math.random() < 0.1) {
+ var toy = toys[Math.floor(Math.random() * toys.length)];
+ self.targetRotation = Math.atan2(toy.y - self.y, toy.x - self.x) + Math.random() * Math.PI - Math.PI / 2;
+ }
+ self.isResting = true;
+ self.targetRotation = Math.PI / 2;
+ self.y = self.getWaterBounds().bottom - 50;
+ }
+ 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;
+ }
+ }
+ return fish.constructor === self.constructor;
+ });
+ if (similarFish.length > 1) {
+ var schoolCenterX = similarFish.reduce((sum, fish) => sum + fish.x, 0) / similarFish.length;
+ var schoolCenterY = similarFish.reduce((sum, fish) => sum + fish.y, 0) / similarFish.length;
+ self.targetRotation = Math.atan2(schoolCenterY - self.y, schoolCenterX - self.x);
+ }
+ var food = self.getNearbyObjects().find(function (obj) {
+ return obj instanceof Food;
+ });
+ if (food) {
+ self.targetRotation = Math.atan2(food.y - self.y, food.x - self.x);
+ }
+ }
self.moveBehavior.update();
var waterBounds = self.getWaterBounds();
if (self.x < waterBounds.left || self.x > waterBounds.right) {
self.x = Math.max(waterBounds.left, Math.min(self.x, waterBounds.right));
@@ -201,8 +323,23 @@
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < 300) {
nearbyFish.push(child);
}
+ var predators = self.getNearbyFish().filter(function (fish) {
+ return fish.size > self.size;
+ });
+ if (predators.length > 0) {
+ var escapeVector = {
+ x: 0,
+ y: 0
+ };
+ predators.forEach(function (predator) {
+ var angle = Math.atan2(self.y - predator.y, self.x - predator.x);
+ escapeVector.x += Math.cos(angle);
+ escapeVector.y += Math.sin(angle);
+ });
+ self.targetRotation = Math.atan2(escapeVector.y, escapeVector.x);
+ }
}
});
return nearbyFish;
};
@@ -984,9 +1121,11 @@
if (!self.directionChangeTime || LK.ticks - self.directionChangeTime > self.directionChangeInterval) {
self.directionChangeTime = LK.ticks;
self.directionChangeInterval = Math.random() * 120 + 60;
if (Math.random() < 0.1) {
- self.targetRotation = Math.random() * Math.PI * 2;
+ var wanderStrength = 0.3;
+ self.targetRotation += (Math.random() * 2 - 1) * wanderStrength;
+ self.targetRotation %= Math.PI * 2;
}
}
var cleaner = self.findNearestCleaner();
if (cleaner && self.distanceTo(cleaner) < 200) {
@@ -1001,9 +1140,13 @@
if (rotationDifference > Math.PI) rotationDifference -= Math.PI * 2;
if (rotationDifference < -Math.PI) rotationDifference += Math.PI * 2;
self.rotation += Math.sign(rotationDifference) * Math.min(Math.abs(rotationDifference), rotationSpeed);
} else {
- self.rotation = self.targetRotation;
+ var rotationSpeed = 0.05;
+ var rotationDifference = self.targetRotation - self.rotation;
+ if (rotationDifference > Math.PI) rotationDifference -= Math.PI * 2;
+ if (rotationDifference < -Math.PI) rotationDifference += Math.PI * 2;
+ self.rotation += Math.sign(rotationDifference) * Math.min(Math.abs(rotationDifference), rotationSpeed);
}
var newX = self.x + Math.cos(self.rotation) * self.speed;
var newY = self.y + Math.sin(self.rotation) * self.speed;
var obstacles = self.getNearbyObstacles();
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.