User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'length')' in this line: 'for (var i = 0; i < self.fishes.length; i++) {' Line Number: 145
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'length')' in this line: 'for (var i = 0; i < self.fishes.length; i++) {' Line Number: 145
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'length')' in this line: 'for (var i = 0; i < self.fishes.length; i++) {' Line Number: 145
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'length')' in this line: 'for (var i = 0; i < this.fishes.length; i++) {' Line Number: 145
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'length')' in this line: 'for (var i = 0; i < this.fishes.length; i++) {' Line Number: 1311
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'length')' in this line: 'for (var i = 0; i < this.fishes.length; i++) {' Line Number: 1311
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'push')' in this line: 'this.fishes.push(fish);' Line Number: 1305
User prompt
Fix Bug: 'Uncaught ReferenceError: fishes is not defined' in this line: 'fishes.push(fish);' Line Number: 1305
User prompt
Fix Bug: 'ReferenceError: fishes is not defined' in this line: 'for (var i = 0; i < fishes.length; i++) {' Line Number: 145
User prompt
Fix Bug: 'ReferenceError: fishes is not defined' in this line: 'for (var i = 0; i < fishes.length; i++) {' Line Number: 145
User prompt
Fix Bug: 'ReferenceError: fishes is not defined' in this line: 'for (var i = 0; i < fishes.length; i++) {' Line Number: 145
User prompt
Spawn one of each race
User prompt
Fix Bug: 'Uncaught timeout callback must be a function' in this line: 'var bubbleSpawnTimer = LK.setInterval(self.spawnBubble, 2000);' Line Number: 1277
User prompt
Add 10 new functionality
User prompt
add 10 new functionality
User prompt
spawn only one fish
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'call')' in this line: 'Fish.prototype.move.call(this);' Line Number: 188
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'call')' in this line: 'Fish.prototype.move.call(this);' Line Number: 188
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'call')' in this line: 'Fish.prototype.move.call(this);' Line Number: 188
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'call')' in this line: 'Fish.prototype.move.call(this);' Line Number: 188
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'call')' in this line: 'Fish.prototype.move.call(this);' Line Number: 188
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'call')' in this line: 'Fish.prototype.move.call(this);' Line Number: 188
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'call')' in this line: 'Fish.prototype.move.call(this);' Line Number: 188
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'call')' in this line: 'Fish.prototype.move.call(this);' Line Number: 188
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'call')' in this line: 'Fish.prototype.move.call(this);' Line Number: 188
===================================================================
--- original.js
+++ change.js
@@ -183,91 +183,132 @@
var self = Fish.call(this) || this;
var fishGraphics = self.createAsset('parrotfish', 'Parrotfish Graphics', .5, .5);
fishGraphics.scale.set(1, 1);
self.speed = Math.random() * 0.2 + 0.50;
- self.move = function () {
- Fish.prototype.move.call(this);
- };
+ self.move = function () {};
});
var Dartfish = Fish.expand(function () {
var self = Fish.call(this) || this;
var fishGraphics = self.createAsset('dartfish', 'Dartfish Graphics', .5, .5);
fishGraphics.scale.set(1, 1);
self.speed = Math.random() * 0.2 + 0.45;
- self.move = function () {
- Fish.prototype.move.call(this);
- };
+ self.move = function () {};
});
var MoorishIdol = Fish.expand(function () {
var self = Fish.call(this) || this;
var fishGraphics = self.createAsset('moorishidol', 'Moorish Idol Graphics', .5, .5);
fishGraphics.scale.set(1, 1);
self.speed = Math.random() * 0.2 + 0.43;
- self.move = function () {
- Fish.prototype.move.call(this);
- };
+ self.move = function () {};
});
var Tangfish = Fish.expand(function () {
var self = Fish.call(this) || this;
var fishGraphics = self.createAsset('tangfish', 'Tangfish Graphics', .5, .5);
fishGraphics.scale.set(1, 1);
self.speed = Math.random() * 0.2 + 0.47;
- self.move = function () {
- Fish.prototype.move.call(this);
- };
+ self.move = function () {};
});
var Bannerfish = Fish.expand(function () {
var self = Fish.call(this) || this;
var fishGraphics = self.createAsset('bannerfish', 'Bannerfish Graphics', .5, .5);
fishGraphics.scale.set(1, 1);
self.speed = Math.random() * 0.2 + 0.46;
- self.move = function () {
- Fish.prototype.move.call(this);
- };
+ self.move = function () {};
});
var Butterflyfish = Fish.expand(function () {
var self = Fish.call(this) || this;
var fishGraphics = self.createAsset('butterflyfish', 'Butterflyfish Graphics', .5, .5);
fishGraphics.scale.set(1, 1);
self.speed = Math.random() * 0.2 + 0.45;
- self.move = function () {
- Fish.prototype.move.call(this);
- };
+ self.move = function () {};
});
var Mandarinfish = Fish.expand(function () {
var self = Fish.call(this) || this;
var fishGraphics = self.createAsset('mandarinfish', 'Mandarinfish Graphics', .5, .5);
fishGraphics.scale.set(1, 1);
self.speed = (Math.random() * 0.2 + 0.4) * 2;
- self.move = function () {
- Fish.prototype.move.call(this);
- };
+ self.move = function () {};
});
var Lionfish = Fish.expand(function () {
var self = Fish.call(this) || this;
var fishGraphics = self.createAsset('lionfish', 'Lionfish Graphics', .5, .5);
fishGraphics.scale.set(1, 1);
self.speed = Math.random() * 0.2 + 0.5;
self.move = function () {
- Fish.prototype.move.call(self);
+ fishGraphics.rotation = self.rotation;
};
});
var Surgeonfish = Fish.expand(function () {
var self = Fish.call(this) || this;
var fishGraphics = self.createAsset('surgeonfish', 'Surgeonfish Graphics', .5, .5);
fishGraphics.scale.set(1, 1);
self.speed = (Math.random() * 0.2 + 0.5) * 2 * 2 * 2;
self.move = function () {
- Fish.prototype.move.call(this);
+ if (!self.directionChangeTime || LK.ticks - self.directionChangeTime > self.directionChangeInterval) {
+ self.directionChangeTime = LK.ticks;
+ self.directionChangeInterval = Math.random() * 120 + 60;
+ self.targetRotation = Math.random() * Math.PI * 2;
+ }
+ var progress = (LK.ticks - self.directionChangeTime) / self.directionChangeInterval;
+ if (progress < 1) {
+ self.rotation += (self.targetRotation - self.rotation) * progress;
+ } else {
+ self.rotation = self.targetRotation;
+ }
+ var newX = self.x + Math.cos(self.rotation) * self.speed;
+ var newY = self.y + Math.sin(self.rotation) * self.speed;
+ var obstacles = self.getNearbyObstacles();
+ if (self.isPathBlocked(newX, newY, obstacles)) {
+ self.avoidObstacles(obstacles);
+ } else {
+ self.x = newX;
+ self.y = newY;
+ }
+ var waterBounds = self.getWaterBounds();
+ var centerX = (waterBounds.left + waterBounds.right) / 2;
+ var centerY = (waterBounds.top + waterBounds.bottom) / 2;
+ if (self.x < waterBounds.left || self.x > waterBounds.right || self.y < waterBounds.top || self.y > waterBounds.bottom) {
+ self.x = centerX;
+ self.y = centerY;
+ }
+ fishGraphics.scale.x = Math.cos(self.rotation) < 0 ? -1 : 1;
+ fishGraphics.rotation = self.rotation;
};
});
var Pufferfish = Fish.expand(function () {
var self = Fish.call(this) || this;
var fishGraphics = self.createAsset('pufferfish', 'Pufferfish Graphics', .5, .5);
fishGraphics.scale.set(1, 1);
self.speed = (Math.random() * 0.2 + 0.4) * 2 * 2;
self.move = function () {
- Fish.prototype.move.call(this);
+ if (!self.directionChangeTime || LK.ticks - self.directionChangeTime > self.directionChangeInterval) {
+ self.directionChangeTime = LK.ticks;
+ self.directionChangeInterval = Math.random() * 140 + 80;
+ self.targetRotation = Math.random() * Math.PI * 2;
+ }
+ var progress = (LK.ticks - self.directionChangeTime) / self.directionChangeInterval;
+ if (progress < 1) {
+ self.rotation += (self.targetRotation - self.rotation) * progress;
+ } else {
+ self.rotation = self.targetRotation;
+ }
+ var tentativeX = self.x + Math.cos(self.rotation) * self.speed;
+ var tentativeY = self.y + Math.sin(self.rotation) * self.speed;
+ var waterBounds = self.getWaterBounds();
+ tentativeX = Math.max(waterBounds.left, Math.min(tentativeX, waterBounds.right));
+ tentativeY = Math.max(waterBounds.top, Math.min(tentativeY, waterBounds.bottom));
+ var waterBounds = self.getWaterBounds();
+ self.x = Math.max(waterBounds.left, Math.min(tentativeX, waterBounds.right));
+ self.y = Math.max(waterBounds.top, Math.min(tentativeY, waterBounds.bottom));
+ var waterBounds = self.getWaterBounds();
+ if (self.x < waterBounds.left || self.x > waterBounds.right) {
+ self.rotation = Math.PI - self.rotation;
+ }
+ if (self.y < waterBounds.top || self.y > waterBounds.bottom) {
+ self.rotation = -self.rotation;
+ }
+ fishGraphics.scale.x = Math.cos(self.rotation) < 0 ? -1 : 1;
+ fishGraphics.rotation = self.rotation;
};
});
var Clownfish = Fish.expand(function () {
var self = Fish.call(this) || this;
@@ -1085,23 +1126,23 @@
LK.stageContainer.setBackgroundColor(0x008080);
var fishes = [];
var fishTypes = [Wrasses, Parrotfish, Dartfish, MoorishIdol, Tangfish, Bannerfish, Butterflyfish, Mandarinfish, Lionfish, Surgeonfish, Pufferfish, Clownfish, Angelfish, KoiFish, EmperorFish, Goldfish, Sunfish, GuppyFish, BettaFish, DiscusFish, NeonTetra, OscarFish, PsychedelicFrogfish, FlameScallop, RibbonEel, LeafySeaDragon, ClownTriggerfish, ElectricBlueDamsel, YellowTang, FlameHawkfish, RoyalGramma, FlameAngel, BlueTang, Moonfish, Starfish, CardinalTetra];
var fishTypes = [ZebraDanio, CelestialPearlDanio, Wrasses, Parrotfish, Dartfish, MoorishIdol, Tangfish, Bannerfish, Butterflyfish, Mandarinfish, Lionfish, Surgeonfish, Pufferfish, Clownfish, Angelfish, KoiFish, EmperorFish, Goldfish, Sunfish, GuppyFish, BettaFish, DiscusFish, NeonTetra, OscarFish, ElectricCatfish, RainbowTrout, PsychedelicFrogfish, FlameScallop, RibbonEel, LeafySeaDragon, ClownTriggerfish, ElectricBlueDamsel, YellowTang, FlameHawkfish, RoyalGramma, FlameAngel, BlueTang, Moonfish, Starfish, GlassCatfish, DiamondTetra, PeacockBass, CrimsonSnapper, CardinalTetra, CometFish, EmeraldGoby];
- fishTypes.forEach(function (fishType) {
- var fish = new fishType();
- if (typeof fish.move === 'function') {
- var waterBounds = aquarium.getWaterBounds();
- var centerX = waterBounds.left + (waterBounds.right - waterBounds.left) / 2;
- var centerY = waterBounds.top + (waterBounds.bottom - waterBounds.top) / 2;
- var maxDistance = 500;
- var angle = Math.random() * Math.PI * 2;
- var distance = Math.random() * maxDistance;
- fish.x = centerX + Math.cos(angle) * distance;
- fish.y = centerY + Math.sin(angle) * distance;
- fishes.push(fish);
- self.addChild(fish);
- }
- });
+ var randomFishIndex = Math.floor(Math.random() * fishTypes.length);
+ var fishType = fishTypes[randomFishIndex];
+ var fish = new fishType();
+ if (typeof fish.move === 'function') {
+ var waterBounds = aquarium.getWaterBounds();
+ var centerX = waterBounds.left + (waterBounds.right - waterBounds.left) / 2;
+ var centerY = waterBounds.top + (waterBounds.bottom - waterBounds.top) / 2;
+ var maxDistance = 500;
+ var angle = Math.random() * Math.PI * 2;
+ var distance = Math.random() * maxDistance;
+ fish.x = centerX + Math.cos(angle) * distance;
+ fish.y = centerY + Math.sin(angle) * distance;
+ fishes.push(fish);
+ self.addChild(fish);
+ }
LK.on('tick', function () {
for (var i = 0; i < fishes.length; i++) {
fishes[i].move();
}
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.