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
/**** * Classes ****/ var Aquarium = Container.expand(function () { var self = Container.call(this); this.getWaterBounds = function () { var waterGraphics = LK.getAsset('water', {}); return { left: (2048 - waterGraphics.width) / 2, right: (2048 + waterGraphics.width) / 2, top: (2732 - waterGraphics.height) / 2 - 150, bottom: (2732 + waterGraphics.height) / 2 - 150 }; }; var aquariumGraphics = self.attachAsset('aquarium', {}); aquariumGraphics.width = 2048 * 1.3; aquariumGraphics.height = 2732 * 1.3; aquariumGraphics.x = (2048 - aquariumGraphics.width) / 2; aquariumGraphics.y = (2732 - aquariumGraphics.height) / 2; self.addChild(aquariumGraphics); var waterGraphics = self.attachAsset('water', {}); waterGraphics.width = 2048 / 3 * 2 * 1.08; waterGraphics.height = 2732 / 3 * 1.26; waterGraphics.x = (2048 - waterGraphics.width) / 2; waterGraphics.y = (2732 - waterGraphics.height) / 2 - 150; waterGraphics.alpha = 0; self.addChild(waterGraphics); }); var Fish = Container.expand(function () { var self = Container.call(this); self.avoidObstacles = function (obstacles) {}; self.isPathBlocked = function (newX, newY, obstacles) { return false; }; self.getNearbyObstacles = function () { return []; }; this.getWaterBounds = function () { var waterGraphics = LK.getAsset('water', {}); return { left: (2048 - waterGraphics.width) / 2, right: (2048 + waterGraphics.width) / 2, top: (2732 - waterGraphics.height) / 2 - 150, bottom: (2732 + waterGraphics.height) / 2 - 150 }; }; }); var YellowTang = Fish.expand(function () { var self = Fish.call(this); var fishGraphics = self.attachAsset('yellowTang', { anchorX: 0.5, anchorY: 0.5 }); fishGraphics.scale.set(1, 1); self.speed = Math.random() * 0.2 + 0.5; self._move_migrated = function () {}; }); var Wrasses = Fish.expand(function () { var self = Fish.call(this); var fishGraphics = self.attachAsset('wrasses', { anchorX: 0.5, anchorY: 0.5 }); fishGraphics.scale.set(1, 1); self.speed = Math.random() * 0.2 + 0.42; self._move_migrated = function () {}; }); var Tangfish = Fish.expand(function () { var self = Fish.call(this); var fishGraphics = self.attachAsset('tangfish', { anchorX: 0.5, anchorY: 0.5 }); fishGraphics.scale.set(1, 1); self.speed = Math.random() * 0.2 + 0.47; self._move_migrated = function () {}; }); var Surgeonfish = Fish.expand(function () { var self = Fish.call(this); var fishGraphics = self.attachAsset('surgeonfish', { anchorX: 0.5, anchorY: 0.5 }); fishGraphics.scale.set(1, 1); self.speed = (Math.random() * 0.2 + 0.5) * 2; self._move_migrated = function () { 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(); 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 Sunfish = Fish.expand(function () { var self = Fish.call(this); var fishGraphics = self.attachAsset('sunfish', { anchorX: 0.5, anchorY: 0.5 }); fishGraphics.scale.set(1, 1); self.speed = Math.random() * 0.2 + 0.6; self._move_migrated = function () { if (!self.directionChangeTime || LK.ticks - self.directionChangeTime > self.directionChangeInterval) { self.directionChangeTime = LK.ticks; self.directionChangeInterval = Math.random() * 200 + 100; 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 Starfish = Fish.expand(function () { var self = Fish.call(this); var fishGraphics = self.attachAsset('starfish', { anchorX: 0.5, anchorY: 0.5 }); fishGraphics.scale.set(1, 1); self.speed = Math.random() * 0.2 + 0.5; self._move_migrated = function () { self.x += Math.sin(LK.ticks / 30) * self.speed; self.y += Math.cos(LK.ticks / 30) * 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 = LK.ticks / 30; }; }); var RoyalGramma = Fish.expand(function () { var self = Fish.call(this); var fishGraphics = self.attachAsset('royalGramma', { anchorX: 0.5, anchorY: 0.5 }); fishGraphics.scale.set(1, 1); self.speed = Math.random() * 0.2 + 0.5; self._move_migrated = function () { if (!self.directionChangeTime || LK.ticks - self.directionChangeTime > self.directionChangeInterval) { self.directionChangeTime = LK.ticks; self.directionChangeInterval = Math.random() * 160 + 100; 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 RibbonEel = Fish.expand(function () { var self = Fish.call(this); var fishGraphics = self.attachAsset('ribbonEel', { anchorX: 0.5, anchorY: 0.5 }); fishGraphics.scale.set(1, 1); self.speed = Math.random() * 0.2 + 0.6; self._move_migrated = function () {}; }); var RainbowTrout = Fish.expand(function () { var self = Fish.call(this); var fishGraphics = self.attachAsset('rainbowTrout', { anchorX: 0.5, anchorY: 0.5 }); fishGraphics.scale.set(1, 1); self.speed = Math.random() * 0.2 + 0.53; self._move_migrated = function () { if (!self.directionChangeTime || LK.ticks - self.directionChangeTime > self.directionChangeInterval) { self.directionChangeTime = LK.ticks; self.directionChangeInterval = Math.random() * 160 + 120; 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 Pufferfish = Fish.expand(function () { var self = Fish.call(this); var fishGraphics = self.attachAsset('pufferfish', { anchorX: 0.5, anchorY: 0.5 }); 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() * 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)); self.x = tentativeX; self.y = tentativeY; 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 PsychedelicFrogfish = Fish.expand(function () { var self = Fish.call(this); var fishGraphics = self.attachAsset('psychedelicFrogfish', { anchorX: 0.5, anchorY: 0.5 }); fishGraphics.scale.set(1, 1); self.speed = Math.random() * 0.2 + 0.4; self._move_migrated = function () {}; }); var PeacockBass = Fish.expand(function () { var self = Fish.call(this); var fishGraphics = self.attachAsset('peacockBass', { anchorX: 0.5, anchorY: 0.5 }); fishGraphics.scale.set(1, 1); self.speed = Math.random() * 0.2 + 0.65; self._move_migrated = function () { if (!self.directionChangeTime || LK.ticks - self.directionChangeTime > self.directionChangeInterval) { self.directionChangeTime = LK.ticks; self.directionChangeInterval = Math.random() * 220 + 160; 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 * 1.6; self.y += Math.sin(self.rotation) * self.speed * 1.6; 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 Parrotfish = Fish.expand(function () { var self = Fish.call(this); var fishGraphics = self.attachAsset('parrotfish', { anchorX: 0.5, anchorY: 0.5 }); fishGraphics.scale.set(1, 1); self.speed = Math.random() * 0.2 + 0.50; self._move_migrated = function () {}; }); var OscarFish = Fish.expand(function () { var self = Fish.call(this); var fishGraphics = self.attachAsset('oscarFish', { anchorX: 0.5, anchorY: 0.5 }); fishGraphics.scale.set(1, 1); self.speed = Math.random() * 0.2 + 0.5; self._move_migrated = function () { if (self.targetRotation === undefined || LK.ticks - self.rotationStartTime >= self.rotationDuration) { self.targetRotation = Math.random() * Math.PI * 2; self.rotationStartTime = LK.ticks; self.rotationDuration = Math.random() * 150 + 100; } var progress = (LK.ticks - self.rotationStartTime) / self.rotationDuration; if (progress < 1) { var deltaRotation = (self.targetRotation - self.rotation) * progress; self.rotation += deltaRotation; } 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); if (Math.cos(self.rotation) < 0) { fishGraphics.scale.x = -1; } else { fishGraphics.scale.x = 1; } fishGraphics.rotation = self.rotation; }; }); var NeonTetra = Fish.expand(function () { var self = Fish.call(this); var fishGraphics = self.attachAsset('neonTetra', { anchorX: 0.5, anchorY: 0.5 }); fishGraphics.scale.set(1, 1); self.speed = Math.random() * 0.2 + 0.3; self._move_migrated = function () { if (self.targetRotation === undefined || LK.ticks - self.rotationStartTime >= self.rotationDuration) { self.targetRotation = Math.random() * Math.PI * 2; self.rotationStartTime = LK.ticks; self.rotationDuration = Math.random() * 100 + 50; } var progress = (LK.ticks - self.rotationStartTime) / self.rotationDuration; if (progress < 1) { var deltaRotation = (self.targetRotation - self.rotation) * progress; self.rotation += deltaRotation; } 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); if (Math.cos(self.rotation) < 0) { fishGraphics.scale.x = -1; } else { fishGraphics.scale.x = 1; } fishGraphics.rotation = self.rotation; }; }); var MoorishIdol = Fish.expand(function () { var self = Fish.call(this); var fishGraphics = self.attachAsset('moorishidol', { anchorX: 0.5, anchorY: 0.5 }); fishGraphics.scale.set(1, 1); self.speed = Math.random() * 0.2 + 0.43; self._move_migrated = function () {}; }); var Moonfish = Fish.expand(function () { var self = Fish.call(this); var fishGraphics = self.attachAsset('moonfish', { anchorX: 0.5, anchorY: 0.5 }); fishGraphics.scale.set(1, 1); self.speed = Math.random() * 0.2 + 0.55; self._move_migrated = function () { self.x += Math.cos(LK.ticks / 60) * self.speed; self.y += Math.sin(LK.ticks / 60) * 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 / 60), Math.cos(LK.ticks / 60)); }; }); var Mandarinfish = Fish.expand(function () { var self = Fish.call(this); var fishGraphics = self.attachAsset('mandarinfish', { anchorX: 0.5, anchorY: 0.5 }); fishGraphics.scale.set(1, 1); self.speed = Math.random() * 0.2 + 0.4; self._move_migrated = function () {}; }); var Lionfish = Fish.expand(function () { var self = Fish.call(this); var fishGraphics = self.attachAsset('lionfish', { anchorX: 0.5, anchorY: 0.5 }); fishGraphics.scale.set(1, 1); self.speed = Math.random() * 0.2 + 0.5; self._move_migrated = function () {}; }); var LeafySeaDragon = Fish.expand(function () { var self = Fish.call(this); var fishGraphics = self.attachAsset('leafySeaDragon', { anchorX: 0.5, anchorY: 0.5 }); fishGraphics.scale.set(1, 1); self.speed = Math.random() * 0.2 + 0.4; self._move_migrated = function () {}; }); var KoiFish = Fish.expand(function () { var self = Fish.call(this); var fishGraphics = self.attachAsset('koiFish', { anchorX: 0.5, anchorY: 0.5 }); fishGraphics.scale.set(1, 1); self.speed = Math.random() * 0.2 + 0.48; self._move_migrated = function () { if (self.targetRotation === undefined || LK.ticks - self.rotationStartTime >= self.rotationDuration) { self.targetRotation = Math.random() * Math.PI * 2; self.rotationStartTime = LK.ticks; self.rotationDuration = Math.random() * 130 + 70; } var progress = (LK.ticks - self.rotationStartTime) / self.rotationDuration; if (progress < 1) { var deltaRotation = (self.targetRotation - self.rotation) * progress; self.rotation += deltaRotation; } 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); if (Math.cos(self.rotation) < 0) { fishGraphics.scale.x = -1; } else { fishGraphics.scale.x = 1; } fishGraphics.rotation = self.rotation; }; }); var GuppyFish = Fish.expand(function () { var self = Fish.call(this); var fishGraphics = self.attachAsset('guppyFish', { 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.targetRotation === undefined || LK.ticks - self.rotationStartTime >= self.rotationDuration) { self.targetRotation = Math.random() * Math.PI * 2; self.rotationStartTime = LK.ticks; self.rotationDuration = Math.random() * 100 + 50; } var progress = (LK.ticks - self.rotationStartTime) / self.rotationDuration; if (progress < 1) { var deltaRotation = (self.targetRotation - self.rotation) * progress; self.rotation += deltaRotation; } 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); if (Math.cos(self.rotation) < 0) { fishGraphics.scale.x = -1; } else { fishGraphics.scale.x = 1; } fishGraphics.rotation = self.rotation; }; }); var Goldfish = Fish.expand(function () { var self = Fish.call(this); var fishGraphics = self.attachAsset('goldfish', { anchorX: 0.5, anchorY: 0.5 }); fishGraphics.scale.set(1, 1); self.speed = Math.random() * 0.2 + 0.4; self._move_migrated = function () { if (self.targetRotation === undefined || LK.ticks - self.rotationStartTime >= self.rotationDuration) { self.targetRotation = Math.random() * Math.PI * 2; self.rotationStartTime = LK.ticks; self.rotationDuration = Math.random() * 140 + 80; } var progress = (LK.ticks - self.rotationStartTime) / self.rotationDuration; if (progress < 1) { var deltaRotation = (self.targetRotation - self.rotation) * progress; self.rotation += deltaRotation; } 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); if (Math.cos(self.rotation) < 0) { fishGraphics.scale.x = -1; } else { fishGraphics.scale.x = 1; } fishGraphics.rotation = self.rotation; }; }); var GlassCatfish = Fish.expand(function () { var self = Fish.call(this); var fishGraphics = self.attachAsset('glassCatfish', { anchorX: 0.5, anchorY: 0.5 }); fishGraphics.scale.set(1, 1); self.speed = Math.random() * 0.2 + 0.45; self._move_migrated = function () { self.x += Math.cos(LK.ticks / 100) * self.speed; self.y += Math.sin(LK.ticks / 100) * 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 / 100), Math.cos(LK.ticks / 100)); }; }); var FlameScallop = Fish.expand(function () { var self = Fish.call(this); var fishGraphics = self.attachAsset('flameScallop', { anchorX: 0.5, anchorY: 0.5 }); fishGraphics.scale.set(1, 1); self.speed = Math.random() * 0.2 + 0.3; self._move_migrated = function () {}; }); var FlameHawkfish = Fish.expand(function () { var self = Fish.call(this); var fishGraphics = self.attachAsset('flameHawkfish', { anchorX: 0.5, anchorY: 0.5 }); fishGraphics.scale.set(1, 1); self.speed = Math.random() * 0.2 + 0.48; self._move_migrated = function () {}; }); var FlameAngel = Fish.expand(function () { var self = Fish.call(this); var fishGraphics = self.attachAsset('flameAngel', { anchorX: 0.5, anchorY: 0.5 }); fishGraphics.scale.set(1, 1); self.speed = Math.random() * 0.2 + 0.55; self._move_migrated = function () { if (!self.directionChangeTime || LK.ticks - self.directionChangeTime > self.directionChangeInterval) { self.directionChangeTime = LK.ticks; self.directionChangeInterval = Math.random() * 170 + 90; 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 EmperorFish = Fish.expand(function () { var self = Fish.call(this); var fishGraphics = self.attachAsset('emperorFish', { anchorX: 0.5, anchorY: 0.5 }); fishGraphics.scale.set(1, 1); self.speed = Math.random() * 0.2 + 0.5; self._move_migrated = function () {}; }); var EmeraldGoby = Fish.expand(function () { var self = Fish.call(this); var fishGraphics = self.attachAsset('emeraldGoby', { anchorX: 0.5, anchorY: 0.5 }); fishGraphics.scale.set(1, 1); self.speed = Math.random() * 0.2 + 0.42; self._move_migrated = function () { if (!self.directionChangeTime || LK.ticks - self.directionChangeTime > self.directionChangeInterval) { self.directionChangeTime = LK.ticks; self.directionChangeInterval = Math.random() * 110 + 55; 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 ElectricCatfish = Fish.expand(function () { var self = Fish.call(this); var fishGraphics = self.attachAsset('electricCatfish', { anchorX: 0.5, anchorY: 0.5 }); fishGraphics.scale.set(1, 1); self.speed = Math.random() * 0.2 + 0.58; self._move_migrated = function () { if (!self.directionChangeTime || LK.ticks - self.directionChangeTime > self.directionChangeInterval) { self.directionChangeTime = LK.ticks; self.directionChangeInterval = Math.random() * 190 + 130; 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 ElectricBlueDamsel = Fish.expand(function () { var self = Fish.call(this); var fishGraphics = self.attachAsset('electricBlueDamsel', { anchorX: 0.5, anchorY: 0.5 }); fishGraphics.scale.set(1, 1); self.speed = Math.random() * 0.2 + 0.45; self._move_migrated = function () {}; }); var DiscusFish = Fish.expand(function () { var self = Fish.call(this); var fishGraphics = self.attachAsset('discusFish', { anchorX: 0.5, anchorY: 0.5 }); fishGraphics.scale.set(1, 1); self.speed = Math.random() * 0.2 + 0.45; self._move_migrated = function () { if (self.targetRotation === undefined || LK.ticks - self.rotationStartTime >= self.rotationDuration) { self.targetRotation = Math.random() * Math.PI * 2; self.rotationStartTime = LK.ticks; self.rotationDuration = Math.random() * 120 + 60; } var progress = (LK.ticks - self.rotationStartTime) / self.rotationDuration; if (progress < 1) { var deltaRotation = (self.targetRotation - self.rotation) * progress; self.rotation += deltaRotation; } 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); if (Math.cos(self.rotation) < 0) { fishGraphics.scale.x = -1; } else { fishGraphics.scale.x = 1; } fishGraphics.rotation = self.rotation; }; }); var DiamondTetra = Fish.expand(function () { var self = Fish.call(this); var fishGraphics = self.attachAsset('diamondTetra', { anchorX: 0.5, anchorY: 0.5 }); 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() * 100 + 50; 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 Dartfish = Fish.expand(function () { var self = Fish.call(this); var fishGraphics = self.attachAsset('dartfish', { anchorX: 0.5, anchorY: 0.5 }); fishGraphics.scale.set(1, 1); self.speed = Math.random() * 0.2 + 0.45; self._move_migrated = function () {}; }); var CrimsonSnapper = Fish.expand(function () { var self = Fish.call(this); var fishGraphics = self.attachAsset('crimsonSnapper', { anchorX: 0.5, anchorY: 0.5 }); fishGraphics.scale.set(1, 1); self.speed = Math.random() * 0.2 + 0.57; self._move_migrated = function () { if (!self.directionChangeTime || LK.ticks - self.directionChangeTime > self.directionChangeInterval) { self.directionChangeTime = LK.ticks; self.directionChangeInterval = Math.random() * 130 + 65; 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 Clownfish = Fish.expand(function () { var self = Fish.call(this); var fishGraphics = self.attachAsset('clownfish', { anchorX: 0.5, anchorY: 0.5 }); 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() * 110 + 70; 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 * 2; var tentativeY = self.y + Math.sin(self.rotation) * self.speed * 2; var waterBounds = self.getWaterBounds(); tentativeX = Math.max(waterBounds.left, Math.min(tentativeX, waterBounds.right)); tentativeY = Math.max(waterBounds.top, Math.min(tentativeY, waterBounds.bottom)); self.x = tentativeX; self.y = tentativeY; 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 ClownTriggerfish = Fish.expand(function () { var self = Fish.call(this); var fishGraphics = self.attachAsset('clownTriggerfish', { anchorX: 0.5, anchorY: 0.5 }); fishGraphics.scale.set(1, 1); self.speed = Math.random() * 0.2 + 0.5; self._move_migrated = function () {}; }); var CardinalTetra = Fish.expand(function () { var self = Fish.call(this); var fishGraphics = self.attachAsset('cardinalTetra', { anchorX: 0.5, anchorY: 0.5 }); fishGraphics.scale.set(1, 1); self.speed = Math.random() * 0.2 + 0.3; self._move_migrated = function () { if (!self.directionChangeTime || LK.ticks - self.directionChangeTime > self.directionChangeInterval) { self.directionChangeTime = LK.ticks; self.directionChangeInterval = Math.random() * 90 + 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; } 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 Butterflyfish = Fish.expand(function () { var self = Fish.call(this); var fishGraphics = self.attachAsset('butterflyfish', { anchorX: 0.5, anchorY: 0.5 }); fishGraphics.scale.set(1, 1); self.speed = Math.random() * 0.2 + 0.45; self._move_migrated = function () {}; }); var BlueTang = Fish.expand(function () { var self = Fish.call(this); var fishGraphics = self.attachAsset('blueTang', { anchorX: 0.5, anchorY: 0.5 }); fishGraphics.scale.set(1, 1); self.speed = Math.random() * 0.2 + 0.52; self._move_migrated = function () { if (!self.directionChangeTime || LK.ticks - self.directionChangeTime > self.directionChangeInterval) { self.directionChangeTime = LK.ticks; self.directionChangeInterval = Math.random() * 150 + 110; 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 BettaFish = Fish.expand(function () { var self = Fish.call(this); var fishGraphics = self.attachAsset('bettaFish', { anchorX: 0.5, anchorY: 0.5 }); fishGraphics.scale.set(1, 1); self.speed = Math.random() * 0.2 + 0.5; self._move_migrated = function () { if (self.targetRotation === undefined || LK.ticks - self.rotationStartTime >= self.rotationDuration) { self.targetRotation = Math.random() * Math.PI * 2; self.rotationStartTime = LK.ticks; self.rotationDuration = Math.random() * 150 + 100; } var progress = (LK.ticks - self.rotationStartTime) / self.rotationDuration; if (progress < 1) { var deltaRotation = (self.targetRotation - self.rotation) * progress; self.rotation += deltaRotation; } 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); if (Math.cos(self.rotation) < 0) { fishGraphics.scale.x = -1; } else { fishGraphics.scale.x = 1; } fishGraphics.rotation = self.rotation; }; }); var Bannerfish = Fish.expand(function () { var self = Fish.call(this); var fishGraphics = self.attachAsset('bannerfish', { anchorX: 0.5, anchorY: 0.5 }); fishGraphics.scale.set(1, 1); self.speed = Math.random() * 0.2 + 0.46; self._move_migrated = function () {}; }); var Angelfish = Fish.expand(function () { var self = Fish.call(this); var fishGraphics = self.attachAsset('angelfish', { anchorX: 0.5, anchorY: 0.5 }); fishGraphics.scale.set(1, 1); self.speed = Math.random() * 0.2 + 0.45; self._move_migrated = function () { if (!self.directionChangeTime || LK.ticks - self.directionChangeTime > self.directionChangeInterval) { self.directionChangeTime = LK.ticks; self.directionChangeInterval = Math.random() * 130 + 90; 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; } fishGraphics.scale.x = Math.cos(self.rotation) < 0 ? -1 : 1; fishGraphics.rotation = self.rotation; }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ 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]; for (var i = 0; i < fishTypes.length; i++) { var fish = new fishTypes[i](); if (typeof fish._move_migrated === 'function') { var waterBounds = aquarium.getWaterBounds(); 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 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(); } });
===================================================================
--- 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.