User prompt
fish cant swin out of water
User prompt
imprtove fish Ai with 10 new functionality
User prompt
imprtove fish Ai with 5 new functionality
User prompt
imprtove fish Ai with 10 new functionality
User prompt
imprtove fish Ai with 5 new functionality
User prompt
Fix Bug: 'ReferenceError: largerFish is not defined' in this line: 'return false;' Line Number: 48
User prompt
Fix Bug: 'ReferenceError: food is not defined' in this line: 'if (food) {' Line Number: 99
User prompt
Fix Bug: 'ReferenceError: partner is not defined' in this line: 'if (partner) {' Line Number: 99
User prompt
Fix Bug: 'TypeError: self.getLargerFish is not a function' in this line: 'var largerFish = self.getLargerFish(nearbyFish);' Line Number: 99
User prompt
Fix Bug: 'TypeError: self.getNearbyFish is not a function' in this line: 'var nearbyFish = self.getNearbyFish();' Line Number: 84
User prompt
Fix Bug: 'TypeError: self.getVisibleFood is not a function' in this line: 'var food = self.getVisibleFood();' Line Number: 83
User prompt
Fix Bug: 'TypeError: self.findReproductionPartner is not a function' in this line: 'var partner = self.findReproductionPartner();' Line Number: 83
User prompt
imprtove fish Ai with 4 new functionality
User prompt
make movement more realistic base on real fish
User prompt
Fix Bug: 'ReferenceError: Obstacle is not defined' in this line: 'if (child instanceof Obstacle) {' Line Number: 35
User prompt
Fix Bug: 'ReferenceError: Obstacle is not defined' in this line: 'if (child instanceof Obstacle) {' Line Number: 35
User prompt
make AI more realistic
User prompt
improve fish AI
User prompt
make water totaly transparent
User prompt
kemm all fish normal size ratio
User prompt
double fish size
User prompt
double all fish size
User prompt
reevert all fish normal size ratio
User prompt
revert all fish to their normal size
User prompt
all fish cant swim out of the water area and all fish swim 2 time faster
var Fish = Container.expand(function () { var self = Container.call(this); self.avoidObstacles = function (obstacles) { if (obstacles.length > 0) { var obstacle = obstacles[0]; var angleToObstacle = Math.atan2(obstacle.y - self.y, obstacle.x - self.x); var avoidAngle = angleToObstacle + Math.PI; self.targetRotation = avoidAngle; self.directionChangeTime = LK.ticks; self.directionChangeInterval = 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; }; self.getNearbyObstacles = function () { var obstacles = []; return obstacles; }; 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 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; self.move = 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 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; self.move = 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 Clownfish = Fish.expand(function () { var self = Fish.call(this) || this; var fishGraphics = self.createAsset('clownfish', 'Clownfish Graphics', .5, .5); fishGraphics.scale.set(1, 1); self.speed = Math.random() * 0.2 + 0.4; self.move = 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 Angelfish = Fish.expand(function () { var self = Fish.call(this) || this; var fishGraphics = self.createAsset('angelfish', 'Angelfish Graphics', .5, .5); fishGraphics.scale.set(1, 1); self.speed = Math.random() * 0.2 + 0.45; self.move = 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; }; }); var Aquarium = Container.expand(function () { var self = Container.call(this); 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 aquariumGraphics = self.createAsset('aquarium', 'Aquarium Background', 0, 0); 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.createAsset('water', 'Water Graphics', 0, 0); 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 KoiFish = Fish.expand(function () { var self = Fish.call(this) || this; var fishGraphics = self.createAsset('koiFish', 'Koi Fish Graphics', .5, .5); fishGraphics.scale.set(1, 1); self.speed = Math.random() * 0.2 + 0.48; self.move = 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 Goldfish = Fish.expand(function () { var self = Fish.call(this) || this; var fishGraphics = self.createAsset('goldfish', 'Goldfish Graphics', .5, .5); fishGraphics.scale.set(1, 1); self.speed = Math.random() * 0.2 + 0.4; self.move = 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 GuppyFish = Fish.expand(function () { var self = Fish.call(this) || this; var fishGraphics = self.createAsset('guppyFish', 'Guppy Fish Graphics', .5, .5); fishGraphics.scale.set(1, 1); self.speed = Math.random() * 0.2 + 0.35; self.move = 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 BettaFish = Fish.expand(function () { var self = Fish.call(this) || this; var fishGraphics = self.createAsset('bettaFish', 'Betta Fish Graphics', .5, .5); fishGraphics.scale.set(1, 1); self.speed = Math.random() * 0.2 + 0.5; self.move = 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 Game = Container.expand(function () { var self = Container.call(this); var aquarium = self.addChild(new Aquarium()); LK.stageContainer.setBackgroundColor(0x008080); var fishes = []; var fishTypes = [Fish, KoiFish, Goldfish, GuppyFish, BettaFish, Angelfish, Clownfish, Pufferfish, Surgeonfish]; for (var i = 0; i < fishTypes.length; i++) { for (var j = 0; j < 1; j++) { var fish = new fishTypes[i](); if (typeof fish.move === '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); self.addChild(fish); } } } LK.on('tick', function () { for (var i = 0; i < fishes.length; i++) { fishes[i].move(); } }); });
===================================================================
--- original.js
+++ change.js
@@ -1,12 +1,30 @@
var Fish = Container.expand(function () {
var self = Container.call(this);
- self.avoidObstacles = function (obstacles) {};
+ self.avoidObstacles = function (obstacles) {
+ if (obstacles.length > 0) {
+ var obstacle = obstacles[0];
+ var angleToObstacle = Math.atan2(obstacle.y - self.y, obstacle.x - self.x);
+ var avoidAngle = angleToObstacle + Math.PI;
+ self.targetRotation = avoidAngle;
+ self.directionChangeTime = LK.ticks;
+ self.directionChangeInterval = 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;
};
self.getNearbyObstacles = function () {
- return [];
+ var obstacles = [];
+ return obstacles;
};
this.getWaterBounds = function () {
var waterGraphics = LK.getAsset('water', 'Water Graphics', 0, 0);
return {
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.