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
@@ -39,35 +39,193 @@
LK.setInterval(self.feed, self.feedingRate);
self.activate();
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;
+var Fish = Container.expand(function () {
+ var self = Container.call(this);
+ self.speed = 2;
+ self.direction = Math.random() * Math.PI * 2;
+ self.move = function () {
+ var newX = self.x + Math.cos(self.direction) * self.speed;
+ var newY = self.y + Math.sin(self.direction) * self.speed;
+ var bounds = self.getWaterBounds();
+ newX = Math.max(bounds.left, Math.min(newX, bounds.right));
+ newY = Math.max(bounds.top, Math.min(newY, bounds.bottom));
+ self.x = newX;
+ self.y = newY;
+ };
+ self.on('tick', function () {
+ self.move();
+ });
+ 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);
+ self.directionChangeTime = LK.ticks;
+ self.directionChangeInterval = 5;
+ self.rememberObject(otherFish);
+ }
+ };
+ 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);
+ }
+ }
});
- 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];
+ return nearbyObjects;
+ };
+ self.findCuriosityTarget = function () {
+ var possibleTargets = self.getNearbyObjects();
+ if (possibleTargets.length > 0) {
+ self.curiosityTarget = possibleTargets[Math.floor(Math.random() * possibleTargets.length)];
+ }
+ };
+ 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 (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();
+ });
+ 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.on('tick', self.hunt);
- return self;
+ 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
+ };
+ };
});
var HealingPlant = DecorativePlant.expand(function () {
var self = DecorativePlant.call(this) || this;
self.healingRate = 0.05;
@@ -251,194 +409,8 @@
});
return nearbyPredators.length > 0;
};
});
-var Fish = Container.expand(function () {
- var self = Container.call(this);
- self.speed = 2;
- self.direction = Math.random() * Math.PI * 2;
- self.move = function () {
- var newX = self.x + Math.cos(self.direction) * self.speed;
- var newY = self.y + Math.sin(self.direction) * self.speed;
- var bounds = self.getWaterBounds();
- newX = Math.max(bounds.left, Math.min(newX, bounds.right));
- newY = Math.max(bounds.top, Math.min(newY, bounds.bottom));
- self.x = newX;
- self.y = newY;
- };
- self.on('tick', function () {
- self.move();
- });
- 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);
- self.directionChangeTime = LK.ticks;
- self.directionChangeInterval = 5;
- self.rememberObject(otherFish);
- }
- };
- 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);
- }
- }
- });
- return nearbyObjects;
- };
- self.findCuriosityTarget = function () {
- var possibleTargets = self.getNearbyObjects();
- if (possibleTargets.length > 0) {
- self.curiosityTarget = possibleTargets[Math.floor(Math.random() * possibleTargets.length)];
- }
- };
- 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
- };
- };
-});
var Lighting = Container.expand(function () {
var self = Container.call(this);
self.light = 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.