User prompt
Bet butonunu 3x küçült
User prompt
BET Textini Bolt yap, 5X büyüt ve Bet butonunun ortasına yerleştir.
User prompt
Bacground ekle ve assetlere eklediğinde değiştirelim. Sağ üst köseye logo ekle ve logo için assetlere alan ekle.
User prompt
Please fix the bug: 'TypeError: setTimeout is not a function' in or related to this line: 'setTimeout(function () {' Line Number: 267
Code edit (1 edits merged)
Please save this source code
User prompt
Ocean's Gamble
Initial prompt
1. 🧠 Game Logic: The game is played on a 5x5 grid (25 boxes total). The user starts by selecting a bet amount. Once the game starts, the system automatically opens a random unopened box every 3 seconds. Each opened box contains either: 🐠 A Fish (reward) 🐚 A Seashell (bomb equivalent; game over) 2. 🎨 Theme & Visuals: Theme: Underwater / Ocean Background: Coral reef or aquarium scene Symbols: Fish types (5 visually distinct fish): All have the same function/value; only the appearance differs. Examples: Clownfish, Blue Tang, Goldfish, Angelfish, Lionfish. Seashell (Bomb): If revealed, the game ends and the user loses their entire bet. 3. 🔁 Game Flow: Player selects a bet amount (e.g., 10, 20, 50 units). The system randomly places 1 to 5 seashells in the grid (number is random each round). Every 3 seconds, a new unopened box is automatically revealed. If a fish is revealed: Player survives Multiplier increases Game continues If a seashell is revealed: Game ends Player loses the bet The player can "Cash Out" at any time before hitting a seashell to secure current winnings. 4. 💰 RTP & Multiplier System: The game must maintain a 96% RTP (Return to Player) over time. Each successful fish reveal increases the multiplier (e.g., 1.1x, 1.3x, 1.6x, 2.0x, 2.6x, etc.). The multiplier values should be dynamically calculated based on the remaining unopened boxes and unrevealed seashells. Probability and rewards must be balanced using statistical simulation to ensure long-term RTP. 5. 📊 Technical Requirements: Grid size: 5x5 Randomly place 1–5 seashells per round System reveals one new box every 3 seconds UI must include: Bet selection Game status (live multiplier, number of safe boxes opened) Cashout button Grid with visual feedback on opened boxes (fish/seashell) Responsive UI (mobile and web-friendly) Visuals: Animations for opening boxes Sound effects for reveal events (fish/seashell) 🧪 Optional Enhancements: Add real-time game statistics (e.g., longest win streak, highest cashout) Include animated fish swimming across the grid The unopened boxes can resemble rocks or sand piles that reveal a fish or shell when clicked
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1", { balance: 1000 }); /**** * Classes ****/ var BetButton = Container.expand(function () { var self = Container.call(this); var buttonGraphics = self.attachAsset('betButton', { anchorX: 0.5, anchorY: 0.5 }); self.betAmount = 0; self.betText = new Text2('Bet: $0', { size: 80, fill: 0xFFFFFF }); self.betText.anchor.set(0.5, 0.5); self.betText.y = -50; self.addChild(self.betText); self.setBetAmount = function (amount) { self.betAmount = amount; self.betText.setText('Bet: $' + amount); }; self.down = function (x, y, obj) { if (gameState === 'betting') { startGame(); } }; return self; }); var CashOutButton = Container.expand(function () { var self = Container.call(this); var buttonGraphics = self.attachAsset('cashOutButton', { anchorX: 0.5, anchorY: 0.5 }); self.cashOutText = new Text2('Cash Out: $0.00', { size: 80, fill: 0x000000 }); self.cashOutText.anchor.set(0.5, 0.5); self.cashOutText.y = -50; self.addChild(self.cashOutText); self.visible = false; self.updateAmount = function (amount) { self.cashOutText.setText('Cash Out: $' + amount.toFixed(2)); }; self.down = function (x, y, obj) { if (gameState === 'playing') { cashOut(); } }; return self; }); var GameBox = Container.expand(function () { var self = Container.call(this); var boxGraphics = self.attachAsset('gameBox', { anchorX: 0.5, anchorY: 0.5 }); self.isRevealed = false; self.content = null; // 'fish' or 'seashell' self.fishType = null; // 1-5 for fish types self.reveal = function () { if (self.isRevealed) return; self.isRevealed = true; if (self.content === 'seashell') { var seashell = self.attachAsset('seashell', { anchorX: 0.5, anchorY: 0.5 }); boxGraphics.tint = 0x8B4513; } else if (self.content === 'fish') { var fishAsset = 'fish' + self.fishType; var fish = self.attachAsset(fishAsset, { anchorX: 0.5, anchorY: 0.5 }); boxGraphics.tint = 0x90EE90; // Animate fish appearing fish.alpha = 0; tween(fish, { alpha: 1 }, { duration: 500 }); } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x006994 }); /**** * Game Code ****/ // Add background var background = game.attachAsset('coralBackground', { anchorX: 0, anchorY: 0, x: 0, y: 0, alpha: 0.9 }); // Game state var gameState = 'betting'; // 'betting', 'playing', 'ended' var boxes = []; var grid = []; var currentBet = 50; var currentMultiplier = 1.0; var revealedBoxes = 0; var totalSeashells = 0; var lastRevealTime = 0; var revealInterval = 1000; // 1 second var gameWinnings = 0; var playerBalance = storage.balance || 1000; // Grid size options var gridSizes = [5, 7, 9]; var currentGridIndex = 0; var currentGridSize = 5; var totalBoxes = 25; // Multiplier progression for balanced 96% RTP var multipliers = [1.1, 1.3, 1.6, 2.0, 2.6, 3.4, 4.5, 6.0, 8.0, 10.7, 14.3, 19.1, 25.5, 34.1, 45.5]; // UI Elements var betAmounts = [10, 25, 50, 100, 250]; var currentBetIndex = 2; // Create UI // Add game logo at top center var gameLogo = game.attachAsset('gameLogo', { anchorX: 0.5, anchorY: 0 }); gameLogo.x = 1024; gameLogo.y = 50; game.addChild(gameLogo); var betButton = game.addChild(new BetButton()); betButton.x = 1024; betButton.y = 2450; betButton.setBetAmount(currentBet); var cashOutButton = game.addChild(new CashOutButton()); cashOutButton.x = 1024; cashOutButton.y = 2350; var multiplierText = new Text2('Multiplier: 1.00x', { size: 60, fill: 0xFFFFFF }); multiplierText.anchor.set(0.5, 0.5); multiplierText.x = 1024; multiplierText.y = 300; game.addChild(multiplierText); var winningsText = new Text2('Winnings: $0.00', { size: 50, fill: 0xFFFFFF }); winningsText.anchor.set(0.5, 0.5); winningsText.x = 1024; winningsText.y = 400; game.addChild(winningsText); var statusText = new Text2('Bahis tutarını seç ve oyuna başla. Kırmızı balon balığı açılmadan cashout yap ve kazan.\n\nSelect bet amount and start. Cash out before the red pufferfish opens and win.', { size: 35, fill: 0xFFFF00 }); statusText.anchor.set(0.5, 0.5); statusText.x = 1024; statusText.y = 500; game.addChild(statusText); var balanceText = new Text2('Balance: $' + playerBalance, { size: 50, fill: 0x00FF00 }); balanceText.anchor.set(0.5, 0.5); balanceText.x = 1024; balanceText.y = 600; game.addChild(balanceText); // Bet control buttons var betControlButtons = []; var betControlLabels = ['-', '+', 'MIN', '25%', '50%', '75%', 'MAX']; var betControlActions = ['decrease', 'increase', 'min', 'percent25', 'percent50', 'percent75', 'max']; for (var i = 0; i < betControlLabels.length; i++) { var controlButton = new Container(); // Button background var buttonBg = controlButton.attachAsset('gameBox', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.4, scaleY: 0.4 }); buttonBg.tint = 0x4A90E2; // Button text var buttonText = new Text2(betControlLabels[i], { size: 30, fill: 0xFFFFFF }); buttonText.anchor.set(0.5, 0.5); controlButton.addChild(buttonText); // Position buttons in a row below the bet button controlButton.x = 400 + i * 180; controlButton.y = 2550; controlButton.actionType = betControlActions[i]; betControlButtons.push(controlButton); game.addChild(controlButton); } // Grid size selection buttons in top right corner var gridButtons = []; var gridButtonTexts = ['5x5', '7x7', '9x9']; for (var i = 0; i < 3; i++) { var gridButton = new Text2(gridButtonTexts[i], { size: 40, fill: i === 0 ? 0x00FF00 : 0xFFFFFF // Green for selected, white for others }); gridButton.anchor.set(0.5, 0.5); gridButton.x = 2048 - 150; // Right side gridButton.y = 200 + i * 80; // Stacked vertically below logo gridButton.gridIndex = i; gridButtons.push(gridButton); game.addChild(gridButton); } // Add logo to top right corner var logo = game.attachAsset('logo', { anchorX: 1, anchorY: 0 }); logo.x = 2048 - 50; // 50px margin from right edge logo.y = 50; // 50px margin from top edge game.addChild(logo); // Add vayabi560.com text to top left corner var websiteText = new Text2('vayabi560.com', { size: 60, fill: 0xFFFFFF, font: "bold Arial, sans-serif" }); websiteText.anchor.set(0, 0); // Top-left anchor websiteText.x = 120; // 120px from left edge to avoid platform menu websiteText.y = 350; // 350px from top edge (moved down 300px) game.addChild(websiteText); // Create grid with variable size function createGrid() { // Clear existing boxes for (var i = 0; i < boxes.length; i++) { if (boxes[i].parent) { boxes[i].parent.removeChild(boxes[i]); } } boxes = []; var boxSize = 300; // Keep boxes at 300x300 pixels var spacing = 10; // Small spacing between boxes var totalBoxSize = boxSize + spacing; var gridWidth = (currentGridSize - 1) * totalBoxSize; var gridHeight = (currentGridSize - 1) * totalBoxSize; var startX = 1024 - gridWidth / 2; // Center the grid horizontally var startY = 900; // Adjusted Y position to accommodate larger grids - moved 100px higher for (var row = 0; row < currentGridSize; row++) { for (var col = 0; col < currentGridSize; col++) { var box = new GameBox(); box.x = startX + col * totalBoxSize; box.y = startY + row * totalBoxSize; // No scaling needed - boxes stay at 300x300 boxes.push(box); game.addChild(box); } } totalBoxes = currentGridSize * currentGridSize; } // Initialize grid createGrid(); // Setup game content function setupGameContent() { // Random number of seashells (1-5, but scale with grid size) var maxSeashells = Math.min(Math.floor(totalBoxes * 0.2), Math.max(1, Math.floor(totalBoxes / 5))); totalSeashells = Math.floor(Math.random() * maxSeashells) + 1; // Create array of positions var positions = []; for (var i = 0; i < totalBoxes; i++) { positions.push(i); } // Shuffle positions for (var i = positions.length - 1; i > 0; i--) { var j = Math.floor(Math.random() * (i + 1)); var temp = positions[i]; positions[i] = positions[j]; positions[j] = temp; } // Place seashells for (var i = 0; i < totalSeashells; i++) { boxes[positions[i]].content = 'seashell'; } // Place fish for (var i = totalSeashells; i < totalBoxes; i++) { boxes[positions[i]].content = 'fish'; boxes[positions[i]].fishType = Math.floor(Math.random() * 5) + 1; } } function startGame() { // Check if player has enough balance if (playerBalance < betAmounts[currentBetIndex]) { statusText.setText('Insufficient balance!'); return; } gameState = 'playing'; currentBet = betAmounts[currentBetIndex]; // Deduct bet from balance playerBalance -= currentBet; storage.balance = playerBalance; balanceText.setText('Balance: $' + playerBalance); currentMultiplier = 1.0; revealedBoxes = 0; lastRevealTime = Date.now(); gameWinnings = currentBet; // Reset all boxes for (var i = 0; i < boxes.length; i++) { boxes[i].isRevealed = false; boxes[i].removeChildren(); var boxGraphics = boxes[i].attachAsset('gameBox', { anchorX: 0.5, anchorY: 0.5 }); } setupGameContent(); betButton.visible = false; cashOutButton.visible = true; cashOutButton.updateAmount(gameWinnings); statusText.setText('Game started! Cash out before hitting seashell!'); LK.playMusic('underwater'); } function revealNextBox() { var unrevealedBoxes = []; for (var i = 0; i < boxes.length; i++) { if (!boxes[i].isRevealed) { unrevealedBoxes.push(i); } } if (unrevealedBoxes.length === 0) { // All boxes revealed - player wins everything cashOut(); return; } // Pick random unrevealed box var randomIndex = Math.floor(Math.random() * unrevealedBoxes.length); var boxIndex = unrevealedBoxes[randomIndex]; var box = boxes[boxIndex]; box.reveal(); revealedBoxes++; if (box.content === 'seashell') { // Game over gameState = 'ended'; statusText.setText('Seashell revealed! You lost $' + currentBet); LK.getSound('seashell').play(); LK.setTimeout(function () { resetGame(); }, 3000); } else if (box.content === 'fish') { // Increase multiplier if (revealedBoxes <= multipliers.length) { currentMultiplier = multipliers[revealedBoxes - 1]; } else { currentMultiplier *= 1.5; // Continue scaling for longer games } gameWinnings = currentBet * currentMultiplier; multiplierText.setText('Multiplier: ' + currentMultiplier.toFixed(2) + 'x'); winningsText.setText('Winnings: $' + gameWinnings.toFixed(2)); cashOutButton.updateAmount(gameWinnings); statusText.setText('Fish found! Multiplier increased!'); LK.getSound('reveal').play(); } } function cashOut() { if (gameState !== 'playing') return; gameState = 'ended'; // Add winnings to balance playerBalance += gameWinnings; storage.balance = playerBalance; balanceText.setText('Balance: $' + playerBalance); LK.setScore(LK.getScore() + Math.floor(gameWinnings - currentBet)); statusText.setText('Cashed out! Won $' + (gameWinnings - currentBet).toFixed(2)); LK.getSound('cashout').play(); LK.setTimeout(function () { resetGame(); }, 3000); } function resetGame() { gameState = 'betting'; betButton.visible = true; cashOutButton.visible = false; statusText.setText('Bahis tutarını seç ve oyuna başla. Kırmızı balon balığı açılmadan cashout yap ve kazan.\n\nSelect bet amount and start. Cash out before the red pufferfish opens and win.'); multiplierText.setText('Multiplier: 1.00x'); winningsText.setText('Winnings: $0.00'); // Reset visual state of all boxes for (var i = 0; i < boxes.length; i++) { boxes[i].isRevealed = false; boxes[i].removeChildren(); var boxGraphics = boxes[i].attachAsset('gameBox', { anchorX: 0.5, anchorY: 0.5 }); } LK.stopMusic(); } // Handle bet amount cycling and grid size selection game.down = function (x, y, obj) { if (gameState === 'betting') { // Check if clicking on any grid button with expanded click area var gridButtonClicked = false; for (var i = 0; i < gridButtons.length; i++) { var button = gridButtons[i]; var buttonX = button.x; var buttonY = button.y; // Expanded click area around each button (±60px horizontally, ±40px vertically) if (x >= buttonX - 60 && x <= buttonX + 60 && y >= buttonY - 40 && y <= buttonY + 40) { currentGridIndex = i; currentGridSize = gridSizes[currentGridIndex]; totalBoxes = currentGridSize * currentGridSize; // Update button colors for (var j = 0; j < gridButtons.length; j++) { gridButtons[j].fill = j === currentGridIndex ? 0x00FF00 : 0xFFFFFF; } createGrid(); // Recreate grid with new size gridButtonClicked = true; break; } } // Check bet control buttons var betControlClicked = false; for (var i = 0; i < betControlButtons.length; i++) { var controlButton = betControlButtons[i]; var buttonX = controlButton.x; var buttonY = controlButton.y; // Check if clicking on bet control button (±60px click area) if (x >= buttonX - 60 && x <= buttonX + 60 && y >= buttonY - 60 && y <= buttonY + 60) { var newBet = currentBet; switch (controlButton.actionType) { case 'decrease': // Find current bet in array and go to previous for (var j = 0; j < betAmounts.length; j++) { if (betAmounts[j] === currentBet && j > 0) { newBet = betAmounts[j - 1]; break; } } break; case 'increase': // Find current bet in array and go to next for (var j = 0; j < betAmounts.length; j++) { if (betAmounts[j] === currentBet && j < betAmounts.length - 1) { newBet = betAmounts[j + 1]; break; } } break; case 'min': newBet = betAmounts[0]; break; case 'max': newBet = betAmounts[betAmounts.length - 1]; break; case 'percent25': newBet = Math.floor(playerBalance * 0.25); // Find closest valid bet amount for (var j = betAmounts.length - 1; j >= 0; j--) { if (betAmounts[j] <= newBet) { newBet = betAmounts[j]; break; } } break; case 'percent50': newBet = Math.floor(playerBalance * 0.5); // Find closest valid bet amount for (var j = betAmounts.length - 1; j >= 0; j--) { if (betAmounts[j] <= newBet) { newBet = betAmounts[j]; break; } } break; case 'percent75': newBet = Math.floor(playerBalance * 0.75); // Find closest valid bet amount for (var j = betAmounts.length - 1; j >= 0; j--) { if (betAmounts[j] <= newBet) { newBet = betAmounts[j]; break; } } break; } // Update bet if player can afford it if (newBet <= playerBalance && newBet > 0) { currentBet = newBet; // Find the index of this bet amount for (var j = 0; j < betAmounts.length; j++) { if (betAmounts[j] === currentBet) { currentBetIndex = j; break; } } betButton.setBetAmount(currentBet); } else { statusText.setText('Invalid bet amount or insufficient balance!'); } betControlClicked = true; break; } } if (!gridButtonClicked && !betControlClicked && y > 2350) { // Cycle through bet amounts, but only if player can afford it var nextBetIndex = (currentBetIndex + 1) % betAmounts.length; var nextBet = betAmounts[nextBetIndex]; if (nextBet <= playerBalance) { currentBetIndex = nextBetIndex; currentBet = betAmounts[currentBetIndex]; betButton.setBetAmount(currentBet); } else { statusText.setText('Not enough balance for this bet amount!'); } } } }; game.update = function () { if (gameState === 'playing') { var currentTime = Date.now(); if (currentTime - lastRevealTime >= revealInterval) { revealNextBox(); lastRevealTime = currentTime; } } };
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1", {
balance: 1000
});
/****
* Classes
****/
var BetButton = Container.expand(function () {
var self = Container.call(this);
var buttonGraphics = self.attachAsset('betButton', {
anchorX: 0.5,
anchorY: 0.5
});
self.betAmount = 0;
self.betText = new Text2('Bet: $0', {
size: 80,
fill: 0xFFFFFF
});
self.betText.anchor.set(0.5, 0.5);
self.betText.y = -50;
self.addChild(self.betText);
self.setBetAmount = function (amount) {
self.betAmount = amount;
self.betText.setText('Bet: $' + amount);
};
self.down = function (x, y, obj) {
if (gameState === 'betting') {
startGame();
}
};
return self;
});
var CashOutButton = Container.expand(function () {
var self = Container.call(this);
var buttonGraphics = self.attachAsset('cashOutButton', {
anchorX: 0.5,
anchorY: 0.5
});
self.cashOutText = new Text2('Cash Out: $0.00', {
size: 80,
fill: 0x000000
});
self.cashOutText.anchor.set(0.5, 0.5);
self.cashOutText.y = -50;
self.addChild(self.cashOutText);
self.visible = false;
self.updateAmount = function (amount) {
self.cashOutText.setText('Cash Out: $' + amount.toFixed(2));
};
self.down = function (x, y, obj) {
if (gameState === 'playing') {
cashOut();
}
};
return self;
});
var GameBox = Container.expand(function () {
var self = Container.call(this);
var boxGraphics = self.attachAsset('gameBox', {
anchorX: 0.5,
anchorY: 0.5
});
self.isRevealed = false;
self.content = null; // 'fish' or 'seashell'
self.fishType = null; // 1-5 for fish types
self.reveal = function () {
if (self.isRevealed) return;
self.isRevealed = true;
if (self.content === 'seashell') {
var seashell = self.attachAsset('seashell', {
anchorX: 0.5,
anchorY: 0.5
});
boxGraphics.tint = 0x8B4513;
} else if (self.content === 'fish') {
var fishAsset = 'fish' + self.fishType;
var fish = self.attachAsset(fishAsset, {
anchorX: 0.5,
anchorY: 0.5
});
boxGraphics.tint = 0x90EE90;
// Animate fish appearing
fish.alpha = 0;
tween(fish, {
alpha: 1
}, {
duration: 500
});
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x006994
});
/****
* Game Code
****/
// Add background
var background = game.attachAsset('coralBackground', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0,
alpha: 0.9
});
// Game state
var gameState = 'betting'; // 'betting', 'playing', 'ended'
var boxes = [];
var grid = [];
var currentBet = 50;
var currentMultiplier = 1.0;
var revealedBoxes = 0;
var totalSeashells = 0;
var lastRevealTime = 0;
var revealInterval = 1000; // 1 second
var gameWinnings = 0;
var playerBalance = storage.balance || 1000;
// Grid size options
var gridSizes = [5, 7, 9];
var currentGridIndex = 0;
var currentGridSize = 5;
var totalBoxes = 25;
// Multiplier progression for balanced 96% RTP
var multipliers = [1.1, 1.3, 1.6, 2.0, 2.6, 3.4, 4.5, 6.0, 8.0, 10.7, 14.3, 19.1, 25.5, 34.1, 45.5];
// UI Elements
var betAmounts = [10, 25, 50, 100, 250];
var currentBetIndex = 2;
// Create UI
// Add game logo at top center
var gameLogo = game.attachAsset('gameLogo', {
anchorX: 0.5,
anchorY: 0
});
gameLogo.x = 1024;
gameLogo.y = 50;
game.addChild(gameLogo);
var betButton = game.addChild(new BetButton());
betButton.x = 1024;
betButton.y = 2450;
betButton.setBetAmount(currentBet);
var cashOutButton = game.addChild(new CashOutButton());
cashOutButton.x = 1024;
cashOutButton.y = 2350;
var multiplierText = new Text2('Multiplier: 1.00x', {
size: 60,
fill: 0xFFFFFF
});
multiplierText.anchor.set(0.5, 0.5);
multiplierText.x = 1024;
multiplierText.y = 300;
game.addChild(multiplierText);
var winningsText = new Text2('Winnings: $0.00', {
size: 50,
fill: 0xFFFFFF
});
winningsText.anchor.set(0.5, 0.5);
winningsText.x = 1024;
winningsText.y = 400;
game.addChild(winningsText);
var statusText = new Text2('Bahis tutarını seç ve oyuna başla. Kırmızı balon balığı açılmadan cashout yap ve kazan.\n\nSelect bet amount and start. Cash out before the red pufferfish opens and win.', {
size: 35,
fill: 0xFFFF00
});
statusText.anchor.set(0.5, 0.5);
statusText.x = 1024;
statusText.y = 500;
game.addChild(statusText);
var balanceText = new Text2('Balance: $' + playerBalance, {
size: 50,
fill: 0x00FF00
});
balanceText.anchor.set(0.5, 0.5);
balanceText.x = 1024;
balanceText.y = 600;
game.addChild(balanceText);
// Bet control buttons
var betControlButtons = [];
var betControlLabels = ['-', '+', 'MIN', '25%', '50%', '75%', 'MAX'];
var betControlActions = ['decrease', 'increase', 'min', 'percent25', 'percent50', 'percent75', 'max'];
for (var i = 0; i < betControlLabels.length; i++) {
var controlButton = new Container();
// Button background
var buttonBg = controlButton.attachAsset('gameBox', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.4,
scaleY: 0.4
});
buttonBg.tint = 0x4A90E2;
// Button text
var buttonText = new Text2(betControlLabels[i], {
size: 30,
fill: 0xFFFFFF
});
buttonText.anchor.set(0.5, 0.5);
controlButton.addChild(buttonText);
// Position buttons in a row below the bet button
controlButton.x = 400 + i * 180;
controlButton.y = 2550;
controlButton.actionType = betControlActions[i];
betControlButtons.push(controlButton);
game.addChild(controlButton);
}
// Grid size selection buttons in top right corner
var gridButtons = [];
var gridButtonTexts = ['5x5', '7x7', '9x9'];
for (var i = 0; i < 3; i++) {
var gridButton = new Text2(gridButtonTexts[i], {
size: 40,
fill: i === 0 ? 0x00FF00 : 0xFFFFFF // Green for selected, white for others
});
gridButton.anchor.set(0.5, 0.5);
gridButton.x = 2048 - 150; // Right side
gridButton.y = 200 + i * 80; // Stacked vertically below logo
gridButton.gridIndex = i;
gridButtons.push(gridButton);
game.addChild(gridButton);
}
// Add logo to top right corner
var logo = game.attachAsset('logo', {
anchorX: 1,
anchorY: 0
});
logo.x = 2048 - 50; // 50px margin from right edge
logo.y = 50; // 50px margin from top edge
game.addChild(logo);
// Add vayabi560.com text to top left corner
var websiteText = new Text2('vayabi560.com', {
size: 60,
fill: 0xFFFFFF,
font: "bold Arial, sans-serif"
});
websiteText.anchor.set(0, 0); // Top-left anchor
websiteText.x = 120; // 120px from left edge to avoid platform menu
websiteText.y = 350; // 350px from top edge (moved down 300px)
game.addChild(websiteText);
// Create grid with variable size
function createGrid() {
// Clear existing boxes
for (var i = 0; i < boxes.length; i++) {
if (boxes[i].parent) {
boxes[i].parent.removeChild(boxes[i]);
}
}
boxes = [];
var boxSize = 300; // Keep boxes at 300x300 pixels
var spacing = 10; // Small spacing between boxes
var totalBoxSize = boxSize + spacing;
var gridWidth = (currentGridSize - 1) * totalBoxSize;
var gridHeight = (currentGridSize - 1) * totalBoxSize;
var startX = 1024 - gridWidth / 2; // Center the grid horizontally
var startY = 900; // Adjusted Y position to accommodate larger grids - moved 100px higher
for (var row = 0; row < currentGridSize; row++) {
for (var col = 0; col < currentGridSize; col++) {
var box = new GameBox();
box.x = startX + col * totalBoxSize;
box.y = startY + row * totalBoxSize;
// No scaling needed - boxes stay at 300x300
boxes.push(box);
game.addChild(box);
}
}
totalBoxes = currentGridSize * currentGridSize;
}
// Initialize grid
createGrid();
// Setup game content
function setupGameContent() {
// Random number of seashells (1-5, but scale with grid size)
var maxSeashells = Math.min(Math.floor(totalBoxes * 0.2), Math.max(1, Math.floor(totalBoxes / 5)));
totalSeashells = Math.floor(Math.random() * maxSeashells) + 1;
// Create array of positions
var positions = [];
for (var i = 0; i < totalBoxes; i++) {
positions.push(i);
}
// Shuffle positions
for (var i = positions.length - 1; i > 0; i--) {
var j = Math.floor(Math.random() * (i + 1));
var temp = positions[i];
positions[i] = positions[j];
positions[j] = temp;
}
// Place seashells
for (var i = 0; i < totalSeashells; i++) {
boxes[positions[i]].content = 'seashell';
}
// Place fish
for (var i = totalSeashells; i < totalBoxes; i++) {
boxes[positions[i]].content = 'fish';
boxes[positions[i]].fishType = Math.floor(Math.random() * 5) + 1;
}
}
function startGame() {
// Check if player has enough balance
if (playerBalance < betAmounts[currentBetIndex]) {
statusText.setText('Insufficient balance!');
return;
}
gameState = 'playing';
currentBet = betAmounts[currentBetIndex];
// Deduct bet from balance
playerBalance -= currentBet;
storage.balance = playerBalance;
balanceText.setText('Balance: $' + playerBalance);
currentMultiplier = 1.0;
revealedBoxes = 0;
lastRevealTime = Date.now();
gameWinnings = currentBet;
// Reset all boxes
for (var i = 0; i < boxes.length; i++) {
boxes[i].isRevealed = false;
boxes[i].removeChildren();
var boxGraphics = boxes[i].attachAsset('gameBox', {
anchorX: 0.5,
anchorY: 0.5
});
}
setupGameContent();
betButton.visible = false;
cashOutButton.visible = true;
cashOutButton.updateAmount(gameWinnings);
statusText.setText('Game started! Cash out before hitting seashell!');
LK.playMusic('underwater');
}
function revealNextBox() {
var unrevealedBoxes = [];
for (var i = 0; i < boxes.length; i++) {
if (!boxes[i].isRevealed) {
unrevealedBoxes.push(i);
}
}
if (unrevealedBoxes.length === 0) {
// All boxes revealed - player wins everything
cashOut();
return;
}
// Pick random unrevealed box
var randomIndex = Math.floor(Math.random() * unrevealedBoxes.length);
var boxIndex = unrevealedBoxes[randomIndex];
var box = boxes[boxIndex];
box.reveal();
revealedBoxes++;
if (box.content === 'seashell') {
// Game over
gameState = 'ended';
statusText.setText('Seashell revealed! You lost $' + currentBet);
LK.getSound('seashell').play();
LK.setTimeout(function () {
resetGame();
}, 3000);
} else if (box.content === 'fish') {
// Increase multiplier
if (revealedBoxes <= multipliers.length) {
currentMultiplier = multipliers[revealedBoxes - 1];
} else {
currentMultiplier *= 1.5; // Continue scaling for longer games
}
gameWinnings = currentBet * currentMultiplier;
multiplierText.setText('Multiplier: ' + currentMultiplier.toFixed(2) + 'x');
winningsText.setText('Winnings: $' + gameWinnings.toFixed(2));
cashOutButton.updateAmount(gameWinnings);
statusText.setText('Fish found! Multiplier increased!');
LK.getSound('reveal').play();
}
}
function cashOut() {
if (gameState !== 'playing') return;
gameState = 'ended';
// Add winnings to balance
playerBalance += gameWinnings;
storage.balance = playerBalance;
balanceText.setText('Balance: $' + playerBalance);
LK.setScore(LK.getScore() + Math.floor(gameWinnings - currentBet));
statusText.setText('Cashed out! Won $' + (gameWinnings - currentBet).toFixed(2));
LK.getSound('cashout').play();
LK.setTimeout(function () {
resetGame();
}, 3000);
}
function resetGame() {
gameState = 'betting';
betButton.visible = true;
cashOutButton.visible = false;
statusText.setText('Bahis tutarını seç ve oyuna başla. Kırmızı balon balığı açılmadan cashout yap ve kazan.\n\nSelect bet amount and start. Cash out before the red pufferfish opens and win.');
multiplierText.setText('Multiplier: 1.00x');
winningsText.setText('Winnings: $0.00');
// Reset visual state of all boxes
for (var i = 0; i < boxes.length; i++) {
boxes[i].isRevealed = false;
boxes[i].removeChildren();
var boxGraphics = boxes[i].attachAsset('gameBox', {
anchorX: 0.5,
anchorY: 0.5
});
}
LK.stopMusic();
}
// Handle bet amount cycling and grid size selection
game.down = function (x, y, obj) {
if (gameState === 'betting') {
// Check if clicking on any grid button with expanded click area
var gridButtonClicked = false;
for (var i = 0; i < gridButtons.length; i++) {
var button = gridButtons[i];
var buttonX = button.x;
var buttonY = button.y;
// Expanded click area around each button (±60px horizontally, ±40px vertically)
if (x >= buttonX - 60 && x <= buttonX + 60 && y >= buttonY - 40 && y <= buttonY + 40) {
currentGridIndex = i;
currentGridSize = gridSizes[currentGridIndex];
totalBoxes = currentGridSize * currentGridSize;
// Update button colors
for (var j = 0; j < gridButtons.length; j++) {
gridButtons[j].fill = j === currentGridIndex ? 0x00FF00 : 0xFFFFFF;
}
createGrid(); // Recreate grid with new size
gridButtonClicked = true;
break;
}
}
// Check bet control buttons
var betControlClicked = false;
for (var i = 0; i < betControlButtons.length; i++) {
var controlButton = betControlButtons[i];
var buttonX = controlButton.x;
var buttonY = controlButton.y;
// Check if clicking on bet control button (±60px click area)
if (x >= buttonX - 60 && x <= buttonX + 60 && y >= buttonY - 60 && y <= buttonY + 60) {
var newBet = currentBet;
switch (controlButton.actionType) {
case 'decrease':
// Find current bet in array and go to previous
for (var j = 0; j < betAmounts.length; j++) {
if (betAmounts[j] === currentBet && j > 0) {
newBet = betAmounts[j - 1];
break;
}
}
break;
case 'increase':
// Find current bet in array and go to next
for (var j = 0; j < betAmounts.length; j++) {
if (betAmounts[j] === currentBet && j < betAmounts.length - 1) {
newBet = betAmounts[j + 1];
break;
}
}
break;
case 'min':
newBet = betAmounts[0];
break;
case 'max':
newBet = betAmounts[betAmounts.length - 1];
break;
case 'percent25':
newBet = Math.floor(playerBalance * 0.25);
// Find closest valid bet amount
for (var j = betAmounts.length - 1; j >= 0; j--) {
if (betAmounts[j] <= newBet) {
newBet = betAmounts[j];
break;
}
}
break;
case 'percent50':
newBet = Math.floor(playerBalance * 0.5);
// Find closest valid bet amount
for (var j = betAmounts.length - 1; j >= 0; j--) {
if (betAmounts[j] <= newBet) {
newBet = betAmounts[j];
break;
}
}
break;
case 'percent75':
newBet = Math.floor(playerBalance * 0.75);
// Find closest valid bet amount
for (var j = betAmounts.length - 1; j >= 0; j--) {
if (betAmounts[j] <= newBet) {
newBet = betAmounts[j];
break;
}
}
break;
}
// Update bet if player can afford it
if (newBet <= playerBalance && newBet > 0) {
currentBet = newBet;
// Find the index of this bet amount
for (var j = 0; j < betAmounts.length; j++) {
if (betAmounts[j] === currentBet) {
currentBetIndex = j;
break;
}
}
betButton.setBetAmount(currentBet);
} else {
statusText.setText('Invalid bet amount or insufficient balance!');
}
betControlClicked = true;
break;
}
}
if (!gridButtonClicked && !betControlClicked && y > 2350) {
// Cycle through bet amounts, but only if player can afford it
var nextBetIndex = (currentBetIndex + 1) % betAmounts.length;
var nextBet = betAmounts[nextBetIndex];
if (nextBet <= playerBalance) {
currentBetIndex = nextBetIndex;
currentBet = betAmounts[currentBetIndex];
betButton.setBetAmount(currentBet);
} else {
statusText.setText('Not enough balance for this bet amount!');
}
}
}
};
game.update = function () {
if (gameState === 'playing') {
var currentTime = Date.now();
if (currentTime - lastRevealTime >= revealInterval) {
revealNextBox();
lastRevealTime = currentTime;
}
}
};
A fantasy underwater scene in a dark deep ocean, illustrated in highly detailed fantasy art style. The background is a dark abyss with faint rays of light piercing from above, casting soft glows through the water. At the bottom of the scene, vibrant and colorful coral reefs in hues of red, purple, teal, and orange spread across the sea floor. Exotic fish swim gently among the coral. The entire scene is viewed with a cinematic wide angle. Shadows of sea creatures loom faintly in the background. The water has particles suspended, giving it a mysterious and immersive depth. Bioluminescent algae softly glow in some areas of the coral. The overall tone is mysterious yet magical. Black background base. Ideal for a 5x5 grid overlay. No text, pure environment. 4K ultra-detailed fantasy illustration.. In-Game asset. 2d. High contrast. No shadows