User prompt
ошибка сохраняется
User prompt
найди в чем ошибка и исправь
User prompt
иногда корм падает медленнее чем обычно и рыбы его не видят в чем ошибка. Исправь
User prompt
счетчик потери сытости у каждой рыбы свой и начинается с момента появления.
User prompt
у рыбы есть три стадии роста 1,2,3.
User prompt
У рыбы есть три стадии роста. На первой стадии она меньша на в два раза меньше. На второй в 1.5 раза, а на третьей стадии она имеет свой естественный размер. Рыба появляется с первой стадии. Рост рыбы происходит каждые 10 секунд.
User prompt
размер fishD при появлении такойже как и урыбы которая удалилась.
User prompt
она не должна быть сплюснутой
User prompt
при появлении рыба пропорционально меньше своего исходного размера на 50%
User prompt
каждые 10 секунда рыба ростет на 50% пока не вырастит до исходного размера. Таймер роста у каждой рыбы свой. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
при появлении рыба пропорционально меньше своего исходного размера на 50%. Каждые 40 секунд она возвращает себе 25% вплоть до исходного размера. Таймер роста у каждой рыбы свой. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
пусть рыба появляется маленькой. Рост рыбы изначально на 50% меньше.
User prompt
нет не работает.
User prompt
все равно не работает.
User prompt
когда рыба плывет влево она должна смотреть влево.
User prompt
рыбы перестали отображаться правильно и смотрят только в одну сторону.
User prompt
у каждой рыбы отдельный цикл роста. Они не должны одновременно расти.
User prompt
инвертируй картинку рыбы в зависимости от того куда она плывет
User prompt
рыбы перестали смотреть в ту сторону которую плывут исправь это
User prompt
Стадии роста теперь меняются с интервалом не 10 а 40 секунд
User prompt
размер fishD должен быть таким же как и у самой рыбы которая удаляется.
User prompt
Рыба появляется с первой стадией роста. Каждые 10 секунд стадия роста растет на 1. третья стади роста максимальная.
User prompt
рыба есть 3 стадии роста. На первой стадии она меньше от своего изначального размера на 50%. На второй стадии роста на 25%. На третий стадии роста она имеет свой естественный размер.
User prompt
FishD падает медленнее в 1.5 раз
User prompt
fishD оерашивается тоже в желтый цвет.
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ // Aquarium class representing the aquarium var Aquarium = Container.expand(function () { var self = Container.call(this); var aquariumGraphics = self.attachAsset('Aquarium', { anchorX: 0.5, anchorY: 0.5 }); self.x = 2048 / 2; self.y = 2732 / 2; var scale = Math.min(2048 / aquariumGraphics.width, 2732 / aquariumGraphics.height); self.scaleX = scale; self.scaleY = scale; }); // Bubble class representing a bubble created by fish var Bubble = Container.expand(function () { var self = Container.call(this); var randomScale = Math.random() * 0.5 + 0.75; // Random scale between 0.75 and 1.25 var bubbleGraphics = self.attachAsset('bubble', { anchorX: 0.5, anchorY: 0.5, alpha: 0.7, // Set transparency to 50% scaleX: randomScale, scaleY: randomScale }); // Initialize bubble position and speed self.speed = Math.random() * 0.5 + 0.5; // Random speed for each bubble // Update function to move the bubble upwards self.update = function () { self.y -= self.speed * 4; self.x += Math.sin(LK.ticks / 20) * 0.5; // Oscillate horizontally if (self.y < 730) { self.pop(); } }; // Function to pop the bubble self.pop = function () { // Add pop animation or effect here if needed LK.getSound('Lop').play(); self.destroy(); bubbles.splice(bubbles.indexOf(self), 1); }; }); // Coin class representing a coin dropped by a fish var Coin = Container.expand(function () { var self = Container.call(this); var coinGraphics = self.attachAsset('coin', { anchorX: 0.5, anchorY: 0.5 }); // Update function to move the coin downwards self.update = function () { self.y += 2; if (self.y > 2732) { self.destroy(); coins.splice(coins.indexOf(self), 1); } }; }); // Corm class representing a falling corm var Corm = Container.expand(function () { var self = Container.call(this); self.rotationDirection = Math.random() < 0.5 ? 1 : -1; // Randomly set rotation direction var cormGraphics = self.attachAsset('corm', { anchorX: 0.5, anchorY: 0.5, alpha: 2 }); // Update function to move the corm downwards self.update = function () { if (self.lastY === undefined) { self.lastY = self.y; } // Initialize lastY for tracking changes on Y if (self.lastIntersecting === undefined) { self.lastIntersecting = false; } // Initialize lastIntersecting for tracking changes on intersections if (self.y > 700) { self.y += 1; // Adjust speed to 1 after reaching y-position of 800 cormGraphics.rotation += self.rotationDirection * 0.005; // Slow down rotation when speed is 1 } else { self.y += 2; // Initial speed of falling corm cormGraphics.rotation += 0.01; // Rotate the corm slowly around its axis } if (self.lastY <= aquarium.y + aquarium.height / 2 - 50 && self.y > aquarium.y + aquarium.height / 2 - 50) { // Stop at the bottom of the aquarium self.y = aquarium.y + aquarium.height / 2 - 50; // Set position to the bottom self.update = null; // Stop updating position // Start the timer for corm disappearance LK.setTimeout(function () { // Flash the corm for 2 seconds var flashDuration = 2000; var flashInterval = 200; var flashCount = flashDuration / flashInterval; var flashTimer = LK.setInterval(function () { cormGraphics.alpha = cormGraphics.alpha === 1 ? 0.5 : 1; flashCount--; if (flashCount <= 0) { LK.clearInterval(flashTimer); self.destroy(); corms.splice(corms.indexOf(self), 1); } }, flashInterval); }, 3000); // Wait for 3 seconds before starting to flash } self.lastY = self.y; // Update lastY for the next frame }; }); // Fish class representing a fish in the aquarium var Fish = Container.expand(function () { var self = Container.call(this); var fishGraphics = self.attachAsset('fish', { anchorX: 0.5, anchorY: 0.5, alpha: 3 }); self.speed = Math.random() * 2 + 1; // Random speed for each fish self.direction = 1; // Fish always swim to the right when they appear // Initialize satiety variable self.satiety = 60; // Create a text object to display satiety above the fish var satietyText = new Text2(self.satiety.toString(), { size: 50, fill: 0x0000FF // Change color to blue }); satietyText.anchor.set(0.5, 1); // Center the text horizontally above the fish satietyText.y -= 75; // Move the text 75 units higher self.addChild(satietyText); // Update satiety display self.updateSatietyDisplay = function () { satietyText.setText(self.satiety.toString()); }; // Update function to move the fish self.verticalInterval = Math.random() * 100 + 50; // Random interval for vertical movement self.update = function () { if (self.satiety > 30 || self.satiety <= 30 && corms.length === 0) { if (Math.random() < 0.01) { self.speed = 0; // Random pause } else { self.speed = Math.random() * 2 + 1; // Randomize speed again after pause } self.x += self.speed * self.direction; self.y += Math.sin(LK.ticks / self.verticalInterval) * self.speed + (Math.random() - 0.5) * 2; // Add random vertical movement based on unique interval // Randomly change direction and speed if (Math.random() < 0.0033) { self.direction *= -1; // Change horizontal direction self.speed = Math.random() * 2 + 1; // Randomize speed fishGraphics.scaleX = self.direction < 0 ? -1 : 1; // Flip the fish based on direction } } else { // Move towards the nearest corm var nearestCorm = null; var minDistance = Infinity; for (var i = 0; i < corms.length; i++) { var corm = corms[i]; var distance = Math.sqrt(Math.pow(corm.x - self.x, 2) + Math.pow(corm.y - self.y, 2)); if (distance < minDistance) { minDistance = distance; nearestCorm = corm; } } if (nearestCorm) { var angle = Math.atan2(nearestCorm.y - self.y, nearestCorm.x - self.x); self.x += Math.cos(angle) * 4; self.y += Math.sin(angle) * 4; fishGraphics.scaleX = Math.cos(angle) < 0 ? -1 : 1; // Flip the fish based on direction // Check if fish intersects with the corm if (!self.lastIntersecting && self.intersects(nearestCorm)) { self.satiety = Math.min(100, self.satiety + 30); // Increase satiety by 30, max 100 self.updateSatietyDisplay(); nearestCorm.destroy(); corms.splice(corms.indexOf(nearestCorm), 1); } self.lastIntersecting = self.intersects(nearestCorm); // Update lastIntersecting for the next frame } } // Ensure fish stays within aquarium bounds if (self.x < aquarium.x - aquarium.width / 2 || self.x > aquarium.x + aquarium.width / 2) { self.direction *= -1; // Change direction if fish hits the aquarium edge fishGraphics.scaleX = self.direction < 0 ? -1 : 1; // Flip the fish based on direction } if (self.y < aquarium.y - aquarium.height / 2 + 550) { self.y = aquarium.y - aquarium.height / 2 + 550; // Prevent fish from swimming above 600 units from the top boundary } else if (self.y > aquarium.y + aquarium.height / 2 - 50) { self.y = aquarium.y + aquarium.height / 2 - 50; // Prevent fish from swimming below the bottom boundary } // Update satiety display if (self.satiety <= 10) { fishGraphics.tint = 0xFFFF00; // Change color to yellow if (self.satiety <= 0) { // Spawn FishD at the fish's position var fishD = new FishD(); fishD.x = self.x; fishD.y = self.y; fishD.scaleX = fishGraphics.scaleX; fishD.scaleY = fishGraphics.scaleY; game.addChild(fishD); fishDs.push(fishD); self.destroy(); // Remove fish if satiety is 0 or less fishes.splice(fishes.indexOf(self), 1); return; // Exit update function to prevent further processing } } else { fishGraphics.tint = 0xFFFFFF; // Reset to original color } self.updateSatietyDisplay(); }; // Function to grow the fish self.grow = function () { // fishGraphics.scaleX += 0.1; // fishGraphics.scaleY += 0.1; }; // Function to drop a coin self.dropCoin = function () { var coin = new Coin(); coin.x = self.x; coin.y = self.y; game.addChild(coin); coins.push(coin); }; }); // FishD class representing a fish skeleton var FishD = Container.expand(function () { var self = Container.call(this); var fishDGraphics = self.attachAsset('FishD', { anchorX: 0.5, anchorY: 0.5, tint: 0xFFFF00 // Change color to yellow }); // Initialize position and speed self.speed = 2 / 1.5; // Update function to move the fish skeleton downwards self.update = function () { self.y += self.speed; if (self.y >= aquarium.y + aquarium.height / 2 - 50) { self.y = aquarium.y + aquarium.height / 2 - 50; // Stop at the bottom self.update = null; // Stop updating position // Start shrinking after reaching the bottom tween(self, { scaleX: 0.33, scaleY: 0.33 }, { duration: 3000, onFinish: function onFinish() { self.destroy(); fishDs.splice(fishDs.indexOf(self), 1); } }); } }; }); // InterfacePanel class representing the interface panel var InterfacePanel = Container.expand(function () { var self = Container.call(this); self.width = 2048; self.height = 200; self.y = 0; self.x = 0; self.color = 0x000000; self.alpha = 0.5; // Function to add a fish to the aquarium self.addFish = function () { var fish = new Fish(); var angle = Math.random() * Math.PI * 2; var radius = Math.random() * 600; fish.x = aquarium.x + radius * Math.cos(angle); fish.y = aquarium.y + radius * Math.sin(angle); fishes.push(fish); game.addChild(fish); }; // Event listener for adding fish // Create a fish icon var fishIcon = self.attachAsset('iconFish', { anchorX: 0.5, anchorY: 0.5, x: 200, y: 500, alpha: 2 }); // Create a corm icon var cormIcon = self.attachAsset('iconcorm', { anchorX: 0.5, anchorY: 0.5, x: 450, y: 500, alpha: 2 }); // Event listener for corm icon cormIcon.down = function (x, y, obj) { LK.getSound('clickkorm').play(); tween(cormIcon, { scaleX: 0.8, scaleY: 0.8 }, { duration: 100, onFinish: function onFinish() { tween(cormIcon, { scaleX: 1, scaleY: 1 }, { duration: 100 }); } }); // Create and drop a new corm from the top var corm = new Corm(); corm.x = Math.random() * (2048 - 500) + 200; // Random x position within 200 units from both edges corm.y = 550; // Start from a slightly higher position game.addChild(corm); corms.push(corm); }; // Event listener for adding fish fishIcon.down = function (x, y, obj) { self.addFish(); LK.getSound('click').play(); tween(fishIcon, { scaleX: 0.8, scaleY: 0.8 }, { duration: 100, onFinish: function onFinish() { tween(fishIcon, { scaleX: 1, scaleY: 1 }, { duration: 100 }); } }); }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ //<Assets used in the game will automatically appear here> // Initialize arrays and variables var fishes = []; var coins = []; var corms = []; var bubbles = []; var fishDs = []; var lastFeedTime = 0; // Decrease satiety of each fish every second LK.setInterval(function () { for (var i = 0; i < fishes.length; i++) { if (fishes[i].satiety <= 10) { fishes[i].satiety = Math.max(0, fishes[i].satiety - 1); // Decrease by 1 if satiety is 10 or less } else { fishes[i].satiety = Math.max(0, fishes[i].satiety - 2); // Decrease by 2 otherwise } fishes[i].updateSatietyDisplay(); } }, 1000); // Create the aquarium var aquarium = new Aquarium(); game.addChild(aquarium); // Function to create bubbles function createBubbles() { if (bubbles.length < 6) { var bubbleCount = Math.random() < 0.5 ? 1 : 3; // Randomly decide to create 1 or 3 bubbles if (bubbleCount === 1) { var bubble = new Bubble(); bubble.x = Math.random() * (aquarium.width - 50) + aquarium.x - aquarium.width / 2 + 25; // Random x position within the aquarium bubble.y = aquarium.y + aquarium.height / 2 - 50; // Start from the bottom of the aquarium game.addChild(bubble); bubbles.push(bubble); LK.getSound('spawnpuzir').play(); // Play sound when a bubble is created } else { var baseX = Math.random() * (aquarium.width - 50) + aquarium.x - aquarium.width / 2 + 25; // Random x position within the aquarium var baseY = aquarium.y + aquarium.height / 2 - 50; // Start from the bottom of the aquarium for (var i = 0; i < bubbleCount; i++) { LK.setTimeout(function () { var bubble = new Bubble(); bubble.x = baseX; bubble.y = baseY; game.addChild(bubble); bubbles.push(bubble); LK.getSound('spawnpuzir').play(); // Play sound when a bubble is created }, i * 500); // Cascade with 0.5 second interval } } } // Set a new random interval between 10 to 20 seconds LK.setTimeout(createBubbles, Math.random() * 10000 + 10000); } // Start the first bubble creation createBubbles(); // Create the interface panel var interfacePanel = new InterfacePanel(); game.addChild(interfacePanel); // Game update function game.update = function () { // Update all coins for (var j = 0; j < coins.length; j++) { coins[j].update(); // Update all bubbles for (var l = 0; l < bubbles.length; l++) { bubbles[l].update(); } } ; // Update all corms for (var k = 0; k < corms.length; k++) { if (typeof corms[k].update === 'function') { corms[k].update(); } } // Update all FishD instances for (var m = 0; m < fishDs.length; m++) { if (typeof fishDs[m].update === 'function') { fishDs[m].update(); } } };
===================================================================
--- original.js
+++ change.js
@@ -75,16 +75,22 @@
alpha: 2
});
// Update function to move the corm downwards
self.update = function () {
+ if (self.lastY === undefined) {
+ self.lastY = self.y;
+ } // Initialize lastY for tracking changes on Y
+ if (self.lastIntersecting === undefined) {
+ self.lastIntersecting = false;
+ } // Initialize lastIntersecting for tracking changes on intersections
if (self.y > 700) {
self.y += 1; // Adjust speed to 1 after reaching y-position of 800
cormGraphics.rotation += self.rotationDirection * 0.005; // Slow down rotation when speed is 1
} else {
self.y += 2; // Initial speed of falling corm
cormGraphics.rotation += 0.01; // Rotate the corm slowly around its axis
}
- if (self.y > aquarium.y + aquarium.height / 2 - 50) {
+ if (self.lastY <= aquarium.y + aquarium.height / 2 - 50 && self.y > aquarium.y + aquarium.height / 2 - 50) {
// Stop at the bottom of the aquarium
self.y = aquarium.y + aquarium.height / 2 - 50; // Set position to the bottom
self.update = null; // Stop updating position
// Start the timer for corm disappearance
@@ -103,8 +109,9 @@
}
}, flashInterval);
}, 3000); // Wait for 3 seconds before starting to flash
}
+ self.lastY = self.y; // Update lastY for the next frame
};
});
// Fish class representing a fish in the aquarium
var Fish = Container.expand(function () {
@@ -164,14 +171,15 @@
self.x += Math.cos(angle) * 4;
self.y += Math.sin(angle) * 4;
fishGraphics.scaleX = Math.cos(angle) < 0 ? -1 : 1; // Flip the fish based on direction
// Check if fish intersects with the corm
- if (self.intersects(nearestCorm)) {
+ if (!self.lastIntersecting && self.intersects(nearestCorm)) {
self.satiety = Math.min(100, self.satiety + 30); // Increase satiety by 30, max 100
self.updateSatietyDisplay();
nearestCorm.destroy();
corms.splice(corms.indexOf(nearestCorm), 1);
}
+ self.lastIntersecting = self.intersects(nearestCorm); // Update lastIntersecting for the next frame
}
}
// Ensure fish stays within aquarium bounds
if (self.x < aquarium.x - aquarium.width / 2 || self.x > aquarium.x + aquarium.width / 2) {
прозрачный пузырь воздуха. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Потрепаная рыбе
древняя Монетка, постэльные цвета. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Потрепаная рыба
сундук с сокровищами с видом спереди, постэльные цвета. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
предупреждение о нападении акул без надписей, постэльные цвета.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Морской Монстр, вид с боку, накаченные мышцы, постэльные цвета.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Большой прозрачный радужный пузырь. пастельные цвета Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
осьминог повар, минимализм, пастельные цвета \. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
spawnpuzir
Sound effect
Lop
Sound effect
click
Sound effect
clickkorm
Sound effect
Emy
Sound effect
MonetaSpawn
Sound effect
MonetaUp
Sound effect
Deadfish
Sound effect
rost
Sound effect
akulaspawn
Sound effect
ataka
Sound effect
emyakula
Sound effect
sundukup
Sound effect
Music
Music
music2
Music
udarbonus
Sound effect
udarbonus2
Sound effect
udarbonus3
Sound effect
startbonus
Sound effect
osmincorm
Sound effect