/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Coin = Container.expand(function () {
var self = Container.call(this);
var coinGraphics = self.attachAsset('coin', {
anchorX: 0.5,
anchorY: 0.5
});
// Add floating animation
self.floatOffset = Math.random() * Math.PI * 2;
self.startY = 0;
self.update = function () {
// Floating animation
if (self.startY === 0) {
self.startY = self.y;
}
self.y = self.startY + Math.sin(LK.ticks * 0.1 + self.floatOffset) * 10;
// Rotate coin
coinGraphics.rotation += 0.05;
};
return self;
});
var Fish = Container.expand(function (fishType) {
var self = Container.call(this);
self.fishType = fishType || 'smallFish';
self.fishSize = 1;
if (self.fishType === 'smallFish') {
self.fishSize = 1;
} else if (self.fishType === 'mediumFish') {
self.fishSize = 2;
} else if (self.fishType === 'largeFish') {
self.fishSize = 3;
} else if (self.fishType === 'hugeFish') {
self.fishSize = 4;
} else if (self.fishType === 'bossfish') {
self.fishSize = 5;
} else if (self.fishType === 'dangerfish') {
self.fishSize = 6;
}
var fishGraphics = self.attachAsset(self.fishType, {
anchorX: 0.5,
anchorY: 0.5
});
if (self.fishType === 'largeFish') {
self.speedX = (Math.random() - 0.5) * 3 * 1.2; // 20% speed increase
self.speedY = (Math.random() - 0.5) * 3 * 1.2; // 20% speed increase
} else {
self.speedX = (Math.random() - 0.5) * 3;
self.speedY = (Math.random() - 0.5) * 3;
}
self.update = function () {
if (attackMode && LK.getScore() < 6000) {
// In attack mode, move towards octopus (but not when score >= 5000)
var dx = octopus.x - self.x;
var dy = octopus.y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance > 0) {
var dirX = dx / distance;
var dirY = dy / distance;
var attackSpeed = 2; // Speed when moving towards octopus
self.x += dirX * attackSpeed;
self.y += dirY * attackSpeed;
}
} else if (self.fishType === 'dangerfish') {
// All dangerfish move towards octopus from spawn
var dx = octopus.x - self.x;
var dy = octopus.y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance > 0) {
var dirX = dx / distance;
var dirY = dy / distance;
var dangerfishSpeed = 2.662; // 33% faster than normal attack speed (2.2 * 1.21 = 2.662)
self.x += dirX * dangerfishSpeed;
self.y += dirY * dangerfishSpeed;
}
} else {
// Normal movement
self.x += self.speedX;
self.y += self.speedY;
}
// Use expanding ocean bounds for feeding game
var currentWidth = oceanWidth;
var currentHeight = oceanHeight;
if (!attackMode) {
// Only bounce off edges when not in attack mode
if (self.x < 0 || self.x > currentWidth) {
self.speedX *= -1;
}
if (self.y < 0 || self.y > currentHeight) {
self.speedY *= -1;
}
// Keep within bounds
self.x = Math.max(0, Math.min(currentWidth, self.x));
self.y = Math.max(0, Math.min(currentHeight, self.y));
}
};
return self;
});
var Octopus = Container.expand(function () {
var self = Container.call(this);
self.octopusSize = 1;
var octopusGraphics = self.attachAsset('octopus', {
anchorX: 0.5,
anchorY: 0.5
});
self.grow = function () {
self.octopusSize++;
// Scale up the octopus with size-based growth rate adjustments
var baseGrowthRate = 0.3;
var growthRate = baseGrowthRate;
if (self.octopusSize === 4) {
growthRate = baseGrowthRate * 1.3; // 30% increase for size 4 (20% boost applied)
} else if (self.octopusSize === 5) {
growthRate = baseGrowthRate * 1.35; // 35% increase for size 5 (20% boost applied)
} else if (self.octopusSize === 6) {
growthRate = baseGrowthRate * 2.0; // 100% increase for size 6
}
var newScale = 1 + (self.octopusSize - 1) * growthRate;
tween(octopusGraphics, {
scaleX: newScale,
scaleY: newScale
}, {
duration: 500
});
// Expand the ocean bounds like in feeding games
oceanWidth += 400; // Increase ocean width by 400 pixels
oceanHeight += 400; // Increase ocean height by 400 pixels
// Scale background to match expanding ocean bounds
var bgScaleX = oceanWidth / 2048;
var bgScaleY = oceanHeight / 2732;
tween(oceanBg, {
scaleX: bgScaleX,
scaleY: bgScaleY
}, {
duration: 1000
});
// Use tween to smoothly expand the camera view
tween(game, {
scaleX: game.scaleX * 0.9,
scaleY: game.scaleY * 0.9
}, {
duration: 1000
});
LK.getSound('grow').play();
};
self.canEat = function (fish) {
return self.octopusSize >= fish.fishSize;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x006994
});
/****
* Game Code
****/
// This task is already completed - bossfish spawn rates already have 30% reduction when score >= 10000
var oceanBg = game.addChild(LK.getAsset('oceanBackground', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0
}));
// Initialize game scale for ocean expansion
game.scaleX = 1;
game.scaleY = 1;
// Track ocean bounds for feeding game expansion
var oceanWidth = 2048;
var oceanHeight = 2732;
var octopus = game.addChild(new Octopus());
octopus.x = 1024;
octopus.y = 1366;
var fish = [];
var fishTypes = ['smallFish', 'mediumFish', 'largeFish', 'hugeFish', 'bossfish', 'dangerfish'];
// Create initial fish (reduced by 10% from 14 to 13)
for (var i = 0; i < 13; i++) {
var currentWidth = oceanWidth;
var currentHeight = oceanHeight;
// Weighted spawning - increase spawn rate for fish matching octopus size
var rand = Math.random();
var fishType;
// Adjust spawn rates based on octopus size
if (octopus.octopusSize === 1) {
// Size 1: SmallFish/MediumFish reduced by 15%, no huge/boss fish
var weights = [{
type: 'smallFish',
weight: 60 * 0.85 * 0.9 * 1.1
},
// 51 - reduced by 15% then 10%
{
type: 'mediumFish',
weight: 30 * 0.85 * 0.9 * 0.9
},
// 25.5 - reduced by 15% then 10%
{
type: 'largeFish',
weight: 10 * 0.85 * 0.9 * 0.8 * 0.9
}];
// Dangerfish now spawn at specific score thresholds, not in weighted spawning
} else if (octopus.octopusSize === 2) {
// Size 2: SmallFish/MediumFish reduced by 15%, no huge/boss fish
var weights = [{
type: 'smallFish',
weight: 25 * 0.85 * 0.9 * 1.1
},
// 21.25 - reduced by 15% then 10%
{
type: 'mediumFish',
weight: (50 * 0.85 + 20) * 0.9 * 0.9
},
// 62.5 - reduced by 15% + size bonus then 10%
{
type: 'largeFish',
weight: 20 * 0.85 * 0.9 * 0.8 * 0.9
}];
// Dangerfish now spawn at specific score thresholds, not in weighted spawning
} else if (octopus.octopusSize === 3) {
// Size 3: SmallFish/MediumFish reduced by 15%, HugeFish/BossFish spawn, increased by 100%
var weights = [{
type: 'smallFish',
weight: 20 * 0.85 * 0.9 * 1.1
},
// 17 - reduced by 15% then 10%
{
type: 'mediumFish',
weight: 15 * 0.85 * 0.9 * 0.9
},
// 12.75 - reduced by 15% then 10%
{
type: 'largeFish',
weight: (30 + 15) * 0.85 * 0.9 * 0.8 * 0.9
},
// 45 - size bonus then 10%
{
type: 'hugeFish',
weight: 15 * 2.0 * 0.85 * 0.9 * 0.9 * (LK.getScore() >= 10000 ? 0.35 : 1) * 0.5 * 0.8 * 0.8
},
// 30 - 100% increase then 10% then 30% reduction if score >= 10000
{
type: 'bossfish',
weight: 10 * 2.0 * 0.85 * 0.85 * 0.9 * 0.9 * (LK.getScore() >= 10000 ? 0.35 : 1) * 0.5 * 0.8 * 0.8 * 0.7
} // 17 - 100% increase then 15% reduction then 10% then 30% reduction if score >= 10000 then 20% reduction
];
// Dangerfish now spawn at specific score thresholds, not in weighted spawning
} else if (octopus.octopusSize === 4) {
// Size 4: SmallFish/MediumFish reduced by 15%, HugeFish/BossFish increased by 100%
var weights = [{
type: 'smallFish',
weight: 15 * 0.85 * 0.9 * 1.1
},
// 12.75 - reduced by 15% then 10%
{
type: 'mediumFish',
weight: 10 * 0.85 * 0.9 * 0.9
},
// 8.5 - reduced by 15% then 10%
{
type: 'largeFish',
weight: 20 * 0.85 * 0.9 * 0.8 * 0.9
},
// 20 - reduced by 10%
{
type: 'hugeFish',
weight: (25 * 2.0 + 15) * 0.85 * 0.9 * 0.9 * (LK.getScore() >= 10000 ? 0.35 : 1) * 0.5 * 0.8 * 0.8
},
// 65 - 100% increase + size bonus then 10% then 30% reduction if score >= 10000
{
type: 'bossfish',
weight: 15 * 2.0 * 0.85 * 0.85 * 0.9 * 0.9 * (LK.getScore() >= 10000 ? 0.35 : 1) * 0.5 * 0.8 * 0.8 * 0.7
} // 25.5 - 100% increase then 15% reduction then 10% then 30% reduction if score >= 10000 then 20% reduction
];
// Dangerfish now spawn at specific score thresholds, not in weighted spawning
} else {
// Size 5+: SmallFish/MediumFish reduced by 15%, HugeFish/BossFish increased by 100%
var weights = [{
type: 'smallFish',
weight: 10 * 0.85 * 0.9 * 1.1
},
// 8.5 - reduced by 15% then 10%
{
type: 'mediumFish',
weight: 8 * 0.85 * 0.9 * 0.9
},
// 6.8 - reduced by 15% then 10%
{
type: 'largeFish',
weight: 15 * 0.85 * 0.9 * 0.8 * 0.9
},
// 15 - reduced by 10%
{
type: 'hugeFish',
weight: 20 * 2.0 * 0.85 * 0.9 * 0.9 * (LK.getScore() >= 10000 ? 0.35 : 1) * 0.5 * 0.8 * 0.8
},
// 40 - 100% increase then 10% then 30% reduction if score >= 10000
{
type: 'bossfish',
weight: (30 * 2.0 + 20) * 0.85 * 0.85 * 0.9 * 0.9 * (LK.getScore() >= 10000 ? 0.35 : 1) * 0.5 * 0.8 * 0.8 * 0.7
} // 68 - 100% increase + size bonus then 15% reduction then 10% then 30% reduction if score >= 10000 then 20% reduction
];
// Dangerfish now spawn at specific score thresholds, not in weighted spawning
}
// Calculate total weight
var totalWeight = 0;
for (var w = 0; w < weights.length; w++) {
totalWeight += weights[w].weight;
}
// Select fish type based on weights
var randomWeight = rand * totalWeight;
var currentWeight = 0;
for (var w = 0; w < weights.length; w++) {
currentWeight += weights[w].weight;
if (randomWeight <= currentWeight) {
fishType = weights[w].type;
break;
}
}
var newFish = new Fish(fishType);
// Spawn fish from ocean edges
var edge = Math.floor(Math.random() * 4); // 0=top, 1=right, 2=bottom, 3=left
if (edge === 0) {
// Top edge
newFish.x = Math.random() * currentWidth;
newFish.y = 0;
} else if (edge === 1) {
// Right edge
newFish.x = currentWidth;
newFish.y = Math.random() * currentHeight;
} else if (edge === 2) {
// Bottom edge
newFish.x = Math.random() * currentWidth;
newFish.y = currentHeight;
} else {
// Left edge
newFish.x = 0;
newFish.y = Math.random() * currentHeight;
}
fish.push(newFish);
game.addChild(newFish);
}
var scoreTxt = new Text2('Score: 0', {
size: 80,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
var sizeTxt = new Text2('Size: 1', {
size: 60,
fill: 0xFFFFFF
});
sizeTxt.anchor.set(0, 0);
sizeTxt.x = 150;
sizeTxt.y = 100;
LK.gui.topLeft.addChild(sizeTxt);
var mouseX = octopus.x;
var mouseY = octopus.y;
var moveSpeed = 8;
var baseSpeed = 8;
var lastClickTime = 0;
var doubleClickThreshold = 300; // 300ms between clicks for double-click
var speedBoostActive = false;
var speedBoostTimer = null;
var attackMode = false;
var coins = 0;
var coinObjects = [];
var coinTxt = new Text2('Coins: 0', {
size: 60,
fill: 0xFFD700
}); //{coin_txt}
coinTxt.anchor.set(1, 0);
LK.gui.topRight.addChild(coinTxt);
var fightTxt = new Text2('FIGHT!!!', {
size: 70,
fill: 0xFF0000,
// Red color
font: "'GillSans-Bold',Impact,'Arial Black',Tahoma" // Bold font
});
fightTxt.anchor.set(1, 0);
fightTxt.y = 70; // Position below coins text
fightTxt.visible = false; // Initially hidden
LK.gui.topRight.addChild(fightTxt);
game.down = function (x, y, obj) {
var currentTime = Date.now();
if (currentTime - lastClickTime < doubleClickThreshold) {
// Double-click detected - check if we have enough coins
if (!speedBoostActive && coins >= 5) {
// Deduct coins
coins -= 5;
coinTxt.setText('Coins: ' + coins);
// Activate speed boost
speedBoostActive = true;
moveSpeed = baseSpeed * 2; // 100% speed increase
// Clear any existing timer
if (speedBoostTimer) {
LK.clearTimeout(speedBoostTimer);
}
// Set timer to reset speed after 3 seconds
speedBoostTimer = LK.setTimeout(function () {
speedBoostActive = false;
moveSpeed = baseSpeed;
speedBoostTimer = null;
}, 3000);
}
}
lastClickTime = currentTime;
};
game.move = function (x, y, obj) {
// Update mouse position for octopus to follow
mouseX = x;
mouseY = y;
};
game.update = function () {
// Move octopus towards mouse position
var dx = mouseX - octopus.x;
var dy = mouseY - octopus.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance > 5) {
// Normalize direction and apply speed
var dirX = dx / distance;
var dirY = dy / distance;
octopus.x += dirX * moveSpeed;
octopus.y += dirY * moveSpeed;
// Keep octopus within expanding ocean bounds
octopus.x = Math.max(40, Math.min(oceanWidth - 40, octopus.x));
octopus.y = Math.max(40, Math.min(oceanHeight - 40, octopus.y));
}
// Check collisions between octopus and fish
for (var i = fish.length - 1; i >= 0; i--) {
var currentFish = fish[i];
// Calculate distance between octopus and fish centers
var dx = octopus.x - currentFish.x;
var dy = octopus.y - currentFish.y;
var distance = Math.sqrt(dx * dx + dy * dy);
// Get approximate radii (half of width/height)
var octopusRadius = octopus.width / 2 * 0.8; // 80% of actual size for more forgiving collision
var fishRadius = currentFish.width / 2 * 0.8; // 80% of actual size for more forgiving collision
// Check if distance is less than combined radii (allowing more penetration)
if (distance < octopusRadius + fishRadius) {
// Special handling for dangerfish
if (currentFish.fishType === 'dangerfish') {
if (LK.getScore() < 30000) {
// Game over - octopus cannot eat dangerfish until score >= 30000
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
return;
} else {
// Win the game when dangerfish is eaten and score >= 30000
LK.showYouWin();
return;
}
} else if (octopus.canEat(currentFish)) {
// Eat the fish
var points;
if (currentFish.fishType === 'bossfish') {
points = 1000;
} else if (currentFish.fishType === 'hugeFish') {
points = 500;
} else if (currentFish.fishType === 'largeFish') {
points = 250;
} else if (currentFish.fishType === 'mediumFish') {
points = 50;
} else {
points = 10; // smallFish
}
var oldScore = LK.getScore();
LK.setScore(oldScore + points);
LK.getSound('eat').play();
// Remove fish
currentFish.destroy();
fish.splice(i, 1);
// Check if octopus should grow with exponential point requirements
var newScore = LK.getScore();
var requiredPoints = [0, 100, 600, 2600, 5600, 10000]; // Cumulative points needed for each size
// Check if we can grow to next size
if (octopus.octopusSize < requiredPoints.length && newScore >= requiredPoints[octopus.octopusSize]) {
octopus.grow();
sizeTxt.setText('Size: ' + octopus.octopusSize);
}
// Spawn fish within expanding ocean bounds (reduced by 10% from 2 to 1.8, rounded to 2)
for (var j = 0; j < 2; j++) {
var currentWidth = oceanWidth;
var currentHeight = oceanHeight;
// Weighted spawning - increase spawn rate for fish matching octopus size
var rand = Math.random();
var fishType;
// Adjust spawn rates based on octopus size
if (octopus.octopusSize === 1) {
// Size 1: SmallFish/MediumFish reduced by 15%, no huge/boss fish
var weights = [{
type: 'smallFish',
weight: 60 * 0.85 * 0.9 * 1.1
},
// 51 - reduced by 15% then 10%
{
type: 'mediumFish',
weight: 30 * 0.85 * 0.9 * 0.9
},
// 25.5 - reduced by 15% then 10%
{
type: 'largeFish',
weight: 10 * 0.85 * 0.9 * 0.8 * 0.9
}];
// Dangerfish now spawn at specific score thresholds, not in weighted spawning
} else if (octopus.octopusSize === 2) {
// Size 2: SmallFish/MediumFish reduced by 15%, no huge/boss fish
var weights = [{
type: 'smallFish',
weight: 25 * 0.85 * 0.9 * 1.1
},
// 21.25 - reduced by 15% then 10%
{
type: 'mediumFish',
weight: (50 * 0.85 + 20) * 0.9 * 0.9
},
// 62.5 - reduced by 15% + size bonus then 10%
{
type: 'largeFish',
weight: 20 * 0.85 * 0.9 * 0.8 * 0.9
}];
// Dangerfish now spawn at specific score thresholds, not in weighted spawning
} else if (octopus.octopusSize === 3) {
// Size 3: SmallFish/MediumFish reduced by 15%, HugeFish/BossFish spawn, increased by 100%
var weights = [{
type: 'smallFish',
weight: 20 * 0.85 * 0.9 * 1.1
},
// 17 - reduced by 15% then 10%
{
type: 'mediumFish',
weight: 15 * 0.85 * 0.9 * 0.9
},
// 12.75 - reduced by 15% then 10%
{
type: 'largeFish',
weight: (30 + 15) * 0.85 * 0.9 * 0.8 * 0.9
},
// 45 - size bonus then 10%
{
type: 'hugeFish',
weight: 15 * 2.0 * 0.85 * 0.9 * 0.9 * (LK.getScore() >= 10000 ? 0.35 : 1) * 0.5 * 0.8 * 0.8
},
// 30 - 100% increase then 10% then 30% reduction if score >= 10000
{
type: 'bossfish',
weight: 10 * 2.0 * 0.85 * 0.85 * 0.9 * 0.9 * (LK.getScore() >= 10000 ? 0.35 : 1) * 0.5 * 0.8 * 0.8 * 0.7
} // 17 - 100% increase then 15% reduction then 10% then 30% reduction if score >= 10000 then 20% reduction
];
// Dangerfish now spawn at specific score thresholds, not in weighted spawning
} else if (octopus.octopusSize === 4) {
// Size 4: SmallFish/MediumFish reduced by 15%, HugeFish/BossFish increased by 100%
var weights = [{
type: 'smallFish',
weight: 15 * 0.85 * 0.9 * 1.1
},
// 12.75 - reduced by 15% then 10%
{
type: 'mediumFish',
weight: 10 * 0.85 * 0.9 * 0.9
},
// 8.5 - reduced by 15% then 10%
{
type: 'largeFish',
weight: 20 * 0.85 * 0.9 * 0.8 * 0.9
},
// 20 - reduced by 10%
{
type: 'hugeFish',
weight: (25 * 2.0 + 15) * 0.85 * 0.9 * 0.9 * (LK.getScore() >= 10000 ? 0.35 : 1) * 0.5 * 0.8 * 0.8
},
// 65 - 100% increase + size bonus then 10% then 30% reduction if score >= 10000
{
type: 'bossfish',
weight: 15 * 2.0 * 0.85 * 0.85 * 0.9 * 0.9 * (LK.getScore() >= 10000 ? 0.35 : 1) * 0.5 * 0.8 * 0.8 * 0.7
} // 25.5 - 100% increase then 15% reduction then 10% then 30% reduction if score >= 10000 then 20% reduction
];
// Dangerfish now spawn at specific score thresholds, not in weighted spawning
} else {
// Size 5+: SmallFish/MediumFish reduced by 15%, HugeFish/BossFish increased by 100%
var weights = [{
type: 'smallFish',
weight: 10 * 0.85 * 0.9 * 1.1
},
// 8.5 - reduced by 15% then 10%
{
type: 'mediumFish',
weight: 8 * 0.85 * 0.9 * 0.9
},
// 6.8 - reduced by 15% then 10%
{
type: 'largeFish',
weight: 15 * 0.85 * 0.9 * 0.8 * 0.9
},
// 15 - reduced by 10%
{
type: 'hugeFish',
weight: 20 * 2.0 * 0.85 * 0.9 * 0.9 * (LK.getScore() >= 10000 ? 0.35 : 1) * 0.5 * 0.8 * 0.8
},
// 40 - 100% increase then 10% then 30% reduction if score >= 10000
{
type: 'bossfish',
weight: (30 * 2.0 + 20) * 0.85 * 0.85 * 0.9 * 0.9 * (LK.getScore() >= 10000 ? 0.35 : 1) * 0.5 * 0.8 * 0.8 * 0.7
} // 68 - 100% increase + size bonus then 15% reduction then 10% then 30% reduction if score >= 10000 then 20% reduction
];
// Dangerfish now spawn at specific score thresholds, not in weighted spawning
}
// Calculate total weight
var totalWeight = 0;
for (var w = 0; w < weights.length; w++) {
totalWeight += weights[w].weight;
}
// Select fish type based on weights
var randomWeight = rand * totalWeight;
var currentWeight = 0;
for (var w = 0; w < weights.length; w++) {
currentWeight += weights[w].weight;
if (randomWeight <= currentWeight) {
fishType = weights[w].type;
break;
}
}
var newFish = new Fish(fishType);
// Spawn fish from ocean edges
var edge = Math.floor(Math.random() * 4); // 0=top, 1=right, 2=bottom, 3=left
if (edge === 0) {
// Top edge
newFish.x = Math.random() * currentWidth;
newFish.y = 0;
} else if (edge === 1) {
// Right edge
newFish.x = currentWidth;
newFish.y = Math.random() * currentHeight;
} else if (edge === 2) {
// Bottom edge
newFish.x = Math.random() * currentWidth;
newFish.y = currentHeight;
} else {
// Left edge
newFish.x = 0;
newFish.y = Math.random() * currentHeight;
}
fish.push(newFish);
game.addChild(newFish);
}
} else {
// Game over - touched larger fish
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
return;
}
}
}
// Spawn coins randomly - 10% increase in spawn rate (163 to 147 frames)
if (LK.ticks % 147 === 0) {
// Every 2.45 seconds (10% faster than 2.7 seconds)
var newCoin = new Coin();
newCoin.x = Math.random() * oceanWidth;
newCoin.y = Math.random() * oceanHeight;
coinObjects.push(newCoin);
game.addChild(newCoin);
}
// Check coin collection
for (var k = coinObjects.length - 1; k >= 0; k--) {
var coin = coinObjects[k];
var dx = octopus.x - coin.x;
var dy = octopus.y - coin.y;
var distance = Math.sqrt(dx * dx + dy * dy);
// Scale collection radius based on octopus size for easier collection when larger
var collectionRadius = 120 + (octopus.octopusSize - 1) * 40; // Base 120, +40 per size level
if (distance < collectionRadius) {
// Coin collected - radius scales with octopus size
coins++;
coinTxt.setText('Coins: ' + coins);
// Play coin collection sound
LK.getSound('coin').play();
coin.destroy();
coinObjects.splice(k, 1);
}
}
// Update score display
scoreTxt.setText('Score: ' + LK.getScore());
// Show FIGHT!!! text when score reaches 30000
if (LK.getScore() >= 30000 && !fightTxt.visible) {
fightTxt.visible = true;
}
// Check if attack mode should be activated
if (LK.getScore() >= 6000 && !attackMode) {
attackMode = true;
}
// Score-based dangerfish spawning: spawn individual dangerfish at specific score thresholds
// First dangerfish at score 7000
if (LK.getScore() >= 7000 && !game.dangerfish1Spawned) {
game.dangerfish1Spawned = true;
var dangerFish1 = new Fish('dangerfish');
dangerFish1.x = 0;
dangerFish1.y = 0;
fish.push(dangerFish1);
game.addChild(dangerFish1);
}
// Second dangerfish at score 15000
if (LK.getScore() >= 15000 && !game.dangerfish2Spawned) {
game.dangerfish2Spawned = true;
var dangerFish2 = new Fish('dangerfish');
dangerFish2.x = oceanWidth;
dangerFish2.y = 0;
fish.push(dangerFish2);
game.addChild(dangerFish2);
}
// Third dangerfish at score 25000
if (LK.getScore() >= 25000 && !game.dangerfish3Spawned) {
game.dangerfish3Spawned = true;
var dangerFish3 = new Fish('dangerfish');
dangerFish3.x = oceanWidth / 2;
dangerFish3.y = 0;
fish.push(dangerFish3);
game.addChild(dangerFish3);
}
}; /****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Coin = Container.expand(function () {
var self = Container.call(this);
var coinGraphics = self.attachAsset('coin', {
anchorX: 0.5,
anchorY: 0.5
});
// Add floating animation
self.floatOffset = Math.random() * Math.PI * 2;
self.startY = 0;
self.update = function () {
// Floating animation
if (self.startY === 0) {
self.startY = self.y;
}
self.y = self.startY + Math.sin(LK.ticks * 0.1 + self.floatOffset) * 10;
// Rotate coin
coinGraphics.rotation += 0.05;
};
return self;
});
var Fish = Container.expand(function (fishType) {
var self = Container.call(this);
self.fishType = fishType || 'smallFish';
self.fishSize = 1;
if (self.fishType === 'smallFish') {
self.fishSize = 1;
} else if (self.fishType === 'mediumFish') {
self.fishSize = 2;
} else if (self.fishType === 'largeFish') {
self.fishSize = 3;
} else if (self.fishType === 'hugeFish') {
self.fishSize = 4;
} else if (self.fishType === 'bossfish') {
self.fishSize = 5;
} else if (self.fishType === 'dangerfish') {
self.fishSize = 6;
}
var fishGraphics = self.attachAsset(self.fishType, {
anchorX: 0.5,
anchorY: 0.5
});
if (self.fishType === 'largeFish') {
self.speedX = (Math.random() - 0.5) * 3 * 1.2; // 20% speed increase
self.speedY = (Math.random() - 0.5) * 3 * 1.2; // 20% speed increase
} else {
self.speedX = (Math.random() - 0.5) * 3;
self.speedY = (Math.random() - 0.5) * 3;
}
self.update = function () {
if (attackMode && LK.getScore() < 6000) {
// In attack mode, move towards octopus (but not when score >= 5000)
var dx = octopus.x - self.x;
var dy = octopus.y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance > 0) {
var dirX = dx / distance;
var dirY = dy / distance;
var attackSpeed = 2; // Speed when moving towards octopus
self.x += dirX * attackSpeed;
self.y += dirY * attackSpeed;
}
} else if (self.fishType === 'dangerfish') {
// All dangerfish move towards octopus from spawn
var dx = octopus.x - self.x;
var dy = octopus.y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance > 0) {
var dirX = dx / distance;
var dirY = dy / distance;
var dangerfishSpeed = 2.662; // 33% faster than normal attack speed (2.2 * 1.21 = 2.662)
self.x += dirX * dangerfishSpeed;
self.y += dirY * dangerfishSpeed;
}
} else {
// Normal movement
self.x += self.speedX;
self.y += self.speedY;
}
// Use expanding ocean bounds for feeding game
var currentWidth = oceanWidth;
var currentHeight = oceanHeight;
if (!attackMode) {
// Only bounce off edges when not in attack mode
if (self.x < 0 || self.x > currentWidth) {
self.speedX *= -1;
}
if (self.y < 0 || self.y > currentHeight) {
self.speedY *= -1;
}
// Keep within bounds
self.x = Math.max(0, Math.min(currentWidth, self.x));
self.y = Math.max(0, Math.min(currentHeight, self.y));
}
};
return self;
});
var Octopus = Container.expand(function () {
var self = Container.call(this);
self.octopusSize = 1;
var octopusGraphics = self.attachAsset('octopus', {
anchorX: 0.5,
anchorY: 0.5
});
self.grow = function () {
self.octopusSize++;
// Scale up the octopus with size-based growth rate adjustments
var baseGrowthRate = 0.3;
var growthRate = baseGrowthRate;
if (self.octopusSize === 4) {
growthRate = baseGrowthRate * 1.3; // 30% increase for size 4 (20% boost applied)
} else if (self.octopusSize === 5) {
growthRate = baseGrowthRate * 1.35; // 35% increase for size 5 (20% boost applied)
} else if (self.octopusSize === 6) {
growthRate = baseGrowthRate * 2.0; // 100% increase for size 6
}
var newScale = 1 + (self.octopusSize - 1) * growthRate;
tween(octopusGraphics, {
scaleX: newScale,
scaleY: newScale
}, {
duration: 500
});
// Expand the ocean bounds like in feeding games
oceanWidth += 400; // Increase ocean width by 400 pixels
oceanHeight += 400; // Increase ocean height by 400 pixels
// Scale background to match expanding ocean bounds
var bgScaleX = oceanWidth / 2048;
var bgScaleY = oceanHeight / 2732;
tween(oceanBg, {
scaleX: bgScaleX,
scaleY: bgScaleY
}, {
duration: 1000
});
// Use tween to smoothly expand the camera view
tween(game, {
scaleX: game.scaleX * 0.9,
scaleY: game.scaleY * 0.9
}, {
duration: 1000
});
LK.getSound('grow').play();
};
self.canEat = function (fish) {
return self.octopusSize >= fish.fishSize;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x006994
});
/****
* Game Code
****/
// This task is already completed - bossfish spawn rates already have 30% reduction when score >= 10000
var oceanBg = game.addChild(LK.getAsset('oceanBackground', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0
}));
// Initialize game scale for ocean expansion
game.scaleX = 1;
game.scaleY = 1;
// Track ocean bounds for feeding game expansion
var oceanWidth = 2048;
var oceanHeight = 2732;
var octopus = game.addChild(new Octopus());
octopus.x = 1024;
octopus.y = 1366;
var fish = [];
var fishTypes = ['smallFish', 'mediumFish', 'largeFish', 'hugeFish', 'bossfish', 'dangerfish'];
// Create initial fish (reduced by 10% from 14 to 13)
for (var i = 0; i < 13; i++) {
var currentWidth = oceanWidth;
var currentHeight = oceanHeight;
// Weighted spawning - increase spawn rate for fish matching octopus size
var rand = Math.random();
var fishType;
// Adjust spawn rates based on octopus size
if (octopus.octopusSize === 1) {
// Size 1: SmallFish/MediumFish reduced by 15%, no huge/boss fish
var weights = [{
type: 'smallFish',
weight: 60 * 0.85 * 0.9 * 1.1
},
// 51 - reduced by 15% then 10%
{
type: 'mediumFish',
weight: 30 * 0.85 * 0.9 * 0.9
},
// 25.5 - reduced by 15% then 10%
{
type: 'largeFish',
weight: 10 * 0.85 * 0.9 * 0.8 * 0.9
}];
// Dangerfish now spawn at specific score thresholds, not in weighted spawning
} else if (octopus.octopusSize === 2) {
// Size 2: SmallFish/MediumFish reduced by 15%, no huge/boss fish
var weights = [{
type: 'smallFish',
weight: 25 * 0.85 * 0.9 * 1.1
},
// 21.25 - reduced by 15% then 10%
{
type: 'mediumFish',
weight: (50 * 0.85 + 20) * 0.9 * 0.9
},
// 62.5 - reduced by 15% + size bonus then 10%
{
type: 'largeFish',
weight: 20 * 0.85 * 0.9 * 0.8 * 0.9
}];
// Dangerfish now spawn at specific score thresholds, not in weighted spawning
} else if (octopus.octopusSize === 3) {
// Size 3: SmallFish/MediumFish reduced by 15%, HugeFish/BossFish spawn, increased by 100%
var weights = [{
type: 'smallFish',
weight: 20 * 0.85 * 0.9 * 1.1
},
// 17 - reduced by 15% then 10%
{
type: 'mediumFish',
weight: 15 * 0.85 * 0.9 * 0.9
},
// 12.75 - reduced by 15% then 10%
{
type: 'largeFish',
weight: (30 + 15) * 0.85 * 0.9 * 0.8 * 0.9
},
// 45 - size bonus then 10%
{
type: 'hugeFish',
weight: 15 * 2.0 * 0.85 * 0.9 * 0.9 * (LK.getScore() >= 10000 ? 0.35 : 1) * 0.5 * 0.8 * 0.8
},
// 30 - 100% increase then 10% then 30% reduction if score >= 10000
{
type: 'bossfish',
weight: 10 * 2.0 * 0.85 * 0.85 * 0.9 * 0.9 * (LK.getScore() >= 10000 ? 0.35 : 1) * 0.5 * 0.8 * 0.8 * 0.7
} // 17 - 100% increase then 15% reduction then 10% then 30% reduction if score >= 10000 then 20% reduction
];
// Dangerfish now spawn at specific score thresholds, not in weighted spawning
} else if (octopus.octopusSize === 4) {
// Size 4: SmallFish/MediumFish reduced by 15%, HugeFish/BossFish increased by 100%
var weights = [{
type: 'smallFish',
weight: 15 * 0.85 * 0.9 * 1.1
},
// 12.75 - reduced by 15% then 10%
{
type: 'mediumFish',
weight: 10 * 0.85 * 0.9 * 0.9
},
// 8.5 - reduced by 15% then 10%
{
type: 'largeFish',
weight: 20 * 0.85 * 0.9 * 0.8 * 0.9
},
// 20 - reduced by 10%
{
type: 'hugeFish',
weight: (25 * 2.0 + 15) * 0.85 * 0.9 * 0.9 * (LK.getScore() >= 10000 ? 0.35 : 1) * 0.5 * 0.8 * 0.8
},
// 65 - 100% increase + size bonus then 10% then 30% reduction if score >= 10000
{
type: 'bossfish',
weight: 15 * 2.0 * 0.85 * 0.85 * 0.9 * 0.9 * (LK.getScore() >= 10000 ? 0.35 : 1) * 0.5 * 0.8 * 0.8 * 0.7
} // 25.5 - 100% increase then 15% reduction then 10% then 30% reduction if score >= 10000 then 20% reduction
];
// Dangerfish now spawn at specific score thresholds, not in weighted spawning
} else {
// Size 5+: SmallFish/MediumFish reduced by 15%, HugeFish/BossFish increased by 100%
var weights = [{
type: 'smallFish',
weight: 10 * 0.85 * 0.9 * 1.1
},
// 8.5 - reduced by 15% then 10%
{
type: 'mediumFish',
weight: 8 * 0.85 * 0.9 * 0.9
},
// 6.8 - reduced by 15% then 10%
{
type: 'largeFish',
weight: 15 * 0.85 * 0.9 * 0.8 * 0.9
},
// 15 - reduced by 10%
{
type: 'hugeFish',
weight: 20 * 2.0 * 0.85 * 0.9 * 0.9 * (LK.getScore() >= 10000 ? 0.35 : 1) * 0.5 * 0.8 * 0.8
},
// 40 - 100% increase then 10% then 30% reduction if score >= 10000
{
type: 'bossfish',
weight: (30 * 2.0 + 20) * 0.85 * 0.85 * 0.9 * 0.9 * (LK.getScore() >= 10000 ? 0.35 : 1) * 0.5 * 0.8 * 0.8 * 0.7
} // 68 - 100% increase + size bonus then 15% reduction then 10% then 30% reduction if score >= 10000 then 20% reduction
];
// Dangerfish now spawn at specific score thresholds, not in weighted spawning
}
// Calculate total weight
var totalWeight = 0;
for (var w = 0; w < weights.length; w++) {
totalWeight += weights[w].weight;
}
// Select fish type based on weights
var randomWeight = rand * totalWeight;
var currentWeight = 0;
for (var w = 0; w < weights.length; w++) {
currentWeight += weights[w].weight;
if (randomWeight <= currentWeight) {
fishType = weights[w].type;
break;
}
}
var newFish = new Fish(fishType);
// Spawn fish from ocean edges
var edge = Math.floor(Math.random() * 4); // 0=top, 1=right, 2=bottom, 3=left
if (edge === 0) {
// Top edge
newFish.x = Math.random() * currentWidth;
newFish.y = 0;
} else if (edge === 1) {
// Right edge
newFish.x = currentWidth;
newFish.y = Math.random() * currentHeight;
} else if (edge === 2) {
// Bottom edge
newFish.x = Math.random() * currentWidth;
newFish.y = currentHeight;
} else {
// Left edge
newFish.x = 0;
newFish.y = Math.random() * currentHeight;
}
fish.push(newFish);
game.addChild(newFish);
}
var scoreTxt = new Text2('Score: 0', {
size: 80,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
var sizeTxt = new Text2('Size: 1', {
size: 60,
fill: 0xFFFFFF
});
sizeTxt.anchor.set(0, 0);
sizeTxt.x = 150;
sizeTxt.y = 100;
LK.gui.topLeft.addChild(sizeTxt);
var mouseX = octopus.x;
var mouseY = octopus.y;
var moveSpeed = 8;
var baseSpeed = 8;
var lastClickTime = 0;
var doubleClickThreshold = 300; // 300ms between clicks for double-click
var speedBoostActive = false;
var speedBoostTimer = null;
var attackMode = false;
var coins = 0;
var coinObjects = [];
var coinTxt = new Text2('Coins: 0', {
size: 60,
fill: 0xFFD700
}); //{coin_txt}
coinTxt.anchor.set(1, 0);
LK.gui.topRight.addChild(coinTxt);
var fightTxt = new Text2('FIGHT!!!', {
size: 70,
fill: 0xFF0000,
// Red color
font: "'GillSans-Bold',Impact,'Arial Black',Tahoma" // Bold font
});
fightTxt.anchor.set(1, 0);
fightTxt.y = 70; // Position below coins text
fightTxt.visible = false; // Initially hidden
LK.gui.topRight.addChild(fightTxt);
game.down = function (x, y, obj) {
var currentTime = Date.now();
if (currentTime - lastClickTime < doubleClickThreshold) {
// Double-click detected - check if we have enough coins
if (!speedBoostActive && coins >= 5) {
// Deduct coins
coins -= 5;
coinTxt.setText('Coins: ' + coins);
// Activate speed boost
speedBoostActive = true;
moveSpeed = baseSpeed * 2; // 100% speed increase
// Clear any existing timer
if (speedBoostTimer) {
LK.clearTimeout(speedBoostTimer);
}
// Set timer to reset speed after 3 seconds
speedBoostTimer = LK.setTimeout(function () {
speedBoostActive = false;
moveSpeed = baseSpeed;
speedBoostTimer = null;
}, 3000);
}
}
lastClickTime = currentTime;
};
game.move = function (x, y, obj) {
// Update mouse position for octopus to follow
mouseX = x;
mouseY = y;
};
game.update = function () {
// Move octopus towards mouse position
var dx = mouseX - octopus.x;
var dy = mouseY - octopus.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance > 5) {
// Normalize direction and apply speed
var dirX = dx / distance;
var dirY = dy / distance;
octopus.x += dirX * moveSpeed;
octopus.y += dirY * moveSpeed;
// Keep octopus within expanding ocean bounds
octopus.x = Math.max(40, Math.min(oceanWidth - 40, octopus.x));
octopus.y = Math.max(40, Math.min(oceanHeight - 40, octopus.y));
}
// Check collisions between octopus and fish
for (var i = fish.length - 1; i >= 0; i--) {
var currentFish = fish[i];
// Calculate distance between octopus and fish centers
var dx = octopus.x - currentFish.x;
var dy = octopus.y - currentFish.y;
var distance = Math.sqrt(dx * dx + dy * dy);
// Get approximate radii (half of width/height)
var octopusRadius = octopus.width / 2 * 0.8; // 80% of actual size for more forgiving collision
var fishRadius = currentFish.width / 2 * 0.8; // 80% of actual size for more forgiving collision
// Check if distance is less than combined radii (allowing more penetration)
if (distance < octopusRadius + fishRadius) {
// Special handling for dangerfish
if (currentFish.fishType === 'dangerfish') {
if (LK.getScore() < 30000) {
// Game over - octopus cannot eat dangerfish until score >= 30000
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
return;
} else {
// Win the game when dangerfish is eaten and score >= 30000
LK.showYouWin();
return;
}
} else if (octopus.canEat(currentFish)) {
// Eat the fish
var points;
if (currentFish.fishType === 'bossfish') {
points = 1000;
} else if (currentFish.fishType === 'hugeFish') {
points = 500;
} else if (currentFish.fishType === 'largeFish') {
points = 250;
} else if (currentFish.fishType === 'mediumFish') {
points = 50;
} else {
points = 10; // smallFish
}
var oldScore = LK.getScore();
LK.setScore(oldScore + points);
LK.getSound('eat').play();
// Remove fish
currentFish.destroy();
fish.splice(i, 1);
// Check if octopus should grow with exponential point requirements
var newScore = LK.getScore();
var requiredPoints = [0, 100, 600, 2600, 5600, 10000]; // Cumulative points needed for each size
// Check if we can grow to next size
if (octopus.octopusSize < requiredPoints.length && newScore >= requiredPoints[octopus.octopusSize]) {
octopus.grow();
sizeTxt.setText('Size: ' + octopus.octopusSize);
}
// Spawn fish within expanding ocean bounds (reduced by 10% from 2 to 1.8, rounded to 2)
for (var j = 0; j < 2; j++) {
var currentWidth = oceanWidth;
var currentHeight = oceanHeight;
// Weighted spawning - increase spawn rate for fish matching octopus size
var rand = Math.random();
var fishType;
// Adjust spawn rates based on octopus size
if (octopus.octopusSize === 1) {
// Size 1: SmallFish/MediumFish reduced by 15%, no huge/boss fish
var weights = [{
type: 'smallFish',
weight: 60 * 0.85 * 0.9 * 1.1
},
// 51 - reduced by 15% then 10%
{
type: 'mediumFish',
weight: 30 * 0.85 * 0.9 * 0.9
},
// 25.5 - reduced by 15% then 10%
{
type: 'largeFish',
weight: 10 * 0.85 * 0.9 * 0.8 * 0.9
}];
// Dangerfish now spawn at specific score thresholds, not in weighted spawning
} else if (octopus.octopusSize === 2) {
// Size 2: SmallFish/MediumFish reduced by 15%, no huge/boss fish
var weights = [{
type: 'smallFish',
weight: 25 * 0.85 * 0.9 * 1.1
},
// 21.25 - reduced by 15% then 10%
{
type: 'mediumFish',
weight: (50 * 0.85 + 20) * 0.9 * 0.9
},
// 62.5 - reduced by 15% + size bonus then 10%
{
type: 'largeFish',
weight: 20 * 0.85 * 0.9 * 0.8 * 0.9
}];
// Dangerfish now spawn at specific score thresholds, not in weighted spawning
} else if (octopus.octopusSize === 3) {
// Size 3: SmallFish/MediumFish reduced by 15%, HugeFish/BossFish spawn, increased by 100%
var weights = [{
type: 'smallFish',
weight: 20 * 0.85 * 0.9 * 1.1
},
// 17 - reduced by 15% then 10%
{
type: 'mediumFish',
weight: 15 * 0.85 * 0.9 * 0.9
},
// 12.75 - reduced by 15% then 10%
{
type: 'largeFish',
weight: (30 + 15) * 0.85 * 0.9 * 0.8 * 0.9
},
// 45 - size bonus then 10%
{
type: 'hugeFish',
weight: 15 * 2.0 * 0.85 * 0.9 * 0.9 * (LK.getScore() >= 10000 ? 0.35 : 1) * 0.5 * 0.8 * 0.8
},
// 30 - 100% increase then 10% then 30% reduction if score >= 10000
{
type: 'bossfish',
weight: 10 * 2.0 * 0.85 * 0.85 * 0.9 * 0.9 * (LK.getScore() >= 10000 ? 0.35 : 1) * 0.5 * 0.8 * 0.8 * 0.7
} // 17 - 100% increase then 15% reduction then 10% then 30% reduction if score >= 10000 then 20% reduction
];
// Dangerfish now spawn at specific score thresholds, not in weighted spawning
} else if (octopus.octopusSize === 4) {
// Size 4: SmallFish/MediumFish reduced by 15%, HugeFish/BossFish increased by 100%
var weights = [{
type: 'smallFish',
weight: 15 * 0.85 * 0.9 * 1.1
},
// 12.75 - reduced by 15% then 10%
{
type: 'mediumFish',
weight: 10 * 0.85 * 0.9 * 0.9
},
// 8.5 - reduced by 15% then 10%
{
type: 'largeFish',
weight: 20 * 0.85 * 0.9 * 0.8 * 0.9
},
// 20 - reduced by 10%
{
type: 'hugeFish',
weight: (25 * 2.0 + 15) * 0.85 * 0.9 * 0.9 * (LK.getScore() >= 10000 ? 0.35 : 1) * 0.5 * 0.8 * 0.8
},
// 65 - 100% increase + size bonus then 10% then 30% reduction if score >= 10000
{
type: 'bossfish',
weight: 15 * 2.0 * 0.85 * 0.85 * 0.9 * 0.9 * (LK.getScore() >= 10000 ? 0.35 : 1) * 0.5 * 0.8 * 0.8 * 0.7
} // 25.5 - 100% increase then 15% reduction then 10% then 30% reduction if score >= 10000 then 20% reduction
];
// Dangerfish now spawn at specific score thresholds, not in weighted spawning
} else {
// Size 5+: SmallFish/MediumFish reduced by 15%, HugeFish/BossFish increased by 100%
var weights = [{
type: 'smallFish',
weight: 10 * 0.85 * 0.9 * 1.1
},
// 8.5 - reduced by 15% then 10%
{
type: 'mediumFish',
weight: 8 * 0.85 * 0.9 * 0.9
},
// 6.8 - reduced by 15% then 10%
{
type: 'largeFish',
weight: 15 * 0.85 * 0.9 * 0.8 * 0.9
},
// 15 - reduced by 10%
{
type: 'hugeFish',
weight: 20 * 2.0 * 0.85 * 0.9 * 0.9 * (LK.getScore() >= 10000 ? 0.35 : 1) * 0.5 * 0.8 * 0.8
},
// 40 - 100% increase then 10% then 30% reduction if score >= 10000
{
type: 'bossfish',
weight: (30 * 2.0 + 20) * 0.85 * 0.85 * 0.9 * 0.9 * (LK.getScore() >= 10000 ? 0.35 : 1) * 0.5 * 0.8 * 0.8 * 0.7
} // 68 - 100% increase + size bonus then 15% reduction then 10% then 30% reduction if score >= 10000 then 20% reduction
];
// Dangerfish now spawn at specific score thresholds, not in weighted spawning
}
// Calculate total weight
var totalWeight = 0;
for (var w = 0; w < weights.length; w++) {
totalWeight += weights[w].weight;
}
// Select fish type based on weights
var randomWeight = rand * totalWeight;
var currentWeight = 0;
for (var w = 0; w < weights.length; w++) {
currentWeight += weights[w].weight;
if (randomWeight <= currentWeight) {
fishType = weights[w].type;
break;
}
}
var newFish = new Fish(fishType);
// Spawn fish from ocean edges
var edge = Math.floor(Math.random() * 4); // 0=top, 1=right, 2=bottom, 3=left
if (edge === 0) {
// Top edge
newFish.x = Math.random() * currentWidth;
newFish.y = 0;
} else if (edge === 1) {
// Right edge
newFish.x = currentWidth;
newFish.y = Math.random() * currentHeight;
} else if (edge === 2) {
// Bottom edge
newFish.x = Math.random() * currentWidth;
newFish.y = currentHeight;
} else {
// Left edge
newFish.x = 0;
newFish.y = Math.random() * currentHeight;
}
fish.push(newFish);
game.addChild(newFish);
}
} else {
// Game over - touched larger fish
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
return;
}
}
}
// Spawn coins randomly - 10% increase in spawn rate (163 to 147 frames)
if (LK.ticks % 147 === 0) {
// Every 2.45 seconds (10% faster than 2.7 seconds)
var newCoin = new Coin();
newCoin.x = Math.random() * oceanWidth;
newCoin.y = Math.random() * oceanHeight;
coinObjects.push(newCoin);
game.addChild(newCoin);
}
// Check coin collection
for (var k = coinObjects.length - 1; k >= 0; k--) {
var coin = coinObjects[k];
var dx = octopus.x - coin.x;
var dy = octopus.y - coin.y;
var distance = Math.sqrt(dx * dx + dy * dy);
// Scale collection radius based on octopus size for easier collection when larger
var collectionRadius = 120 + (octopus.octopusSize - 1) * 40; // Base 120, +40 per size level
if (distance < collectionRadius) {
// Coin collected - radius scales with octopus size
coins++;
coinTxt.setText('Coins: ' + coins);
// Play coin collection sound
LK.getSound('coin').play();
coin.destroy();
coinObjects.splice(k, 1);
}
}
// Update score display
scoreTxt.setText('Score: ' + LK.getScore());
// Show FIGHT!!! text when score reaches 30000
if (LK.getScore() >= 30000 && !fightTxt.visible) {
fightTxt.visible = true;
}
// Check if attack mode should be activated
if (LK.getScore() >= 6000 && !attackMode) {
attackMode = true;
}
// Score-based dangerfish spawning: spawn individual dangerfish at specific score thresholds
// First dangerfish at score 7000
if (LK.getScore() >= 7000 && !game.dangerfish1Spawned) {
game.dangerfish1Spawned = true;
var dangerFish1 = new Fish('dangerfish');
dangerFish1.x = 0;
dangerFish1.y = 0;
fish.push(dangerFish1);
game.addChild(dangerFish1);
}
// Second dangerfish at score 15000
if (LK.getScore() >= 15000 && !game.dangerfish2Spawned) {
game.dangerfish2Spawned = true;
var dangerFish2 = new Fish('dangerfish');
dangerFish2.x = oceanWidth;
dangerFish2.y = 0;
fish.push(dangerFish2);
game.addChild(dangerFish2);
}
// Third dangerfish at score 25000
if (LK.getScore() >= 25000 && !game.dangerfish3Spawned) {
game.dangerfish3Spawned = true;
var dangerFish3 = new Fish('dangerfish');
dangerFish3.x = oceanWidth / 2;
dangerFish3.y = 0;
fish.push(dangerFish3);
game.addChild(dangerFish3);
}
};
tatlı balık görseli. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
kırmızı renk tatlı balık görseli. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
yeşil renk tatlı balık görseli. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
kalamar görseli. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
okyanusun derinlikleri okyanusun üstü görünmesin renk geçişleri olabilir. 2d oyun içi asset balık olmasın
mürekkep balığı. In-Game asset. 2d. High contrast. No shadows
coin image üzerinde balık işareti olan bir madeni para altın renkte. In-Game asset. 2d. High contrast. No shadows
korkunç bir deniz canavarı. In-Game asset. 2d. High contrast. No shadows
tatlı ahtapot mor