User prompt
Lütfen hatayı düzeltin: 'Script hatası.' bu satırda veya bu satırla ilgili: 'currentBoard.push(scoreEntry);' Satır Numarası: 1021 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'currentBoard.push(scoreEntry);' Line Number: 1021 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Oyunda skormuzu görek ve Sv mizide görək ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Ve öldüyümuzuzde ana menüye gedey
User prompt
Ve biz bu engelre deydiyimzde ölek
User prompt
Şimdi bu maniyelere deydiyimzde öley ve bu maiyeler hızlı gelsin ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Ya ben sıkıldım diyorum ki bizim önüme maniyelr cıksın ve bizi zorlasın para kasabada ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Oyundakı o sarı altın şeyelr geliyor a onları kayb et onalrın yerine bizi zorluyan şeyler cıksın özumuze ve ölek ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Abi bir oyun skoru yap ve bir svy yap ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Oyuna kapak fotoğrafı köy
User prompt
Şimdi oyuna ana menü ekleyin içi dolu olsun yap kafana göre bir şeyelr ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Şimdide oyuna altın gelsin altında da basdımızda oyun hızılansın ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Yok bu bolanalr gelsin hemde altın para gelsin cobo 259 olun ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Oyun biraz sıkıcı be ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Buna böyle bir şey yap bu oyuna bir en iyi skor köy ve hızlansın Bide biraz maraxlı şeyler ele lutven ↪💡 Consider importing and using the following plugins: @upit/storage.v1, @upit/tween.v1
Code edit (1 edits merged)
Please save this source code
User prompt
Bubble Pop Frenzy
Initial prompt
Selam bana bir Oyun yap kafana göre ama eyeleneceli bir şey olsun vakit geçirecek bir şey
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1", { highScore: 0, leaderboard: [] }); /**** * Classes ****/ var Bubble = Container.expand(function (isGolden, isBonus) { var self = Container.call(this); self.isGolden = isGolden || false; self.isBonus = isBonus || false; self.speed = Math.random() * 2 + 1; // Random speed between 1-3 self.points = self.isBonus ? 259 : self.isGolden ? 50 : 10; var assetName = self.isBonus ? 'bonusBubble' : self.isGolden ? 'goldenBubble' : 'bubble'; var bubbleGraphics = self.attachAsset(assetName, { anchorX: 0.5, anchorY: 0.5 }); // Bonus bubbles get extreme pulsing effect if (self.isBonus) { tween(bubbleGraphics, { scaleX: 1.5, scaleY: 1.5, rotation: Math.PI / 4 }, { duration: 400, easing: tween.bounceOut, onFinish: function onFinish() { tween(bubbleGraphics, { scaleX: 0.8, scaleY: 0.8, rotation: -Math.PI / 4 }, { duration: 400, easing: tween.bounceOut, onFinish: function onFinish() { // Loop the extreme pulsing effect if (self.parent) { tween(bubbleGraphics, { scaleX: 1.5, scaleY: 1.5, rotation: Math.PI / 4 }, { duration: 400, easing: tween.bounceOut }); } } }); } }); } else if (self.isGolden) { tween(bubbleGraphics, { scaleX: 1.2, scaleY: 1.2 }, { duration: 800, easing: tween.easeInOut, onFinish: function onFinish() { tween(bubbleGraphics, { scaleX: 1, scaleY: 1 }, { duration: 800, easing: tween.easeInOut, onFinish: function onFinish() { // Loop the pulsing effect if (self.parent) { // Only continue if bubble still exists tween(bubbleGraphics, { scaleX: 1.2, scaleY: 1.2 }, { duration: 800, easing: tween.easeInOut }); } } }); } }); } // Add slight floating animation var floatOffset = Math.random() * Math.PI * 2; self.update = function () { self.y -= self.speed; // Add slight horizontal wobble self.x += Math.sin(LK.ticks * 0.05 + floatOffset) * 0.5; // Add special effects for different bubble types if (self.isBonus) { // Bonus bubbles get super fast rainbow cycling and extra wobble var fastColorPhase = (LK.ticks * 0.1 + floatOffset) % (Math.PI * 2); var red = Math.floor(Math.sin(fastColorPhase) * 127 + 128); var green = Math.floor(Math.sin(fastColorPhase + 2.094) * 127 + 128); var blue = Math.floor(Math.sin(fastColorPhase + 4.188) * 127 + 128); var rainbowColor = red << 16 | green << 8 | blue; bubbleGraphics.tint = rainbowColor; // Extra wobble for bonus bubbles self.x += Math.sin(LK.ticks * 0.1 + floatOffset) * 2; } else if (!self.isGolden) { var colorPhase = (LK.ticks * 0.02 + floatOffset) % (Math.PI * 2); var red = Math.floor(Math.sin(colorPhase) * 127 + 128); var green = Math.floor(Math.sin(colorPhase + 2.094) * 127 + 128); var blue = Math.floor(Math.sin(colorPhase + 4.188) * 127 + 128); var rainbowColor = red << 16 | green << 8 | blue; bubbleGraphics.tint = rainbowColor; } }; self.down = function (x, y, obj) { self.pop(); }; self.pop = function () { // Combo system comboCount++; comboTimer = 180; // 3 seconds to maintain combo var comboMultiplier = Math.min(Math.floor(comboCount / 5) + 1, 5); var finalPoints = self.points * comboMultiplier; // Add points to score LK.setScore(LK.getScore() + finalPoints); // Create floating score indicator var scoreIndicator = new Text2('+' + finalPoints, { size: 50 + comboMultiplier * 10, fill: self.isGolden ? 0xFFD700 : 0x00FF88 }); scoreIndicator.anchor.set(0.5, 0.5); scoreIndicator.x = self.x; scoreIndicator.y = self.y; game.addChild(scoreIndicator); // Animate the floating score tween(scoreIndicator, { y: self.y - 100, alpha: 0, scaleX: 1.5, scaleY: 1.5 }, { duration: 1200, easing: tween.easeOut, onFinish: function onFinish() { scoreIndicator.destroy(); } }); // Show combo text for exciting combos if (comboCount >= 5 && comboCount % 5 === 0) { comboTxt.setText('COMBO x' + comboMultiplier + '!'); comboTxt.alpha = 1; comboTxt.scaleX = 1.5; comboTxt.scaleY = 1.5; tween(comboTxt, { alpha: 0, scaleX: 1, scaleY: 1 }, { duration: 1500 }); // Screen shake for big combos screenShakeIntensity = Math.min(comboMultiplier * 2, 10); // Add screen zoom effect for mega combos if (comboCount >= 10) { tween(game, { scaleX: 1.05, scaleY: 1.05 }, { duration: 200, easing: tween.easeOut, onFinish: function onFinish() { tween(game, { scaleX: 1, scaleY: 1 }, { duration: 300, easing: tween.bounceOut }); } }); } } // Play pop sound and special effects if (self.isBonus) { LK.getSound('bonusPop').play(); // Bonus bubble creates intense orange screen flash LK.effects.flashScreen(0xFF6B35, 600); // Extra screen shake for bonus bubbles screenShakeIntensity = Math.max(screenShakeIntensity, 15); } else if (self.isGolden) { LK.getSound('goldenPop').play(); // Golden bubble creates screen flash LK.effects.flashScreen(0xFFD700, 300); } else { LK.getSound('pop').play(); } // Create particle burst effect var particleCount = self.isBonus ? 12 : 6; for (var p = 0; p < particleCount; p++) { var particle = LK.getAsset('bubble', { anchorX: 0.5, anchorY: 0.5, scaleX: self.isBonus ? 0.5 : 0.3, scaleY: self.isBonus ? 0.5 : 0.3, x: self.x, y: self.y }); particle.tint = self.isBonus ? 0xFF6B35 : self.isGolden ? 0xFFD700 : bubbleGraphics.tint; game.addChild(particle); var angle = p / particleCount * Math.PI * 2; var distance = self.isBonus ? 120 + Math.random() * 60 : 80 + Math.random() * 40; var targetX = self.x + Math.cos(angle) * distance; var targetY = self.y + Math.sin(angle) * distance; tween(particle, { x: targetX, y: targetY, alpha: 0, scaleX: 0, scaleY: 0, rotation: Math.random() * Math.PI * 2 }, { duration: self.isBonus ? 800 + Math.random() * 400 : 400 + Math.random() * 200, easing: tween.easeOut, onFinish: function onFinish() { particle.destroy(); } }); } // Enhanced pop animation with random rotation var randomRotation = (Math.random() - 0.5) * Math.PI; tween(self, { scaleX: 2, scaleY: 2, alpha: 0, rotation: randomRotation }, { duration: 250, easing: tween.bounceOut, onFinish: function onFinish() { self.destroy(); } }); // Remove from bubbles array for (var i = bubbles.length - 1; i >= 0; i--) { if (bubbles[i] === self) { bubbles.splice(i, 1); break; } } }; return self; }); var Coin = Container.expand(function () { var self = Container.call(this); self.speed = Math.random() * 3 + 2; // Random speed between 2-5 self.collected = false; var coinGraphics = self.attachAsset('coin', { anchorX: 0.5, anchorY: 0.5 }); // Add spinning animation tween(coinGraphics, { rotation: Math.PI * 2 }, { duration: 1000, easing: tween.linear, onFinish: function onFinish() { if (self.parent) { // Loop the spinning tween(coinGraphics, { rotation: Math.PI * 4 }, { duration: 1000, easing: tween.linear }); } } }); // Add pulsing effect tween(coinGraphics, { scaleX: 1.2, scaleY: 1.2 }, { duration: 600, easing: tween.easeInOut, onFinish: function onFinish() { tween(coinGraphics, { scaleX: 1, scaleY: 1 }, { duration: 600, easing: tween.easeInOut, onFinish: function onFinish() { if (self.parent) { // Loop the pulsing tween(coinGraphics, { scaleX: 1.2, scaleY: 1.2 }, { duration: 600, easing: tween.easeInOut }); } } }); } }); self.update = function () { self.y += self.speed; // Add slight horizontal wobble self.x += Math.sin(LK.ticks * 0.08) * 0.3; }; self.down = function (x, y, obj) { if (!self.collected) { self.collect(); } }; self.collect = function () { if (self.collected) return; self.collected = true; // Add coins to game state coinCount += 5; coinsTxt.setText('Coins: ' + coinCount); // Play collect sound LK.getSound('coinCollect').play(); // Create floating coin indicator var coinIndicator = new Text2('+5 Coins!', { size: 45, fill: 0xFFD700 }); coinIndicator.anchor.set(0.5, 0.5); coinIndicator.x = self.x; coinIndicator.y = self.y; game.addChild(coinIndicator); // Animate the floating indicator tween(coinIndicator, { y: self.y - 80, alpha: 0, scaleX: 1.3, scaleY: 1.3 }, { duration: 1000, easing: tween.easeOut, onFinish: function onFinish() { coinIndicator.destroy(); } }); // Coin collection effect tween(self, { scaleX: 2, scaleY: 2, alpha: 0, rotation: Math.PI * 2 }, { duration: 300, easing: tween.bounceOut, onFinish: function onFinish() { self.destroy(); } }); // Remove from coins array for (var i = coins.length - 1; i >= 0; i--) { if (coins[i] === self) { coins.splice(i, 1); break; } } // Speed boost effect when collecting coins gameSpeedMultiplier = Math.min(gameSpeedMultiplier + 0.1, 3.0); speedBoostTimer = 300; // 5 seconds of speed boost }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB }); /**** * Game Code ****/ // Game state management var gameState = 'menu'; // 'menu', 'playing', 'gameOver', 'leaderboard' var bubbles = []; var bubblesEscaped = 0; var maxEscapedBubbles = 10; var spawnTimer = 0; var spawnInterval = 80; // Start spawning faster (80 ticks = ~1.3 seconds) var difficultyTimer = 0; var comboCount = 0; var comboTimer = 0; var screenShakeIntensity = 0; var coins = []; var coinCount = 0; var coinSpawnTimer = 0; var coinSpawnInterval = 300; // Spawn coins every 5 seconds var gameSpeedMultiplier = 1.0; var speedBoostTimer = 0; var showingLeaderboard = false; var leaderboardContainer = new Container(); // Main Menu Elements var menuContainer = new Container(); // Add cover image var coverImage = LK.getAsset('coverImage', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 600, scaleX: 1.5, scaleY: 1.2 }); coverImage.tint = 0x87CEEB; menuContainer.addChild(coverImage); // Add decorative bubbles on cover image var decorBubbles = []; for (var d = 0; d < 8; d++) { var decorBubble = LK.getAsset('bubble', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.3 + Math.random() * 0.4, scaleY: 0.3 + Math.random() * 0.4, x: 1024 + (Math.random() - 0.5) * 500, y: 600 + (Math.random() - 0.5) * 300 }); decorBubble.alpha = 0.7; decorBubbles.push(decorBubble); menuContainer.addChild(decorBubble); } // Add golden decorative bubbles for (var g = 0; g < 3; g++) { var goldenDecor = LK.getAsset('goldenBubble', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.25, scaleY: 0.25, x: 1024 + (Math.random() - 0.5) * 400, y: 600 + (Math.random() - 0.5) * 250 }); goldenDecor.alpha = 0.8; decorBubbles.push(goldenDecor); menuContainer.addChild(goldenDecor); } var titleTxt = new Text2('BUBBLE POP FRENZY', { size: 120, fill: 0xFFD700 }); titleTxt.anchor.set(0.5, 0.5); titleTxt.x = 1024; titleTxt.y = 450; menuContainer.addChild(titleTxt); var playBtn = LK.getAsset('bubble', { anchorX: 0.5, anchorY: 0.5, scaleX: 2.5, scaleY: 2.5, x: 1024, y: 1100 }); playBtn.tint = 0x00FF88; menuContainer.addChild(playBtn); var playTxt = new Text2('TAP TO PLAY', { size: 80, fill: 0xFFFFFF }); playTxt.anchor.set(0.5, 0.5); playTxt.x = 1024; playTxt.y = 1100; menuContainer.addChild(playTxt); var bestScoreMenuTxt = new Text2('Best Score: ' + storage.highScore, { size: 60, fill: 0xFFD700 }); bestScoreMenuTxt.anchor.set(0.5, 0.5); bestScoreMenuTxt.x = 1024; bestScoreMenuTxt.y = 1300; menuContainer.addChild(bestScoreMenuTxt); var instructionsTxt = new Text2('Pop bubbles before they escape!\nGolden bubbles = 50 points\nBonus bubbles = 259 points\nCollect coins for speed boost!', { size: 45, fill: 0xFFFFFF }); instructionsTxt.anchor.set(0.5, 0.5); instructionsTxt.x = 1024; instructionsTxt.y = 1550; menuContainer.addChild(instructionsTxt); var leaderboardBtn = LK.getAsset('bubble', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.8, scaleY: 1.8, x: 1024, y: 1800 }); leaderboardBtn.tint = 0xFFD700; menuContainer.addChild(leaderboardBtn); var leaderboardBtnTxt = new Text2('LEADERBOARD', { size: 60, fill: 0x000000 }); leaderboardBtnTxt.anchor.set(0.5, 0.5); leaderboardBtnTxt.x = 1024; leaderboardBtnTxt.y = 1800; menuContainer.addChild(leaderboardBtnTxt); game.addChild(menuContainer); // Create leaderboard container var leaderboardBg = LK.getAsset('coverImage', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 1366, scaleX: 1.8, scaleY: 2.2 }); leaderboardBg.tint = 0x2c3e50; leaderboardContainer.addChild(leaderboardBg); var leaderboardTitle = new Text2('🏆 LEADERBOARD 🏆', { size: 90, fill: 0xFFD700 }); leaderboardTitle.anchor.set(0.5, 0.5); leaderboardTitle.x = 1024; leaderboardTitle.y = 500; leaderboardContainer.addChild(leaderboardTitle); var backBtn = LK.getAsset('bubble', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.5, scaleY: 1.5, x: 1024, y: 2200 }); backBtn.tint = 0xFF6B35; leaderboardContainer.addChild(backBtn); var backBtnTxt = new Text2('BACK', { size: 60, fill: 0xFFFFFF }); backBtnTxt.anchor.set(0.5, 0.5); backBtnTxt.x = 1024; backBtnTxt.y = 2200; leaderboardContainer.addChild(backBtnTxt); leaderboardContainer.visible = false; game.addChild(leaderboardContainer); // Animate menu elements function animateMenu() { // Cover image gentle pulsing tween(coverImage, { scaleX: 1.6, scaleY: 1.3, alpha: 0.9 }, { duration: 2500, easing: tween.easeInOut, onFinish: function onFinish() { tween(coverImage, { scaleX: 1.5, scaleY: 1.2, alpha: 1 }, { duration: 2500, easing: tween.easeInOut }); } }); // Animate decorative bubbles for (var db = 0; db < decorBubbles.length; db++) { var bubble = decorBubbles[db]; var delay = db * 200; LK.setTimeout(function (b) { return function () { tween(b, { y: b.y - 20, rotation: Math.PI / 4 }, { duration: 1500 + Math.random() * 1000, easing: tween.easeInOut, onFinish: function onFinish() { tween(b, { y: b.y + 20, rotation: -Math.PI / 4 }, { duration: 1500 + Math.random() * 1000, easing: tween.easeInOut }); } }); }; }(bubble), delay); } // Title pulsing animation tween(titleTxt, { scaleX: 1.2, scaleY: 1.2 }, { duration: 1500, easing: tween.easeInOut, onFinish: function onFinish() { tween(titleTxt, { scaleX: 1, scaleY: 1 }, { duration: 1500, easing: tween.easeInOut, onFinish: function onFinish() { if (gameState === 'menu') { animateMenu(); } } }); } }); // Play button floating animation tween(playBtn, { y: 1080 }, { duration: 2000, easing: tween.easeInOut, onFinish: function onFinish() { tween(playBtn, { y: 1120 }, { duration: 2000, easing: tween.easeInOut, onFinish: function onFinish() { if (gameState === 'menu') { animateMenu(); } } }); } }); // Sync play text with button tween(playTxt, { y: 1080 }, { duration: 2000, easing: tween.easeInOut, onFinish: function onFinish() { tween(playTxt, { y: 1120 }, { duration: 2000, easing: tween.easeInOut }); } }); // Leaderboard button floating animation tween(leaderboardBtn, { y: 1780 }, { duration: 2200, easing: tween.easeInOut, onFinish: function onFinish() { tween(leaderboardBtn, { y: 1820 }, { duration: 2200, easing: tween.easeInOut, onFinish: function onFinish() { if (gameState === 'menu') { animateMenu(); } } }); } }); // Sync leaderboard text with button tween(leaderboardBtnTxt, { y: 1780 }, { duration: 2200, easing: tween.easeInOut, onFinish: function onFinish() { tween(leaderboardBtnTxt, { y: 1820 }, { duration: 2200, easing: tween.easeInOut }); } }); // Rainbow color cycling for title var colorTimer = 0; function cycleColors() { if (gameState !== 'menu') return; colorTimer += 0.05; var red = Math.floor(Math.sin(colorTimer) * 127 + 128); var green = Math.floor(Math.sin(colorTimer + 2.094) * 127 + 128); var blue = Math.floor(Math.sin(colorTimer + 4.188) * 127 + 128); var rainbowColor = red << 16 | green << 8 | blue; titleTxt.tint = rainbowColor; LK.setTimeout(cycleColors, 50); } cycleColors(); } function updateLeaderboard(newScore) { if (newScore <= 0) return; // Get current leaderboard or create empty array var currentBoard = storage.leaderboard || []; // Add new score with timestamp var scoreEntry = { score: newScore, date: new Date().toLocaleDateString() }; currentBoard.push(scoreEntry); // Sort by score (highest first) and keep top 10 currentBoard.sort(function (a, b) { return b.score - a.score; }); // Keep only top 10 scores if (currentBoard.length > 10) { currentBoard = currentBoard.slice(0, 10); } // Save back to storage storage.leaderboard = currentBoard; } function showLeaderboard() { if (showingLeaderboard) return; showingLeaderboard = true; gameState = 'leaderboard'; // Hide menu menuContainer.visible = false; // Clear previous leaderboard entries for (var i = leaderboardContainer.children.length - 1; i >= 0; i--) { var child = leaderboardContainer.children[i]; if (child.isScoreEntry) { leaderboardContainer.removeChild(child); } } // Display leaderboard scores var leaderboard = storage.leaderboard || []; for (var i = 0; i < Math.min(leaderboard.length, 10); i++) { var entry = leaderboard[i]; var position = i + 1; var medal = position === 1 ? '🥇' : position === 2 ? '🥈' : position === 3 ? '🥉' : position + '.'; var entryText = new Text2(medal + ' ' + entry.score + ' pts - ' + entry.date, { size: 55, fill: position <= 3 ? 0xFFD700 : 0xFFFFFF }); entryText.anchor.set(0.5, 0.5); entryText.x = 1024; entryText.y = 650 + i * 120; entryText.isScoreEntry = true; leaderboardContainer.addChild(entryText); // Add entrance animation entryText.alpha = 0; entryText.x = 1024 + 200; tween(entryText, { alpha: 1, x: 1024 }, { duration: 300 + i * 100, easing: tween.easeOut }); } // Show empty message if no scores if (leaderboard.length === 0) { var emptyText = new Text2('No scores yet!\nStart playing to set records!', { size: 60, fill: 0xAAAAAAA }); emptyText.anchor.set(0.5, 0.5); emptyText.x = 1024; emptyText.y = 1200; emptyText.isScoreEntry = true; leaderboardContainer.addChild(emptyText); } // Show leaderboard with animation leaderboardContainer.visible = true; leaderboardContainer.alpha = 0; tween(leaderboardContainer, { alpha: 1 }, { duration: 500, easing: tween.easeInOut }); } function hideLeaderboard() { if (!showingLeaderboard) return; showingLeaderboard = false; gameState = 'menu'; tween(leaderboardContainer, { alpha: 0 }, { duration: 300, easing: tween.easeInOut, onFinish: function onFinish() { leaderboardContainer.visible = false; menuContainer.visible = true; menuContainer.alpha = 1; animateMenu(); } }); } // Start menu animations animateMenu(); // Play button interaction playBtn.down = function (x, y, obj) { startGame(); }; playTxt.down = function (x, y, obj) { startGame(); }; // Leaderboard button interactions leaderboardBtn.down = function (x, y, obj) { if (gameState === 'menu') { showLeaderboard(); } }; leaderboardBtnTxt.down = function (x, y, obj) { if (gameState === 'menu') { showLeaderboard(); } }; // Back button interactions backBtn.down = function (x, y, obj) { if (gameState === 'leaderboard') { hideLeaderboard(); } }; backBtnTxt.down = function (x, y, obj) { if (gameState === 'leaderboard') { hideLeaderboard(); } }; function startGame() { if (gameState !== 'menu') return; gameState = 'playing'; menuContainer.alpha = 0; menuContainer.visible = false; // Show game UI gameUIContainer.visible = true; gameUIContainer.alpha = 1; // Reset game variables bubbles = []; bubblesEscaped = 0; spawnTimer = 0; spawnInterval = 80; difficultyTimer = 0; comboCount = 0; comboTimer = 0; screenShakeIntensity = 0; coins = []; coinCount = 0; coinSpawnTimer = 0; gameSpeedMultiplier = 1.0; speedBoostTimer = 0; LK.setScore(0); // Update displays scoreTxt.setText('Score: 0'); escapedTxt.setText('Escaped: 0/10'); coinsTxt.setText('Coins: 0'); } // Game UI Container var gameUIContainer = new Container(); // UI Elements var scoreTxt = new Text2('Score: 0', { size: 60, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); gameUIContainer.addChild(scoreTxt); var escapedTxt = new Text2('Escaped: 0/10', { size: 50, fill: 0xFFFFFF }); escapedTxt.anchor.set(1, 0); escapedTxt.x = -20; escapedTxt.y = 80; LK.gui.topRight.addChild(escapedTxt); gameUIContainer.addChild(escapedTxt); var highScoreTxt = new Text2('Best: ' + storage.highScore, { size: 45, fill: 0xFFD700 }); highScoreTxt.anchor.set(0, 0); highScoreTxt.x = 20; highScoreTxt.y = 80; LK.gui.topLeft.addChild(highScoreTxt); gameUIContainer.addChild(highScoreTxt); var comboTxt = new Text2('', { size: 70, fill: 0xFF6B35 }); comboTxt.anchor.set(0.5, 0.5); LK.gui.center.addChild(comboTxt); gameUIContainer.addChild(comboTxt); var coinsTxt = new Text2('Coins: 0', { size: 50, fill: 0xFFD700 }); coinsTxt.anchor.set(0.5, 0); coinsTxt.y = 140; LK.gui.top.addChild(coinsTxt); gameUIContainer.addChild(coinsTxt); // Initially hide game UI gameUIContainer.visible = false; gameUIContainer.alpha = 0; function spawnBubble() { if (gameState !== 'playing') return; var isBonus = Math.random() < 0.02; // 2% chance for bonus bubble (259 points) var isGolden = !isBonus && Math.random() < 0.1; // 10% chance for golden bubble (only if not bonus) var bubble = new Bubble(isGolden, isBonus); // Random spawn position across screen width bubble.x = Math.random() * (2048 - 200) + 100; bubble.y = 2732 + 60; // Start just below screen bubbles.push(bubble); game.addChild(bubble); } function spawnCoin() { if (gameState !== 'playing') return; var coin = new Coin(); // Random spawn position across screen width coin.x = Math.random() * (2048 - 160) + 80; coin.y = -80; // Start above screen coins.push(coin); game.addChild(coin); } function updateDifficulty() { difficultyTimer++; // Increase difficulty every 7 seconds (420 ticks) - faster progression if (difficultyTimer % 420 === 0) { // Decrease spawn interval (spawn faster) spawnInterval = Math.max(25, spawnInterval - 8); // Increase bubble speed more dramatically for (var i = 0; i < bubbles.length; i++) { bubbles[i].speed += 0.4; } } // Every 30 seconds, spawn a burst of golden bubbles for excitement if (difficultyTimer % 1800 === 0) { for (var j = 0; j < 3; j++) { LK.setTimeout(function () { var goldenBubble = new Bubble(true); goldenBubble.x = Math.random() * (2048 - 200) + 100; goldenBubble.y = 2732 + 60; goldenBubble.speed *= 0.7; // Slower so players can catch them bubbles.push(goldenBubble); game.addChild(goldenBubble); }, j * 300); } } // Every 45 seconds, spawn bonus bubble rain for mega excitement if (difficultyTimer % 2700 === 0) { for (var k = 0; k < 5; k++) { LK.setTimeout(function () { var bonusBubble = new Bubble(false, true); bonusBubble.x = Math.random() * (2048 - 200) + 100; bonusBubble.y = 2732 + 60; bonusBubble.speed *= 0.5; // Much slower so players can definitely catch them bubbles.push(bonusBubble); game.addChild(bonusBubble); }, k * 200); } } } game.update = function () { // Only run game logic when playing if (gameState !== 'playing') { // Update best score display in menu if (gameState === 'menu') { bestScoreMenuTxt.setText('Best Score: ' + storage.highScore); } return; } updateDifficulty(); // Speed boost timer countdown if (speedBoostTimer > 0) { speedBoostTimer--; if (speedBoostTimer === 0) { gameSpeedMultiplier = 1.0; // Reset speed multiplier } } // Combo timer countdown if (comboTimer > 0) { comboTimer--; if (comboTimer === 0) { comboCount = 0; // Reset combo when timer expires } } // Spawn coins coinSpawnTimer++; if (coinSpawnTimer >= coinSpawnInterval) { spawnCoin(); coinSpawnTimer = 0; } // Screen shake effect if (screenShakeIntensity > 0) { game.x = (Math.random() - 0.5) * screenShakeIntensity; game.y = (Math.random() - 0.5) * screenShakeIntensity; screenShakeIntensity *= 0.9; // Gradually reduce shake if (screenShakeIntensity < 0.1) { screenShakeIntensity = 0; game.x = 0; game.y = 0; } } // Spawn bubbles faster spawnTimer++; if (spawnTimer >= spawnInterval) { spawnBubble(); spawnTimer = 0; } // Apply speed multiplier to all bubbles for (var b = 0; b < bubbles.length; b++) { bubbles[b].speed = Math.max(bubbles[b].speed, bubbles[b].speed * gameSpeedMultiplier); } // Check for bubbles that escaped for (var i = bubbles.length - 1; i >= 0; i--) { var bubble = bubbles[i]; // Check if bubble escaped (reached top of screen) if (bubble.y < -60) { bubblesEscaped++; bubble.destroy(); bubbles.splice(i, 1); // Reset combo when bubble escapes comboCount = 0; comboTimer = 0; // Update escaped counter escapedTxt.setText('Escaped: ' + bubblesEscaped + '/' + maxEscapedBubbles); // Check game over condition if (bubblesEscaped >= maxEscapedBubbles) { // Update high score before game over var currentScore = LK.getScore(); if (currentScore > storage.highScore) { storage.highScore = currentScore; highScoreTxt.setText('Best: ' + storage.highScore); } // Add score to leaderboard updateLeaderboard(currentScore); // Clean up game objects for (var cleanBubble = bubbles.length - 1; cleanBubble >= 0; cleanBubble--) { bubbles[cleanBubble].destroy(); } bubbles = []; for (var cleanCoin = coins.length - 1; cleanCoin >= 0; cleanCoin--) { coins[cleanCoin].destroy(); } coins = []; // Return to menu after short delay LK.setTimeout(function () { gameState = 'menu'; gameUIContainer.visible = false; gameUIContainer.alpha = 0; menuContainer.visible = true; tween(menuContainer, { alpha: 1 }, { duration: 500, easing: tween.easeInOut, onFinish: function onFinish() { animateMenu(); } }); }, 2000); LK.showGameOver(); return; } } } // Check for coins that fell off screen for (var c = coins.length - 1; c >= 0; c--) { var coin = coins[c]; if (coin.y > 2732 + 80) { coin.destroy(); coins.splice(c, 1); } } // Update score display scoreTxt.setText('Score: ' + LK.getScore()); // Dynamic background color based on score for atmosphere var currentScore = LK.getScore(); var colorPhase = currentScore * 0.01 % (Math.PI * 2); var bgRed = Math.floor(Math.sin(colorPhase) * 40 + 100); var bgGreen = Math.floor(Math.sin(colorPhase + 2.094) * 40 + 150); var bgBlue = Math.floor(Math.sin(colorPhase + 4.188) * 40 + 200); var dynamicBgColor = bgRed << 16 | bgGreen << 8 | bgBlue; game.setBackgroundColor(dynamicBgColor); // Update high score display in real-time if beaten var currentScore = LK.getScore(); if (currentScore > storage.highScore) { storage.highScore = currentScore; highScoreTxt.setText('Best: ' + storage.highScore); highScoreTxt.tint = 0x00FF00; // Green highlight for new record } };
===================================================================
--- original.js
+++ change.js
@@ -2,9 +2,10 @@
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1", {
- highScore: 0
+ highScore: 0,
+ leaderboard: []
});
/****
* Classes
@@ -380,9 +381,9 @@
/****
* Game Code
****/
// Game state management
-var gameState = 'menu'; // 'menu', 'playing', 'gameOver'
+var gameState = 'menu'; // 'menu', 'playing', 'gameOver', 'leaderboard'
var bubbles = [];
var bubblesEscaped = 0;
var maxEscapedBubbles = 10;
var spawnTimer = 0;
@@ -396,8 +397,10 @@
var coinSpawnTimer = 0;
var coinSpawnInterval = 300; // Spawn coins every 5 seconds
var gameSpeedMultiplier = 1.0;
var speedBoostTimer = 0;
+var showingLeaderboard = false;
+var leaderboardContainer = new Container();
// Main Menu Elements
var menuContainer = new Container();
// Add cover image
var coverImage = LK.getAsset('coverImage', {
@@ -480,9 +483,66 @@
instructionsTxt.anchor.set(0.5, 0.5);
instructionsTxt.x = 1024;
instructionsTxt.y = 1550;
menuContainer.addChild(instructionsTxt);
+var leaderboardBtn = LK.getAsset('bubble', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 1.8,
+ scaleY: 1.8,
+ x: 1024,
+ y: 1800
+});
+leaderboardBtn.tint = 0xFFD700;
+menuContainer.addChild(leaderboardBtn);
+var leaderboardBtnTxt = new Text2('LEADERBOARD', {
+ size: 60,
+ fill: 0x000000
+});
+leaderboardBtnTxt.anchor.set(0.5, 0.5);
+leaderboardBtnTxt.x = 1024;
+leaderboardBtnTxt.y = 1800;
+menuContainer.addChild(leaderboardBtnTxt);
game.addChild(menuContainer);
+// Create leaderboard container
+var leaderboardBg = LK.getAsset('coverImage', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 1024,
+ y: 1366,
+ scaleX: 1.8,
+ scaleY: 2.2
+});
+leaderboardBg.tint = 0x2c3e50;
+leaderboardContainer.addChild(leaderboardBg);
+var leaderboardTitle = new Text2('🏆 LEADERBOARD 🏆', {
+ size: 90,
+ fill: 0xFFD700
+});
+leaderboardTitle.anchor.set(0.5, 0.5);
+leaderboardTitle.x = 1024;
+leaderboardTitle.y = 500;
+leaderboardContainer.addChild(leaderboardTitle);
+var backBtn = LK.getAsset('bubble', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 1.5,
+ scaleY: 1.5,
+ x: 1024,
+ y: 2200
+});
+backBtn.tint = 0xFF6B35;
+leaderboardContainer.addChild(backBtn);
+var backBtnTxt = new Text2('BACK', {
+ size: 60,
+ fill: 0xFFFFFF
+});
+backBtnTxt.anchor.set(0.5, 0.5);
+backBtnTxt.x = 1024;
+backBtnTxt.y = 2200;
+leaderboardContainer.addChild(backBtnTxt);
+leaderboardContainer.visible = false;
+game.addChild(leaderboardContainer);
// Animate menu elements
function animateMenu() {
// Cover image gentle pulsing
tween(coverImage, {
@@ -584,8 +644,43 @@
easing: tween.easeInOut
});
}
});
+ // Leaderboard button floating animation
+ tween(leaderboardBtn, {
+ y: 1780
+ }, {
+ duration: 2200,
+ easing: tween.easeInOut,
+ onFinish: function onFinish() {
+ tween(leaderboardBtn, {
+ y: 1820
+ }, {
+ duration: 2200,
+ easing: tween.easeInOut,
+ onFinish: function onFinish() {
+ if (gameState === 'menu') {
+ animateMenu();
+ }
+ }
+ });
+ }
+ });
+ // Sync leaderboard text with button
+ tween(leaderboardBtnTxt, {
+ y: 1780
+ }, {
+ duration: 2200,
+ easing: tween.easeInOut,
+ onFinish: function onFinish() {
+ tween(leaderboardBtnTxt, {
+ y: 1820
+ }, {
+ duration: 2200,
+ easing: tween.easeInOut
+ });
+ }
+ });
// Rainbow color cycling for title
var colorTimer = 0;
function cycleColors() {
if (gameState !== 'menu') return;
@@ -598,8 +693,107 @@
LK.setTimeout(cycleColors, 50);
}
cycleColors();
}
+function updateLeaderboard(newScore) {
+ if (newScore <= 0) return;
+ // Get current leaderboard or create empty array
+ var currentBoard = storage.leaderboard || [];
+ // Add new score with timestamp
+ var scoreEntry = {
+ score: newScore,
+ date: new Date().toLocaleDateString()
+ };
+ currentBoard.push(scoreEntry);
+ // Sort by score (highest first) and keep top 10
+ currentBoard.sort(function (a, b) {
+ return b.score - a.score;
+ });
+ // Keep only top 10 scores
+ if (currentBoard.length > 10) {
+ currentBoard = currentBoard.slice(0, 10);
+ }
+ // Save back to storage
+ storage.leaderboard = currentBoard;
+}
+function showLeaderboard() {
+ if (showingLeaderboard) return;
+ showingLeaderboard = true;
+ gameState = 'leaderboard';
+ // Hide menu
+ menuContainer.visible = false;
+ // Clear previous leaderboard entries
+ for (var i = leaderboardContainer.children.length - 1; i >= 0; i--) {
+ var child = leaderboardContainer.children[i];
+ if (child.isScoreEntry) {
+ leaderboardContainer.removeChild(child);
+ }
+ }
+ // Display leaderboard scores
+ var leaderboard = storage.leaderboard || [];
+ for (var i = 0; i < Math.min(leaderboard.length, 10); i++) {
+ var entry = leaderboard[i];
+ var position = i + 1;
+ var medal = position === 1 ? '🥇' : position === 2 ? '🥈' : position === 3 ? '🥉' : position + '.';
+ var entryText = new Text2(medal + ' ' + entry.score + ' pts - ' + entry.date, {
+ size: 55,
+ fill: position <= 3 ? 0xFFD700 : 0xFFFFFF
+ });
+ entryText.anchor.set(0.5, 0.5);
+ entryText.x = 1024;
+ entryText.y = 650 + i * 120;
+ entryText.isScoreEntry = true;
+ leaderboardContainer.addChild(entryText);
+ // Add entrance animation
+ entryText.alpha = 0;
+ entryText.x = 1024 + 200;
+ tween(entryText, {
+ alpha: 1,
+ x: 1024
+ }, {
+ duration: 300 + i * 100,
+ easing: tween.easeOut
+ });
+ }
+ // Show empty message if no scores
+ if (leaderboard.length === 0) {
+ var emptyText = new Text2('No scores yet!\nStart playing to set records!', {
+ size: 60,
+ fill: 0xAAAAAAA
+ });
+ emptyText.anchor.set(0.5, 0.5);
+ emptyText.x = 1024;
+ emptyText.y = 1200;
+ emptyText.isScoreEntry = true;
+ leaderboardContainer.addChild(emptyText);
+ }
+ // Show leaderboard with animation
+ leaderboardContainer.visible = true;
+ leaderboardContainer.alpha = 0;
+ tween(leaderboardContainer, {
+ alpha: 1
+ }, {
+ duration: 500,
+ easing: tween.easeInOut
+ });
+}
+function hideLeaderboard() {
+ if (!showingLeaderboard) return;
+ showingLeaderboard = false;
+ gameState = 'menu';
+ tween(leaderboardContainer, {
+ alpha: 0
+ }, {
+ duration: 300,
+ easing: tween.easeInOut,
+ onFinish: function onFinish() {
+ leaderboardContainer.visible = false;
+ menuContainer.visible = true;
+ menuContainer.alpha = 1;
+ animateMenu();
+ }
+ });
+}
// Start menu animations
animateMenu();
// Play button interaction
playBtn.down = function (x, y, obj) {
@@ -607,8 +801,30 @@
};
playTxt.down = function (x, y, obj) {
startGame();
};
+// Leaderboard button interactions
+leaderboardBtn.down = function (x, y, obj) {
+ if (gameState === 'menu') {
+ showLeaderboard();
+ }
+};
+leaderboardBtnTxt.down = function (x, y, obj) {
+ if (gameState === 'menu') {
+ showLeaderboard();
+ }
+};
+// Back button interactions
+backBtn.down = function (x, y, obj) {
+ if (gameState === 'leaderboard') {
+ hideLeaderboard();
+ }
+};
+backBtnTxt.down = function (x, y, obj) {
+ if (gameState === 'leaderboard') {
+ hideLeaderboard();
+ }
+};
function startGame() {
if (gameState !== 'menu') return;
gameState = 'playing';
menuContainer.alpha = 0;
@@ -811,8 +1027,10 @@
if (currentScore > storage.highScore) {
storage.highScore = currentScore;
highScoreTxt.setText('Best: ' + storage.highScore);
}
+ // Add score to leaderboard
+ updateLeaderboard(currentScore);
// Clean up game objects
for (var cleanBubble = bubbles.length - 1; cleanBubble >= 0; cleanBubble--) {
bubbles[cleanBubble].destroy();
}