User prompt
add 2 time more fish
User prompt
Add 10 time more fish
User prompt
Add 5 time more fish
User prompt
improve the ai of all the fish
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'width')' in or related to this line: 'return {' Line Number: 115
User prompt
Please fix the bug: 'TypeError: self.getChildByName is not a function' in or related to this line: 'var waterGraphics = self.getChildByName('Water Graphics');' Line Number: 112
User prompt
Please fix the bug: 'TypeError: this.getChildByName is not a function' in or related to this line: 'var waterGraphics = this.getChildByName('Water Graphics');' Line Number: 112
User prompt
Please fix the bug: 'TypeError: self.getWaterBounds is not a function' in or related to this line: 'var waterBounds = self.getWaterBounds();' Line Number: 156
User prompt
Please fix the bug: 'TypeError: fishes[i]._move_migrated is not a function' in or related to this line: 'fishes[i]._move_migrated();' Line Number: 228
User prompt
Migrate to the latest version of LK
User prompt
Migrate to the latest version of LK
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'attachAsset')' in or related to this line: 'var fishGraphics = self.attachAsset('zebraDanio', {' Line Number: 116
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'attachAsset')' in or related to this line: 'self.fishGraphics = self.attachAsset('zebraDanio', {' Line Number: 116
===================================================================
--- original.js
+++ change.js
@@ -43,62 +43,15 @@
top: (2732 - waterGraphics.height) / 2 - 150,
bottom: (2732 + waterGraphics.height) / 2 - 150
};
};
- self.attachAsset = function (id, options) {
- var asset = LK.getAsset(id, {});
- self.addChild(asset);
- return asset;
- };
- var fishGraphics = self.attachAsset('fish', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.addChild(fishGraphics);
});
-var ZebraDanio = Fish.expand(function () {
- var self = Fish.call(this);
- var fishGraphics = self.attachAsset('zebraDanio', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.addChild(fishGraphics);
- fishGraphics.scale.set(1, 1);
- self.speed = Math.random() * 0.2 + 0.4;
- self._move_migrated = function () {
- if (!self.directionChangeTime || LK.ticks - self.directionChangeTime > self.directionChangeInterval) {
- self.directionChangeTime = LK.ticks;
- self.directionChangeInterval = Math.random() * 90 + 45;
- 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;
- }
- self.x += Math.cos(self.rotation) * self.speed;
- self.y += Math.sin(self.rotation) * self.speed;
- 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;
- }
- self.rotation = self.rotation % (Math.PI * 2);
- fishGraphics.scale.x = Math.cos(self.rotation) < 0 ? -1 : 1;
- fishGraphics.rotation = self.rotation;
- };
- self.addChild(fishGraphics);
-});
var YellowTang = Fish.expand(function () {
var self = Fish.call(this);
var fishGraphics = self.attachAsset('yellowTang', {
anchorX: 0.5,
anchorY: 0.5
});
- self.addChild(fishGraphics);
fishGraphics.scale.set(1, 1);
self.speed = Math.random() * 0.2 + 0.5;
self._move_migrated = function () {};
});
@@ -107,9 +60,8 @@
var fishGraphics = self.attachAsset('wrasses', {
anchorX: 0.5,
anchorY: 0.5
});
- self.addChild(fishGraphics);
fishGraphics.scale.set(1, 1);
self.speed = Math.random() * 0.2 + 0.42;
self._move_migrated = function () {};
});
@@ -118,9 +70,8 @@
var fishGraphics = self.attachAsset('tangfish', {
anchorX: 0.5,
anchorY: 0.5
});
- self.addChild(fishGraphics);
fishGraphics.scale.set(1, 1);
self.speed = Math.random() * 0.2 + 0.47;
self._move_migrated = function () {};
});
@@ -918,27 +869,8 @@
fishGraphics.scale.x = Math.cos(self.rotation) < 0 ? -1 : 1;
fishGraphics.rotation = self.rotation;
};
});
-var CometFish = Fish.expand(function () {
- var self = Fish.call(this);
- var fishGraphics = self.attachAsset('cometFish', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- fishGraphics.scale.set(1, 1);
- self.speed = Math.random() * 0.2 + 0.6;
- self._move_migrated = function () {
- self.x += Math.cos(LK.ticks / 70) * self.speed;
- self.y += Math.sin(LK.ticks / 70) * self.speed;
- var waterBounds = self.getWaterBounds();
- if (self.x < waterBounds.left || self.x > waterBounds.right || self.y < waterBounds.top || self.y > waterBounds.bottom) {
- self.x = Math.max(waterBounds.left, Math.min(self.x, waterBounds.right));
- self.y = Math.max(waterBounds.top, Math.min(self.y, waterBounds.bottom));
- }
- fishGraphics.rotation = Math.atan2(Math.sin(LK.ticks / 70), Math.cos(LK.ticks / 70));
- };
-});
var Clownfish = Fish.expand(function () {
var self = Fish.call(this);
var fishGraphics = self.attachAsset('clownfish', {
anchorX: 0.5,
@@ -985,42 +917,8 @@
fishGraphics.scale.set(1, 1);
self.speed = Math.random() * 0.2 + 0.5;
self._move_migrated = function () {};
});
-var CelestialPearlDanio = Fish.expand(function () {
- var self = Fish.call(this);
- var fishGraphics = self.attachAsset('celestialPearlDanio', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- fishGraphics.scale.set(1, 1);
- self.speed = Math.random() * 0.2 + 0.35;
- self._move_migrated = function () {
- if (!self.directionChangeTime || LK.ticks - self.directionChangeTime > self.directionChangeInterval) {
- self.directionChangeTime = LK.ticks;
- self.directionChangeInterval = Math.random() * 80 + 40;
- 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;
- }
- self.x += Math.cos(self.rotation) * self.speed;
- self.y += Math.sin(self.rotation) * self.speed;
- 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;
- }
- self.rotation = self.rotation % (Math.PI * 2);
- fishGraphics.scale.x = Math.cos(self.rotation) < 0 ? -1 : 1;
- fishGraphics.rotation = self.rotation;
- };
-});
var CardinalTetra = Fish.expand(function () {
var self = Fish.call(this);
var fishGraphics = self.attachAsset('cardinalTetra', {
anchorX: 0.5,
@@ -1194,24 +1092,27 @@
var aquarium = game.addChild(new Aquarium());
game.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();
+for (var i = 0; i < fishTypes.length; i++) {
+ var fish = new fishTypes[i]();
if (typeof fish._move_migrated === '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 = 600;
+ var waterWidth = waterBounds.right - waterBounds.left;
+ var waterHeight = waterBounds.bottom - waterBounds.top;
+ var waterCenterX = waterBounds.left + waterWidth / 2;
+ var waterCenterY = waterBounds.top + waterHeight / 2;
+ var maxDistanceX = waterWidth / 2 * 0.8;
+ var maxDistanceY = waterHeight / 2 * 0.8;
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;
+ var distanceX = Math.random() * maxDistanceX;
+ var distanceY = Math.random() * maxDistanceY;
+ fish.x = waterCenterX + distanceX * Math.cos(angle);
+ fish.y = waterCenterY + distanceY * Math.sin(angle);
fishes.push(fish);
game.addChild(fish);
}
-});
+}
LK.on('tick', function () {
for (var i = 0; i < fishes.length; i++) {
fishes[i]._move_migrated();
}
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.