User prompt
Update with: var leftColumnUpgrades = [ ['player', 'lungCapacity'], ['player', 'quickBreath'], ['player', 'autoPop'] // Added here ]; var rightColumnUpgrades = [ ['machines', 'basicClam'], ['machines', 'advancedClam'], ['machines', 'premiumClam'], ['machine', 'bubbleDurability'], ['machine', 'autoBubbleSpeed'] // autoPop removed from here ];
Code edit (1 edits merged)
Please save this source code
User prompt
Update with: // Inside game.update, after other updates if (UPGRADE_CONFIG.player.autoPop.currentLevel > 0) { // Spawn fish every 5 seconds (300 frames), reduced by level if (LK.ticks % Math.max(120, 300 - UPGRADE_CONFIG.player.autoPop.currentLevel * 30) === 0) { var fish = new Fish(); game.addChild(fish); } }
Code edit (1 edits merged)
Please save this source code
User prompt
Update as needed: Move the localX/localY calculation to the start of the menuOpen block: ```javascript if (menuOpen) { var localX = x - menuContainer.x; var localY = y - menuContainer.y;
User prompt
Update only as needed: if (localX >= menuBounds.x && localX <= menuBounds.x + menuBounds.width && localY >= menuBounds.y && localY <= menuBounds.y + menuBounds.height) { // Check for upgrade clicks var textLocalY = localY - menuTextContainer.y;
User prompt
Update only as needed: Add a return true at the end of the menu bounds check (before the else): ```javascript } return true; // Click was inside menu but not on upgrade } else {
User prompt
Update only as needed with: if (menuOpen) { var localX = x - menuContainer.x; var localY = y - menuContainer.y; var menuBounds = { x: -menuPanel.width / 2, y: -menuPanel.height, width: menuPanel.width, height: menuPanel.height + menuTab.height }; // First check if click is within menu bounds if (localX >= menuBounds.x && localX <= menuBounds.x + menuBounds.width && localY >= menuBounds.y && localY <= menuBounds.y + menuBounds.height) { // Check for upgrade clicks var textLocalY = localY - menuTextContainer.y; for (var i = 0; i < upgradeTexts.length; i++) { var text = upgradeTexts[i]; if (text.upgrade && text.category) { // Only check name texts, not cost texts // Check if click is within text bounds if (Math.abs(localX - text.x) < 400 && Math.abs(textLocalY - text.y) < 50) { var upgrade = UPGRADE_CONFIG[text.category][text.upgrade]; var cost = getUpgradeCost(upgrade); // Check if we can afford it if (game.bp >= cost) { // Handle machines differently if (text.category === 'machines') { upgrade.amount++; } else { // Check max level if (upgrade.currentLevel < upgrade.maxLevel) { upgrade.currentLevel++; } else { return true; } } // Deduct cost game.bp -= cost; bpText.setText(formatBP(game.bp) + " BP"); // Update cost display upgradeTexts[i + 1].setText(getUpgradeCost(upgrade) + " BP"); } return true; } } } return true; // Click was inside menu but not on upgrade } else { // Click was outside menu bounds menuOpen = false; tween(menuContainer, { y: game.height }, { duration: 300, easing: tween.easeInBack }); return true; } }
User prompt
Update as needed with: if (menuOpen) { var localX = x - menuContainer.x; var localY = y - menuContainer.y; // Check for upgrade clicks first for (var i = 0; i < upgradeTexts.length; i++) { var text = upgradeTexts[i]; if (text.upgrade && text.category) { if (Math.abs(localX - text.x) < 400 && Math.abs(localY - text.y) < 50) { var upgrade = UPGRADE_CONFIG[text.category][text.upgrade]; var cost = getUpgradeCost(upgrade); if (game.bp >= cost) { if (text.category === 'machines') { upgrade.amount++; } else if (upgrade.currentLevel < upgrade.maxLevel) { upgrade.currentLevel++; } game.bp -= cost; bpText.setText(formatBP(game.bp) + " BP"); upgradeTexts[i + 1].setText(getUpgradeCost(upgrade) + " BP"); } return true; } } } // If we didn't click an upgrade, check if we clicked outside the menu panel if (localY > 0) { // Simple check - if click is below the menu panel menuOpen = false; tween(menuContainer, { y: game.height }, { duration: 300, easing: tween.easeInBack }); } return true; }
User prompt
Update with: if (menuOpen) { // Calculate position relative to menuTextContainer var localX = x - menuContainer.x - menuTextContainer.x; var localY = y - menuContainer.y - menuTextContainer.y; // Check for upgrade clicks for (var i = 0; i < upgradeTexts.length; i++) { var text = upgradeTexts[i]; if (text.upgrade && text.category) { if (Math.abs(localX - text.x) < 400 && Math.abs(localY - text.y) < 50) { var upgrade = UPGRADE_CONFIG[text.category][text.upgrade]; var cost = getUpgradeCost(upgrade); if (game.bp >= cost) { if (text.category === 'machines') { upgrade.amount++; } else if (upgrade.currentLevel < upgrade.maxLevel) { upgrade.currentLevel++; } game.bp -= cost; bpText.setText(formatBP(game.bp) + " BP"); upgradeTexts[i + 1].setText(getUpgradeCost(upgrade) + " BP"); } return true; } } } // If we didn't click an upgrade, check if we clicked outside the menu if (y > menuContainer.y) { menuOpen = false; tween(menuContainer, { y: game.height }, { duration: 300, easing: tween.easeInBack }); } return true; }
User prompt
update with: if (menuOpen) { // Normalize click position relative to the menu panel var panelX = x - menuContainer.x; var panelY = y - menuContainer.y; // Check if click is within the panel bounds var panelBounds = { x: -menuPanel.width * menuPanel.scaleX / 2, y: -menuPanel.height * menuPanel.scaleY, width: menuPanel.width * menuPanel.scaleX, height: menuPanel.height * menuPanel.scaleY }; if (panelY < 0 && // Above the bottom of the screen panelX >= panelBounds.x && panelX <= panelBounds.x + panelBounds.width && panelY >= panelBounds.y && panelY <= panelBounds.y + panelBounds.height) { // Check each upgrade text for (var i = 0; i < upgradeTexts.length; i++) { var text = upgradeTexts[i]; if (text.upgrade && text.category) { // Create larger hit area around text var hitBounds = { x: text.x - 500, // Wider click area y: text.y - 75, // Taller click area width: 1000, // Total width of hit area height: 150 // Total height of hit area }; if (panelX >= hitBounds.x && panelX <= hitBounds.x + hitBounds.width && panelY >= hitBounds.y && panelY <= hitBounds.y + hitBounds.height) { var upgrade = UPGRADE_CONFIG[text.category][text.upgrade]; var cost = getUpgradeCost(upgrade); if (game.bp >= cost) { if (text.category === 'machines') { upgrade.amount++; } else if (upgrade.currentLevel < upgrade.maxLevel) { upgrade.currentLevel++; } game.bp -= cost; bpText.setText(formatBP(game.bp) + " BP"); upgradeTexts[i + 1].setText(getUpgradeCost(upgrade) + " BP"); } return true; } } } return true; // Clicked in panel but not on upgrade } // Close menu if clicked outside panel menuOpen = false; tween(menuContainer, { y: game.height }, { duration: 300, easing: tween.easeInBack }); return true; }
User prompt
replace game.down with:game.down = function(x, y, obj) { console.log('Click at:', x, y); console.log('Menu container position:', menuContainer.x, menuContainer.y); console.log('Menu open:', menuOpen); // Convert to local coordinates for container var localX = x - menuContainer.x; var localY = y - menuContainer.y; // Check if clicked on menu tab var tabBounds = { x: -menuTab.width * menuTab.scaleX / 2, y: -menuTab.height * menuTab.scaleY, width: menuTab.width * menuTab.scaleX, height: menuTab.height * menuTab.scaleY }; if (localX >= tabBounds.x && localX <= tabBounds.x + tabBounds.width && localY >= tabBounds.y && localY <= tabBounds.y + tabBounds.height) { menuOpen = !menuOpen; var targetY = menuOpen ? menuTab.height : game.height; // Move menu to top when opening if (menuOpen) { game.setChildIndex(menuContainer, game.children.length - 1); } tween(menuContainer, { y: targetY }, { duration: 300, easing: tween.easeOutBack, onFinish: function() { // Move menu back down in z-index when closed if (!menuOpen) { game.setChildIndex(menuContainer, 1); } } }); return true; } if (menuOpen) { // Get global positions var containerGlobalPos = { x: menuContainer.x, y: menuContainer.y }; // Check each upgrade text for (var i = 0; i < upgradeTexts.length; i++) { var text = upgradeTexts[i]; if (text.upgrade && text.category) { // Get text's global position var textGlobalX = text.x + menuTextContainer.x + containerGlobalPos.x; var textGlobalY = text.y + menuTextContainer.y + containerGlobalPos.y; console.log('Text global pos:', text.upgrade, textGlobalX, textGlobalY); // Create hit area in global coordinates var hitArea = { x: textGlobalX - 400, y: textGlobalY - 50, width: 800, height: 100 }; // Check if click is within hit area if (x >= hitArea.x && x <= hitArea.x + hitArea.width && y >= hitArea.y && y <= hitArea.y + hitArea.height) { console.log('Hit detected on:', text.upgrade); var upgrade = UPGRADE_CONFIG[text.category][text.upgrade]; var cost = getUpgradeCost(upgrade); if (game.bp >= cost) { if (text.category === 'machines') { upgrade.amount++; } else if (upgrade.currentLevel < upgrade.maxLevel) { upgrade.currentLevel++; } game.bp -= cost; bpText.setText(formatBP(game.bp) + " BP"); upgradeTexts[i + 1].setText(getUpgradeCost(upgrade) + " BP"); } return true; } } } // If we clicked within the menu panel area (above screen bottom), don't close if (localY < 0) { return true; } // Close menu if clicked outside menuOpen = false; tween(menuContainer, { y: game.height }, { duration: 300, easing: tween.easeInBack }); return true; } // Bubble popping logic var popped = false; for (var i = game.bubbles.length - 1; i >= 0; i--) { var bubble = game.bubbles[i]; var dx = x - bubble.x; var dy = y - bubble.y; var distance = Math.sqrt(dx * dx + dy * dy); if (!popped && distance <= bubble.size / 2 + 10 && bubble.down) { bubble.down(); popped = true; break; } } };
User prompt
update with: if (menuOpen) { // Check each upgrade text for (var i = 0; i < upgradeTexts.length; i++) { var text = upgradeTexts[i]; if (text.upgrade && text.category) { // Calculate hit area relative to menu container var hitArea = { x: text.x - 400, // Wide hit area y: text.y - 50, // Tall hit area width: 800, height: 100 }; // Check if click (in local coordinates) is within hit area if (localX >= hitArea.x && localX <= hitArea.x + hitArea.width && localY >= hitArea.y && localY <= hitArea.y + hitArea.height) { console.log('Hit detected on:', text.upgrade); var upgrade = UPGRADE_CONFIG[text.category][text.upgrade]; var cost = getUpgradeCost(upgrade); if (game.bp >= cost) { if (text.category === 'machines') { upgrade.amount++; } else if (upgrade.currentLevel < upgrade.maxLevel) { upgrade.currentLevel++; } game.bp -= cost; bpText.setText(formatBP(game.bp) + " BP"); upgradeTexts[i + 1].setText(getUpgradeCost(upgrade) + " BP"); } return true; } } }
User prompt
update with: game.down = function(x, y, obj) { console.log('Click at:', x, y); // Convert to local coordinates for container var localX = x - menuContainer.x; var localY = y - menuContainer.y; // Check if clicked on menu tab var tabBounds = { x: -menuTab.width * menuTab.scaleX / 2, y: -menuTab.height * menuTab.scaleY, width: menuTab.width * menuTab.scaleX, height: menuTab.height * menuTab.scaleY }; // Handle tab click if (localX >= tabBounds.x && localX <= tabBounds.x + tabBounds.width && localY >= tabBounds.y && localY <= tabBounds.y + tabBounds.height) { menuOpen = !menuOpen; var targetY = menuOpen ? menuTab.height : game.height; if (menuOpen) { game.setChildIndex(menuContainer, game.children.length - 1); } tween(menuContainer, { y: targetY }, { duration: 300, easing: tween.easeOutBack, onFinish: function() { if (!menuOpen) { game.setChildIndex(menuContainer, 1); } } }); return true; } // If menu is open, handle menu interactions if (menuOpen) { // Define panel bounds var panelBounds = { x: -menuPanel.width * menuPanel.scaleX / 2, y: -menuPanel.height * menuPanel.scaleY, width: menuPanel.width * menuPanel.scaleX, height: menuPanel.height * menuPanel.scaleY }; // If click is within panel bounds if (localX >= panelBounds.x && localX <= panelBounds.x + panelBounds.width && localY >= panelBounds.y && localY <= panelBounds.y + panelBounds.height) { // Check upgrades for (var i = 0; i < upgradeTexts.length; i++) { var text = upgradeTexts[i]; if (text.upgrade && text.category) { var hitArea = { x: text.x - 400, y: text.y - 50, width: 800, height: 100 }; if (localX >= hitArea.x && localX <= hitArea.x + hitArea.width && localY >= hitArea.y && localY <= hitArea.y + hitArea.height) { console.log('Hit detected on:', text.upgrade); var upgrade = UPGRADE_CONFIG[text.category][text.upgrade]; var cost = getUpgradeCost(upgrade); if (game.bp >= cost) { if (text.category === 'machines') { upgrade.amount++; } else if (upgrade.currentLevel < upgrade.maxLevel) { upgrade.currentLevel++; } game.bp -= cost; bpText.setText(formatBP(game.bp) + " BP"); upgradeTexts[i + 1].setText(getUpgradeCost(upgrade) + " BP"); } return true; } } } return true; // Click was in panel but not on upgrade } // Click was outside panel, close menu menuOpen = false; tween(menuContainer, { y: game.height }, { duration: 300, easing: tween.easeInBack }); return true; } // Handle bubble popping var popped = false; for (var i = game.bubbles.length - 1; i >= 0; i--) { var bubble = game.bubbles[i]; var dx = x - bubble.x; var dy = y - bubble.y; var distance = Math.sqrt(dx * dx + dy * dy); if (!popped && distance <= bubble.size / 2 + 10 && bubble.down) { bubble.down(); popped = true; break; } } };
User prompt
update with: // Add this right after calculating localX/localY if (menuOpen) { localY += (game.height - menuTab.height); // Adjust for menu's open position } // Rest of the bounds checking remains the same
User prompt
update with: game.down = function(x, y, obj) { // Get container-relative coordinates var localX = x - menuContainer.x; var localY = y - menuContainer.y; // Check tab click first (no changes needed here) var tabBounds = { x: -menuTab.width * menuTab.scaleX / 2, y: -menuTab.height * menuTab.scaleY, width: menuTab.width * menuTab.scaleX, height: menuTab.height * menuTab.scaleY }; if (localX >= tabBounds.x && localX <= tabBounds.x + tabBounds.width && localY >= tabBounds.y && localY <= tabBounds.y + tabBounds.height) { // Tab click handling (no changes) return true; } // If menu is open, handle menu interactions if (menuOpen) { // Transform coordinates to account for panel's scale var panelLocalX = localX / menuPanel.scaleX; var panelLocalY = localY / menuPanel.scaleY; // Use unscaled panel dimensions for bounds var panelBounds = { x: -menuPanel.width / 2, y: -menuPanel.height, width: menuPanel.width, height: menuPanel.height }; // Check against unscaled bounds if (panelLocalX >= panelBounds.x && panelLocalX <= panelBounds.x + panelBounds.width && panelLocalY >= panelBounds.y && panelLocalY <= panelBounds.y + panelBounds.height) { // Update upgrade hit detection to use same coordinate space for (var i = 0; i < upgradeTexts.length; i++) { var text = upgradeTexts[i]; if (text.upgrade && text.category) { var hitArea = { x: text.x / menuPanel.scaleX - 400, y: text.y / menuPanel.scaleY - 50, width: 800, height: 100 }; if (panelLocalX >= hitArea.x && panelLocalX <= hitArea.x + hitArea.width && panelLocalY >= hitArea.y && panelLocalY <= hitArea.y + hitArea.height) { // Upgrade click handling (no changes needed) return true; } } } return true; // Click was in panel but not on upgrade } } // Rest of the function (bubble handling) remains the same }
Code edit (1 edits merged)
Please save this source code
User prompt
update only as needed with: if (menuOpen) { var panelLocalX = localX / menuPanel.scaleX; var panelLocalY = localY / menuPanel.scaleY; console.log('Click at:', x, y); console.log('Local to container:', localX, localY); console.log('Local to panel:', panelLocalX, panelLocalY); var panelBounds = { x: -menuPanel.width / 2, y: -menuPanel.height, width: menuPanel.width, height: menuPanel.height }; if (panelLocalX >= panelBounds.x && panelLocalX <= panelBounds.x + panelBounds.width && panelLocalY >= panelBounds.y && panelLocalY <= panelBounds.y + panelBounds.height) { for (var i = 0; i < upgradeTexts.length; i++) { var text = upgradeTexts[i]; if (text.upgrade && text.category) { // Don't transform text coordinates - they're already in the right space var hitArea = { x: text.x - 400, y: text.y - 50, width: 800, height: 100 }; console.log('Checking upgrade:', text.upgrade); console.log('Hit area:', hitArea); console.log('Click relative to text:', localX, localY); if (localX >= hitArea.x && localX <= hitArea.x + hitArea.width && localY >= hitArea.y && localY <= hitArea.y + hitArea.height) { console.log('Hit detected on:', text.upgrade); var upgrade = UPGRADE_CONFIG[text.category][text.upgrade]; var cost = getUpgradeCost(upgrade); if (game.bp >= cost) { if (text.category === 'machines') { upgrade.amount++; } else if (upgrade.currentLevel < upgrade.maxLevel) { upgrade.currentLevel++; } game.bp -= cost; bpText.setText(formatBP(game.bp) + " BP"); upgradeTexts[i + 1].setText(getUpgradeCost(upgrade) + " BP"); } return true; } } } return true; } }
User prompt
update as needed with: game.down = function(x, y, obj) { var localX = x - menuContainer.x; var localY = y - menuContainer.y; // Tab handling stays the same... if (menuOpen) { // Keep tracking the raw coordinates var rawLocalX = localX; var rawLocalY = localY; console.log('Click raw local:', rawLocalX, rawLocalY); for (var i = 0; i < upgradeTexts.length; i++) { var text = upgradeTexts[i]; if (text.upgrade && text.category) { var hitArea = { x: text.x - 400, y: text.y - 50, width: 800, height: 100 }; console.log('Testing upgrade:', text.upgrade, 'at', hitArea); // Compare using raw coordinates if (rawLocalX >= hitArea.x && rawLocalX <= hitArea.x + hitArea.width && rawLocalY >= hitArea.y && rawLocalY <= hitArea.y + hitArea.height) { console.log('Hit detected on:', text.upgrade); var upgrade = UPGRADE_CONFIG[text.category][text.upgrade]; var cost = getUpgradeCost(upgrade); if (game.bp >= cost) { if (text.category === 'machines') { upgrade.amount++; } else if (upgrade.currentLevel < upgrade.maxLevel) { upgrade.currentLevel++; } game.bp -= cost; bpText.setText(formatBP(game.bp) + " BP"); upgradeTexts[i + 1].setText(getUpgradeCost(upgrade) + " BP"); } return true; } } } return true; // Click was in panel } // Bubble popping stays the same... };
User prompt
update with: game.down = function(x, y, obj) { var localX = x - menuContainer.x; var localY = y - menuContainer.y; // Tab handling stays the same... if (menuOpen) { console.log('Click raw local:', localX, localY); for (var i = 0; i < upgradeTexts.length; i++) { var text = upgradeTexts[i]; if (text.upgrade && text.category) { // Adjust hit area to match actual click coordinates var hitArea = { x: text.x - 200, // Reduced from 400 y: text.y - 25, // Reduced from 50 width: 400, // Reduced from 800 height: 50 // Reduced from 100 }; console.log('Testing upgrade:', text.upgrade, 'at', hitArea); if (localX >= hitArea.x && localX <= hitArea.x + hitArea.width && localY >= hitArea.y && localY <= hitArea.y + hitArea.height) { console.log('Hit detected on:', text.upgrade); var upgrade = UPGRADE_CONFIG[text.category][text.upgrade]; var cost = getUpgradeCost(upgrade); if (game.bp >= cost) { if (text.category === 'machines') { upgrade.amount++; } else if (upgrade.currentLevel < upgrade.maxLevel) { upgrade.currentLevel++; } game.bp -= cost; bpText.setText(formatBP(game.bp) + " BP"); upgradeTexts[i + 1].setText(getUpgradeCost(upgrade) + " BP"); } return true; } } } return true; // Click was in panel } // Bubble popping stays the same... };
User prompt
update as needed with: // First, in the text creation part where we position the upgrades: function createUpgradeText(category, key, index, isLeftColumn) { // ... text creation stays same ... // Adjust xOffset for better positioning var xOffset = isLeftColumn ? -700 : 100; // Changed from -924 nameText.x = xOffset; nameText.y = startY + index * upgradeSpacing; costText.x = xOffset; costText.y = startY + index * upgradeSpacing + 100; // ... rest stays same ... } // Then in game.down: if (menuOpen) { console.log('Click raw local:', localX, localY); for (var i = 0; i < upgradeTexts.length; i++) { var text = upgradeTexts[i]; if (text.upgrade && text.category) { var hitArea = { x: text.x - 150, // Adjusted to be closer to text y: text.y - 40, // Adjusted for better vertical hit width: 300, // Width of clickable area height: 80 // Height to cover both name and cost }; console.log('Testing upgrade:', text.upgrade, 'at', hitArea); if (localX >= hitArea.x && localX <= hitArea.x + hitArea.width && localY >= hitArea.y && localY <= hitArea.y + hitArea.height) { console.log('Hit detected on:', text.upgrade); // ... upgrade handling stays same ... } } } return true; }
User prompt
update as needed with: // In createUpgradeText: function createUpgradeText(category, key, index, isLeftColumn) { // ... text creation stays same ... // Move left column closer to click positions var xOffset = isLeftColumn ? -600 : 100; // Changed from -700 nameText.x = xOffset; nameText.y = startY + index * upgradeSpacing; costText.x = xOffset; costText.y = startY + index * upgradeSpacing + 100; // ... rest stays same ... } // In game.down: if (menuOpen) { console.log('Click raw local:', localX, localY); for (var i = 0; i < upgradeTexts.length; i++) { var text = upgradeTexts[i]; if (text.upgrade && text.category) { var hitArea = { x: text.x - 100, // Smaller offset from text y: text.y - 40, width: 200, // Tighter hit area height: 150 // Taller to ensure we catch the entire button }; // Add debug visualization if needed console.log(`Click at ${localX},${localY} checking against hitArea at ${text.x},${text.y} for ${text.upgrade}`); if (localX >= hitArea.x && localX <= hitArea.x + hitArea.width && localY >= hitArea.y && localY <= hitArea.y + hitArea.height) { // ... upgrade handling stays same ... } } } return true; }
User prompt
update as needed with: // In createUpgradeText: function createUpgradeText(category, key, index, isLeftColumn) { // ... text creation same ... // Center text where people are clicking var xOffset = isLeftColumn ? -550 : 100; // Centered around where clicks happen nameText.x = xOffset; nameText.y = startY + index * upgradeSpacing; costText.x = xOffset; costText.y = startY + index * upgradeSpacing + 100; } // In game.down: if (menuOpen) { console.log('Click raw local:', localX, localY); for (var i = 0; i < upgradeTexts.length; i++) { var text = upgradeTexts[i]; if (text.upgrade && text.category) { var hitArea = { x: text.x - 200, // Much wider hit area y: text.y - 40, width: 400, // Cover the entire text width height: 150 // Keep the height }; if (localX >= hitArea.x && localX <= hitArea.x + hitArea.width && localY >= hitArea.y && localY <= hitArea.y + hitArea.height) { // ... upgrade handling stays same ... } } } return true; }
User prompt
update as needed with: if (menuOpen) { console.log('Click raw local:', localX, localY); for (var i = 0; i < upgradeTexts.length; i++) { var text = upgradeTexts[i]; if (text.upgrade && text.category) { // Calculate position based on index to match creation spacing var baseY = startY + (Math.floor(i/2)) * upgradeSpacing; // Divide by 2 because we have name+cost pairs var hitArea = { x: text.x - 200, y: baseY - 40, // Use baseY instead of text.y width: 400, height: 150 }; console.log('Testing upgrade:', text.upgrade, 'Text pos:', text.x, baseY, 'Hit area:', hitArea, 'Click pos:', localX, localY); if (localX >= hitArea.x && localX <= hitArea.x + hitArea.width && localY >= hitArea.y && localY <= hitArea.y + hitArea.height) { console.log('Hit detected on:', text.upgrade); var upgrade = UPGRADE_CONFIG[text.category][text.upgrade]; var cost = getUpgradeCost(upgrade); if (game.bp >= cost) { if (text.category === 'machines') { upgrade.amount++; } else if (upgrade.currentLevel < upgrade.maxLevel) { upgrade.currentLevel++; } game.bp -= cost; bpText.setText(formatBP(game.bp) + " BP"); upgradeTexts[i + 1].setText(getUpgradeCost(upgrade) + " BP"); } return true; } } } return true; }
User prompt
update with: // First, modify the container creation at start var menuContainer = new Container(); menuContainer.x = game.width / 2; menuContainer.y = game.height; var menuPanel = LK.getAsset('upgradetab', { anchorX: 0.5, anchorY: 0, y: -570, alpha: 0.9, scaleX: 2048 / 200, scaleY: game.height * 0.4 / 100.3 }); var menuTab = LK.getAsset('upgradetab', { anchorX: 0.5, anchorY: 1, y: 0, scaleX: 3, scaleY: 0.8, alpha: 0.9 }); menuContainer.addChild(menuPanel); menuContainer.addChild(menuTab); // Menu text setup var menuText = new Text2("Upgrades", { size: 90, fill: 0xFFFFFF, stroke: 0x000000, strokeThickness: 3, font: "Impact" }); menuText.anchor = {x: 0.5, y: 0.5}; menuText.x = 0; menuText.y = -menuTab.height / 2; menuContainer.addChild(menuText); var menuTextContainer = new Container(); menuContainer.addChild(menuTextContainer); // Modified createUpgradeText function function createUpgradeText(category, key, index, isLeftColumn) { var upgrade = UPGRADE_CONFIG[category][key]; var xOffset = isLeftColumn ? -550 : 100; var yPos = startY + index * upgradeSpacing; // Create hit container first (so it's behind text) var hitContainer = new Container(); // Create a shape for the hit area (can make visible for debugging) var hitArea = LK.getAsset('blower', { width: 400, height: 150, color: 0xFFFFFF, alpha: 0.0 // Set to 0.2 to see hit areas }); hitContainer.addChild(hitArea); hitContainer.x = xOffset - 200; // Center on where text will be hitContainer.y = yPos - 40; // Create name text var nameText = new Text2(upgrade.name, { size: 96, fill: 0xFFFFFF, stroke: 0x000000, strokeThickness: 2, font: "Impact" }); nameText.x = xOffset; nameText.y = yPos; // Create cost text var cost = getUpgradeCost(upgrade); var costText = new Text2(cost + " BP", { size: 96, fill: 0xFFFF00, stroke: 0x000000, strokeThickness: 2, font: "Impact" }); costText.x = xOffset; costText.y = yPos + 100; // Add click handler to hit container hitContainer.down = function() { console.log('Click on:', upgrade.name); var cost = getUpgradeCost(upgrade); if (game.bp >= cost) { if (category === 'machines') { upgrade.amount++; } else if (upgrade.currentLevel < upgrade.maxLevel) { upgrade.currentLevel++; } game.bp -= cost; bpText.setText(formatBP(game.bp) + " BP"); costText.setText(getUpgradeCost(upgrade) + " BP"); } return true; }; menuTextContainer.addChild(hitContainer); menuTextContainer.addChild(nameText); menuTextContainer.addChild(costText); }
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var facekit = LK.import("@upit/facekit.v1");
/****
* Classes
****/
// Bubble class to represent each bubble in the game
var Bubble = Container.expand(function () {
var self = Container.call(this);
self.lifetime = 0;
self.hasSplit = false;
self.splitHeight = null;
self.AUTO_POP_SIZE = 40;
self.MIN_SPLIT_SIZE = 30;
self.lastPopTime = 0; // Add timestamp tracking
var sprite = self.attachAsset('bubble', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0.9
});
self.size = 100;
self.initLifetime = function () {
self.maxLifetime = Math.floor(Math.random() * 960 + 1440);
self.maxLifetime *= Math.min(1, self.size / 100);
};
self.initLifetime();
// Subtle size-based variance plus small random factor
var speedMultiplier = 120 / self.size * (0.9 + Math.random() * 0.2); // Just 10% variance
self.floatSpeed = 50 * speedMultiplier / 60;
self.driftX = (Math.random() * 20 - 10) / 60; // Normal drift variance
self.verticalVelocity = 0;
self.down = function (e) {
// Add cooldown check (100ms)
var currentTime = Date.now();
if (currentTime - self.lastPopTime < 100) {
return true; // Ignore clicks too close together
}
self.lastPopTime = currentTime;
var index = game.bubbles.indexOf(self);
if (index > -1) {
game.bubbles.splice(index, 1);
}
var points = self.getBP();
game.addBP(points, self.x, self.y, false); // Pass position and flag for manual pop
// Only split if manually popped and large enough
if (self.size > 60 && !self.justSplit) {
var splitCount = 2 + UPGRADE_CONFIG.machine.bubbleDurability.currentLevel;
var newSize = Math.max(self.MIN_SPLIT_SIZE, self.size * 0.6);
for (var i = 0; i < splitCount; i++) {
var angle = i / splitCount * Math.PI * 2;
spawnSplitBubble(self.x, self.y, newSize, Math.cos(angle),
// More even distribution
false);
}
}
self.destroy();
return true; // Stop event propagation
};
self.getBP = function () {
return Math.max(1, Math.floor(Math.pow(self.size, 1.4) * 0.02));
};
self.update = function () {
self.lifetime++;
// Add subtle drift variation
if (self.lifetime % 60 === 0) {
// Every second
self.driftX += (Math.random() - 0.5) * 0.3; // Add small random drift
}
// Increase overall horizontal movement
self.x += self.driftX * 1.2; // 20% more horizontal movement
// Auto-pop or split when lifetime exceeded
if (self.lifetime > self.maxLifetime) {
// Just check size and not already split
if (self.size > 60 && !self.hasSplit) {
self.hasSplit = true;
var newSize = Math.max(self.MIN_SPLIT_SIZE, self.size * 0.6);
for (var i = 0; i < 2; i++) {
var split = spawnSplitBubble(self.x, self.y, newSize, i === 0 ? -1 : 1, true);
split.maxLifetime *= 0.7; // Shorter lifetime for split bubbles
}
self.destroy();
return;
}
// If too small to split, just pop
self.autoPop();
return;
}
// Clear off-screen bubbles
if (self.y < -self.size) {
self.destroy();
return;
}
self.justSplit = false; // Clear the flag after first update
// More gradual vertical speed transition
if (self.verticalVelocity < self.floatSpeed) {
self.verticalVelocity += 0.08; // More gentle transition
}
self.y -= self.verticalVelocity;
// Gradually reduce horizontal speed after split
if (Math.abs(self.driftX) > (Math.random() * 20 - 10) / 60) {
self.driftX *= 0.98; // Slowly return to normal drift speed
}
self.x += self.driftX;
// Bounce off edges
if (self.x < self.size) {
self.x = self.size;
self.driftX = Math.abs(self.driftX);
} else if (self.x > game.width - self.size) {
self.x = game.width - self.size;
self.driftX = -Math.abs(self.driftX);
}
var scale = self.size / sprite.width;
sprite.scaleX = scale;
sprite.scaleY = scale;
};
self.autoPop = function () {
if (!self.autoPopDisplayed) {
var points = Math.floor(self.getBP() * 0.5); // Half points for auto-pop
game.addBP(points, self.x, self.y, true); // Added true flag for autoPop
self.autoPopDisplayed = true;
}
self.destroy();
return;
};
return self;
});
// Pufferfish mask that follows face
var pufferMask = Container.expand(function () {
var self = Container.call(this);
var sprite = self.attachAsset('pufferfish', {
anchorX: 0.5,
anchorY: 0.5
});
var targetX = 0;
var targetY = 0;
var smoothingFactor = 0.12;
var prevX = null;
var prevY = null;
var targetRotation = 0;
var rotationSmoothingFactor = 0.1;
var targetTilt = 0;
var tiltSmoothingFactor = 0.11; // Reduced from 0.08 for smoother movement
var tiltScaleFactor = 0.09; // Reduced from 0.15 for less tilt
var scaleHistory = new Array(5).fill(0); // Keep last 5 scale values
var scaleIndex = 0;
var baseScale = 1;
var minScale = 0.1;
var maxScale = 3;
self.update = function () {
// Adjust scale based on face size
if (facekit.leftEye && facekit.rightEye && facekit.mouthCenter) {
var eyeDistance = Math.abs(facekit.rightEye.x - facekit.leftEye.x);
var newScale = eyeDistance / 500;
// Update rolling average
scaleHistory[scaleIndex] = newScale;
scaleIndex = (scaleIndex + 1) % scaleHistory.length;
// Calculate average scale
var avgScale = scaleHistory.reduce(function (a, b) {
return a + b;
}, 0) / scaleHistory.length;
// More gentle smoothing
sprite.scaleX = sprite.scaleX * 0.85 + avgScale * 0.15;
sprite.scaleY = sprite.scaleY * 0.85 + avgScale * 0.15;
}
// Follow nose position for main face tracking
if (facekit.noseTip) {
targetX = facekit.noseTip.x;
targetY = facekit.noseTip.y;
// Initialize previous positions if not set
if (prevX === null) {
prevX = targetX;
prevY = targetY;
}
// Weighted average between previous and target position
var newX = prevX * (1 - smoothingFactor) + targetX * smoothingFactor;
var newY = prevY * (1 - smoothingFactor) + targetY * smoothingFactor;
self.x = newX;
self.y = newY;
// Update previous positions
prevX = newX;
prevY = newY;
}
if (facekit.leftEye && facekit.rightEye) {
targetTilt = calculateFaceTilt() * tiltScaleFactor; // Scale down the tilt
// Reduce max rotation to ±15 degrees
targetTilt = Math.max(-15, Math.min(15, targetTilt));
self.rotation += (targetTilt - self.rotation) * tiltSmoothingFactor;
}
};
function calculateFaceTilt() {
if (facekit.leftEye && facekit.rightEye && facekit.mouthCenter) {
// Calculate midpoint between eyes
var eyeMidX = (facekit.leftEye.x + facekit.rightEye.x) / 2;
var eyeMidY = (facekit.leftEye.y + facekit.rightEye.y) / 2;
// Calculate angle between eye midpoint and mouth, negated to fix direction
var dx = facekit.mouthCenter.x - eyeMidX;
var dy = facekit.mouthCenter.y - eyeMidY;
var angle = -(Math.atan2(dx, dy) * (180 / Math.PI));
// Reduced max angle to ±15 degrees and lowered multiplier
return Math.max(-15, Math.min(15, angle * 0.15));
}
return 0; // Default to straight when face points aren't available
}
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB // Light blue background to represent the sky
});
/****
* Game Code
****/
var UPGRADE_EFFECTS = {
lungCapacity: {
baseValue: 160,
// Base max bubble size
incrementPercent: 25 // +25% per level
},
quickBreath: {
baseValue: 1.6,
// Base growth rate
incrementPercent: 25 // +25% per level
},
autoBubbleSpeed: {
decrementPercent: 10 // -10% production time per level
},
bubbleDurability: {
extraSplits: 1 // +1 split per level
},
autoPop: {
timeReduction: 0.8 // Reduces lifetime by 20% per level
}
};
function _slicedToArray3(r, e) {
return _arrayWithHoles3(r) || _iterableToArrayLimit3(r, e) || _unsupportedIterableToArray3(r, e) || _nonIterableRest3();
}
function _nonIterableRest3() {
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _unsupportedIterableToArray3(r, a) {
if (r) {
if ("string" == typeof r) {
return _arrayLikeToArray3(r, a);
}
var t = {}.toString.call(r).slice(8, -1);
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray3(r, a) : void 0;
}
}
function _arrayLikeToArray3(r, a) {
(null == a || a > r.length) && (a = r.length);
for (var e = 0, n = Array(a); e < a; e++) {
n[e] = r[e];
}
return n;
}
function _iterableToArrayLimit3(r, l) {
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
if (null != t) {
var e,
n,
i,
u,
a = [],
f = !0,
o = !1;
try {
if (i = (t = t.call(r)).next, 0 === l) {
if (Object(t) !== t) {
return;
}
f = !1;
} else {
for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0) {
;
}
}
} catch (r) {
o = !0, n = r;
} finally {
try {
if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) {
return;
}
} finally {
if (o) {
throw n;
}
}
}
return a;
}
}
function _arrayWithHoles3(r) {
if (Array.isArray(r)) {
return r;
}
}
function getUpgradeCost(upgrade) {
if (upgrade.amount !== undefined) {
// For clams
return Math.floor(upgrade.baseCost * Math.pow(upgrade.costScale, upgrade.amount));
} else {
// For regular upgrades
return Math.floor(upgrade.baseCost * Math.pow(upgrade.costScale, upgrade.currentLevel));
}
}
function _slicedToArray2(r, e) {
return _arrayWithHoles2(r) || _iterableToArrayLimit2(r, e) || _unsupportedIterableToArray2(r, e) || _nonIterableRest2();
}
function _nonIterableRest2() {
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _unsupportedIterableToArray2(r, a) {
if (r) {
if ("string" == typeof r) {
return _arrayLikeToArray2(r, a);
}
var t = {}.toString.call(r).slice(8, -1);
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray2(r, a) : void 0;
}
}
function _arrayLikeToArray2(r, a) {
(null == a || a > r.length) && (a = r.length);
for (var e = 0, n = Array(a); e < a; e++) {
n[e] = r[e];
}
return n;
}
function _iterableToArrayLimit2(r, l) {
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
if (null != t) {
var e,
n,
i,
u,
a = [],
f = !0,
o = !1;
try {
if (i = (t = t.call(r)).next, 0 === l) {
if (Object(t) !== t) {
return;
}
f = !1;
} else {
for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0) {
;
}
}
} catch (r) {
o = !0, n = r;
} finally {
try {
if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) {
return;
}
} finally {
if (o) {
throw n;
}
}
}
return a;
}
}
function _arrayWithHoles2(r) {
if (Array.isArray(r)) {
return r;
}
}
function updateClams() {
Object.entries(UPGRADE_CONFIG.machines).forEach(function (_ref) {
var _ref2 = _slicedToArray3(_ref, 2),
type = _ref2[0],
machine = _ref2[1];
if (machine.amount > 0) {
// Calculate production time with speed upgrade
var baseTime = machine.production * 60; // Convert to frames
var speedMultiplier = Math.pow(1 - UPGRADE_EFFECTS.autoBubbleSpeed.decrementPercent / 100, UPGRADE_CONFIG.machine.autoBubbleSpeed.currentLevel);
var adjustedTime = Math.max(1, Math.floor(baseTime * speedMultiplier));
if (LK.ticks % adjustedTime === 0) {
for (var i = 0; i < machine.amount; i++) {
if (game.bubbles.length < game.MAX_BUBBLES) {
var x = Math.random() * (game.width - 200) + 100;
spawnSplitBubble(x, game.height + 100, machine.bubbleSize, 0);
}
}
}
}
});
}
function _slicedToArray(r, e) {
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
}
function _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _unsupportedIterableToArray(r, a) {
if (r) {
if ("string" == typeof r) {
return _arrayLikeToArray(r, a);
}
var t = {}.toString.call(r).slice(8, -1);
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
}
}
function _arrayLikeToArray(r, a) {
(null == a || a > r.length) && (a = r.length);
for (var e = 0, n = Array(a); e < a; e++) {
n[e] = r[e];
}
return n;
}
function _iterableToArrayLimit(r, l) {
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
if (null != t) {
var e,
n,
i,
u,
a = [],
f = !0,
o = !1;
try {
if (i = (t = t.call(r)).next, 0 === l) {
if (Object(t) !== t) {
return;
}
f = !1;
} else {
for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0) {
;
}
}
} catch (r) {
o = !0, n = r;
} finally {
try {
if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) {
return;
}
} finally {
if (o) {
throw n;
}
}
}
return a;
}
}
function _arrayWithHoles(r) {
if (Array.isArray(r)) {
return r;
}
}
var background = LK.getAsset('background', {
anchorX: 0.5,
anchorY: 0.5,
x: game.width / 2,
y: game.height / 2
});
game.addChild(background);
var playerMask = new pufferMask();
game.addChild(playerMask);
var UPGRADE_CONFIG = {
player: {
lungCapacity: {
name: "Lung Capacity",
baseCost: 50,
// About 1-2 max bubbles
costScale: 2.0,
// Steeper scaling
maxLevel: 10,
currentLevel: 0
},
quickBreath: {
name: "Quick Breath",
baseCost: 100,
// 2-3 max bubbles
costScale: 2.0,
// Steeper scaling
maxLevel: 10,
currentLevel: 0
},
autoPop: {
// Moved here from machine section
name: "Fish Friends",
// Updated name
baseCost: 1000,
costScale: 2.3,
maxLevel: 5,
currentLevel: 0
}
},
machines: {
basicClam: {
name: "Basic Clam",
baseCost: 300,
// 6-7 max bubbles
costScale: 1.25,
// Slightly steeper scaling
amount: 0,
production: 3,
bubbleSize: 25
},
advancedClam: {
name: "Advanced Clam",
baseCost: 2000,
// Requires running basic clams for a while
costScale: 1.3,
amount: 0,
production: 2,
bubbleSize: 35,
unlockCost: 2000
},
premiumClam: {
name: "Premium Clam",
baseCost: 15000,
// True end-game content
costScale: 1.35,
amount: 0,
production: 1,
bubbleSize: 50,
unlockCost: 15000
}
},
machine: {
bubbleDurability: {
name: "Bubble Durability",
baseCost: 250,
costScale: 2.8,
// Significant scaling
maxLevel: 5,
currentLevel: 0
},
autoBubbleSpeed: {
name: "Auto-Bubble Speed",
baseCost: 500,
costScale: 2.5,
maxLevel: 10,
currentLevel: 0
}
}
};
// Create upgrade menu elements
// Menu tab (handle)
// First position the panel relative to container at y=0
// Menu panel should be below the tab in the container
var menuTab = LK.getAsset('upgradetab', {
anchorX: 0.5,
anchorY: 1,
// Change to bottom anchor
y: 0,
// Will be at container's position
scaleX: 3,
scaleY: 0.8,
alpha: 0.9
});
var menuPanel = LK.getAsset('upgradetab', {
anchorX: 0.5,
anchorY: 0,
y: -570,
alpha: 0.9,
scaleX: 2048 / 200,
// Use the width of the asset directly
scaleY: game.height * 0.4 / 100.3
});
// Initialize menu structure
// Initialize menu container at the right position
var menuContainer = new Container();
menuContainer.x = game.width / 2;
menuContainer.y = game.height; // Position at bottom
// Add panel first (so it's behind tab)
menuContainer.addChild(menuPanel);
menuContainer.addChild(menuTab);
// Menu text setup - should be good as is
var menuText = new Text2("Upgrades", {
size: 90,
fill: 0xFFFFFF,
stroke: 0x000000,
strokeThickness: 3,
font: "Impact"
});
menuText.anchor = {
x: 0.5,
y: 0.5
};
menuText.x = 0; // Relative to container
menuText.y = -menuTab.height / 2; // Position relative to container bottom
menuContainer.addChild(menuText);
// Add to game
game.addChild(menuContainer);
// Create text container AFTER panel scaling
var menuTextContainer = new Container();
menuContainer.addChild(menuTextContainer);
// Add upgrade texts to text container instead of panel
var upgradeTexts = [];
var startY = 150;
var upgradeSpacing = 250;
var columnWidth = 1024;
// Create arrays to hold upgrade categories in desired order
var leftColumnUpgrades = [['player', 'lungCapacity'], ['player', 'quickBreath'], ['player', 'autoPop']];
var rightColumnUpgrades = [['machines', 'basicClam'], ['machines', 'advancedClam'], ['machines', 'premiumClam'], ['machine', 'bubbleDurability'], ['machine', 'autoBubbleSpeed']];
// Function to create upgrade text
function createUpgradeText(category, key, index, isLeftColumn) {
var upgrade = UPGRADE_CONFIG[category][key];
// Create name text
var nameText = new Text2(upgrade.name, {
size: 96,
fill: 0xFFFFFF,
stroke: 0x000000,
strokeThickness: 2,
font: "Impact"
});
// Create cost text
var cost = getUpgradeCost(upgrade);
var costText = new Text2(cost + " BP", {
size: 96,
fill: 0xFFFF00,
stroke: 0x000000,
strokeThickness: 2,
font: "Impact"
});
// Position texts
var xOffset = isLeftColumn ? -924 : 100; // Adjust these values as needed
nameText.x = xOffset;
nameText.y = startY + index * upgradeSpacing;
costText.x = xOffset;
costText.y = startY + index * upgradeSpacing + 100;
nameText.upgrade = key;
nameText.category = category;
upgradeTexts.push(nameText);
upgradeTexts.push(costText);
menuTextContainer.addChild(nameText);
menuTextContainer.addChild(costText);
}
// Clear existing texts
upgradeTexts.forEach(function (text) {
return text.destroy();
});
upgradeTexts = [];
// Create left column
leftColumnUpgrades.forEach(function (upgrade, index) {
createUpgradeText(upgrade[0], upgrade[1], index, true);
});
// Create right column
rightColumnUpgrades.forEach(function (upgrade, index) {
createUpgradeText(upgrade[0], upgrade[1], index, false);
});
// Move the entire text container down by adjusting its Y position
menuTextContainer.y = 0; // This should align it with the top of the panel instead of being above it
menuTextContainer.x = 0; // Center in panel
// Menu state and animation
var menuOpen = false;
var menuTargetY = game.height;
// Initialize game variables
game.growingBubble = null;
game.lastMouthState = false; // Track previous mouth state
game.mouthOpenDuration = 0; // Track how long mouth has been open
game.MOUTH_OPEN_THRESHOLD = 10; // Frames required with mouth open to start bubble
game.MIN_SPAWN_SIZE = 25; // Minimum initial bubble size
game.blowCooldown = 0; // Cooldown timer between bubble starts
game.BLOW_COOLDOWN_TIME = 15; // Frames to wait between new bubbles
game.maxBubbleSize = 160; // Increased by 30%
game.growthRate = 1.6; // Slightly increased to match new max size
game.MAX_BUBBLES = 125;
game.baseSpawnRate = 180; // Every 3 seconds
function spawnSplitBubble(parentX, parentY, size, direction) {
var isAutoPop = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
var bubble = new Bubble();
bubble.x = parentX;
bubble.y = parentY;
bubble.size = size;
bubble.initLifetime(); // Recalculate after size is set
bubble.justSplit = true;
var speedMultiplier = 120 / size * (0.9 + Math.random() * 0.2);
if (isAutoPop) {
// Pure upward/sideways motion for natural splits
bubble.verticalVelocity = bubble.floatSpeed; // Start at float speed
bubble.driftX = direction * (Math.random() * 0.8 + 0.5);
} else {
// Manual pop physics
bubble.verticalVelocity = -(Math.random() * 2 + 4);
bubble.driftX = direction * (Math.random() * 1.5 + 2);
}
game.addChild(bubble);
game.bubbles.push(bubble);
return bubble;
}
game.bubbles = []; // Track bubble array
// Initialize game variables
//<Assets used in the game will automatically appear here>
game.bp = 0; // Track total BP
game.combo = 0;
game.lastPopTime = 0;
game.COMBO_WINDOW = 60; // 1 second in frames
function formatBP(value) {
var units = ['', 'K', 'M', 'B', 'T'];
var unitIndex = 0;
while (value >= 1000 && unitIndex < units.length - 1) {
value /= 1000;
unitIndex++;
}
return Math.floor(value * 10) / 10 + units[unitIndex];
}
// Create BP display text (add near game initialization)
var bpText = new Text2("0 BP", {
size: 120,
fill: 0xFFFFFF,
stroke: 0x33caf8,
strokeThickness: 4,
font: "Impact",
fontWeight: "bold"
});
bpText.anchor.set(1, 0);
bpText.x = game.width - 20;
bpText.y = 20;
game.addChild(bpText);
game.addBP = function (points, x, y, isAutoPop) {
var currentTime = LK.ticks;
// Only update combo if it's not an auto-pop
if (!isAutoPop) {
if (currentTime - game.lastPopTime < game.COMBO_WINDOW) {
game.combo++;
points *= 1 + game.combo * 0.1; // 10% bonus per combo
} else {
game.combo = 0;
}
game.lastPopTime = currentTime;
}
game.bp += Math.floor(points);
bpText.setText(formatBP(game.bp) + " BP");
// Always show point text regardless of auto or manual pop
var pointText = new Text2("+" + Math.floor(points), {
size: 96,
fill: 0xFFFF00,
font: "Impact",
fontWeight: 'bold'
});
pointText.anchorX = 0.5;
pointText.anchorY = 0.5;
pointText.x = x;
pointText.y = y;
game.addChild(pointText);
tween(pointText, {
y: pointText.y - 100,
alpha: 0
}, {
duration: 1200,
onFinish: function onFinish() {
pointText.destroy();
}
});
// Only show combo text if it's a manual pop and we have a combo
if (!isAutoPop && game.combo > 0) {
var comboText = new Text2("x" + (game.combo + 1), {
size: 96,
fill: 0xFFA500,
stroke: 0x000000,
strokeThickness: 4,
fontWeight: 'bold'
});
comboText.anchorX = 0.5;
comboText.anchorY = 0;
comboText.x = game.width / 2;
comboText.y = 20;
game.addChild(comboText);
tween(comboText, {
alpha: 0
}, {
duration: 500,
onFinish: function onFinish() {
comboText.destroy();
}
});
}
};
game.update = function () {
// Update mouth state and duration
if (!game.lastMouthState) {
game.mouthOpenDuration = 0;
}
if (facekit.mouthOpen) {
game.mouthOpenDuration++;
} else {
game.mouthOpenDuration = 0;
}
// Only allow bubble creation if menu is closed and mouth has been open long enough
if (!menuOpen && facekit.mouthOpen && game.mouthOpenDuration >= game.MOUTH_OPEN_THRESHOLD) {
// Only allow new bubbles after cooldown
if (!game.growingBubble && game.blowCooldown <= 0) {
// Calculate spawn position relative to pufferfish mask
var spawnX = playerMask.x;
var spawnY = playerMask.y + playerMask.height * 0.15;
game.growingBubble = new Bubble();
game.growingBubble.size = game.MIN_SPAWN_SIZE;
game.addChild(game.growingBubble);
game.bubbles.push(game.growingBubble);
game.blowCooldown = game.BLOW_COOLDOWN_TIME;
}
if (game.growingBubble) {
game.growingBubble.x = playerMask.x;
game.growingBubble.y = playerMask.y + playerMask.height * 0.15;
game.growingBubble.size = Math.min(game.growingBubble.size + game.growthRate, game.maxBubbleSize);
game.growingBubble.verticalVelocity = 0;
game.growingBubble.driftX = 0;
}
} else {
if (game.growingBubble) {
game.growingBubble.verticalVelocity = -12;
game.growingBubble.driftX = (Math.random() * 2 - 1) * 2.5;
game.growingBubble = null;
game.mouthOpenDuration = 0;
}
}
// Update cooldown timer
if (game.blowCooldown > 0) {
game.blowCooldown--;
}
game.lastMouthState = facekit.mouthOpen;
updateClams();
// Update all children (bubbles)
// Only spawn if under max bubbles
if (game.bubbles.length < game.MAX_BUBBLES) {
if (LK.ticks % game.baseSpawnRate == 0) {
var x = Math.random() * (game.width - 200) + 100;
spawnSplitBubble(x, game.height + 100, 100, 0);
}
}
// Clean up destroyed bubbles from array
game.bubbles = game.bubbles.filter(function (bubble) {
return !bubble.destroyed;
});
// Update all children (bubbles)
for (var i = game.bubbles.length - 1; i >= 0; i--) {
var bubble = game.bubbles[i];
if (bubble.update) {
bubble.update();
}
}
};
// Handle touch/mouse events for the game
game.down = function (x, y, obj) {
// Convert to local coordinates for container
var localX = x - menuContainer.x;
var localY = y - menuContainer.y;
// Check if clicked on menu tab
var tabBounds = {
x: -menuTab.width * menuTab.scaleX / 2,
// Account for scale
y: -menuTab.height * menuTab.scaleY,
// Account for scale
width: menuTab.width * menuTab.scaleX,
// Account for scale
height: menuTab.height * menuTab.scaleY // Account for scale
};
if (localX >= tabBounds.x && localX <= tabBounds.x + tabBounds.width && localY >= tabBounds.y && localY <= tabBounds.y + tabBounds.height) {
menuOpen = !menuOpen;
var targetY = menuOpen ? menuTab.height : game.height;
// Move menu to top when opening
if (menuOpen) {
game.setChildIndex(menuContainer, game.children.length - 1);
}
tween(menuContainer, {
y: targetY
}, {
duration: 300,
easing: tween.easeOutBack,
onFinish: function onFinish() {
// Move menu back down in z-index when closed
if (!menuOpen) {
game.setChildIndex(menuContainer, 1); // Above background
}
}
});
return true;
}
// Check for clicks outside when menu is open
if (menuOpen) {
var menuBounds = {
x: -menuPanel.width / 2,
y: -menuPanel.height,
width: menuPanel.width,
height: menuPanel.height + menuTab.height
};
if (!(localX >= menuBounds.x && localX <= menuBounds.x + menuBounds.width && localY >= menuBounds.y && localY <= menuBounds.y + menuBounds.height)) {
menuOpen = false;
tween(menuContainer, {
y: game.height
}, {
duration: 300,
easing: tween.easeInBack
});
return true;
}
}
// Rest of click handling for bubbles...
};
var popped = false; // Track if we've popped any bubble
for (var i = game.bubbles.length - 1; i >= 0; i--) {
var bubble = game.bubbles[i];
// Calculate distance between click and bubble center
var dx = x - bubble.x;
var dy = y - bubble.y;
var distance = Math.sqrt(dx * dx + dy * dy);
// Only pop if we haven't popped anything this click
if (!popped && distance <= bubble.size / 2 + 10 && bubble.down) {
bubble.down();
popped = true;
break; // Exit loop after first pop
}
}
;
A treasure chest with gold coins. Cartoon.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
A golden skull with diamonds for eyes. Cartoon.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
A golden necklace with a ruby pendant. Cartoon.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
A filled in white circle.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
A yellow star. Cartoon.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
a game logo for a game called 'Bubble Blower Tycoon' about a happy purple pufferfish with yellow fins and spines that builds an underwater empire of bubbles. Cartoon. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
an SVG of the word 'Start'. word should be yellow and the font should look like its made out of bubbles. cartoon. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
bubblelow
Sound effect
backgroundmusic
Music
bubblehigh
Sound effect
bubble1
Sound effect
bubble2
Sound effect
bubble3
Sound effect
bubble4
Sound effect
blowing
Sound effect
bubbleshoot
Sound effect
fishtank
Sound effect
menuopen
Sound effect
upgrade
Sound effect
jellyfish
Sound effect
titlemusic
Music
startbutton
Sound effect