User prompt
120 fps seçildinde her tokladında gelen score yazısı +1 ekranda ve 0 sayısın üstünde +1 veya o score çıksın ve score eklensin ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
120 fps seçtinde gelen +1 yazsın ekranda gelsin ve +1 yasını score üstünde çıksın +1 yazısı çıksın ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
120 fps semtinde güneş detayını sil güneş ve ay olmasın
User prompt
Güneş sarı olsun ve etrafa ışık ile aydınlatsın 120 fps te ve etrafta sabah ken aydınlık olsun sarı olsun böyle saydam güneşte ışık gelsin ve rainy system de olsun yağmur da yağsın ↪💡 Consider importing and using the following plugins: @upit/tween.v1
Code edit (1 edits merged)
Please save this source code
User prompt
120 fps seçildinde ekranda yağmur yağsın yağmur her 5 dakak sürüsün her 10 dakka bir yağmur yağsın ve su damlası yere damlasında aynı su gibi shock wawe olsunşun yağmur shock wawe ve üsttede saat ya,sın gerçek hayattan 20x hızlı geçsin saat dakka yazsın ve ekranda güneş olsun saat ilerledikçe batsın battı zaman ay ortaya çıksın ve etraf gece olsun ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Ekranda ağaç detaylarını sil
User prompt
120 fps te ekrana helen agaç detaylarını sil
User prompt
Oyundaki 120 fps seçildinde ekrana kelen normal ağaç ve çam ağacının detaylarını kaldırın
User prompt
120 fps teli taş yollar Araçlar kamp ateşi odun bu eşyaları kaldır
User prompt
Menü deki 120 fps seçildinde etrafa ultra gerçekçi ekrana gerçekçi ağaçlar dalları olan çam ağacı sonra normal ağaç ikisine birisi sağda birisi solda ortada yuvarlak gerçekçi ultra gerçekçi detaylı bir uzun odun etrafta taş yollar ve en ortada bir bir kam ateşi gerçekçi alev animasyonu ve yukarı doğru animasyon çıksın etrafında 2 tane odun olsun odunlar ultra gerçekçi çok fazla gerçekçi odun üstünde çizgiler detaylar cam ayaklar ultra mega gerçekçi ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Menü deki 120 fps tıklama animasyon ve yazılar daha detaylı daha gerçekçi olsun ve yumurtalar dış görünüş daha detaylı ve gerçekçi olsun ve yumurtaları açılma animasyon her tıkaldında çatlasın ve sağ sola haraket etsin 3 defa çatlasın 4 defa tıkaldımızda çatlatan bir sarı ışık çıksın saydam fener gibi bir sarı ışık çıksın ve oradaki bir pet ekrana doğru gelsin ve yumurta altta doğru duşun yok olsun çıktık tam sonra ekrana doğru yaklaştın ve ekrana geldikten sonra ekranda 2 3 saniye dursun ve altta özellikleri tıklama başına kac score geldiği kaç şans ile çıktı nadirlik yüzde kaç oranla çıktığı yazsın ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Menüdeki 90 fps seçildin +1 tıkalmama basın gelen +1 puan yazısı veya yazılar daha detaylı ve gerçekçi olsun ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
120 fps çıkan shock wawe yuvarlak olsun ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Menü deki 120 fps Secildinde 120 fps score yazısı aşağa doğru gitmesin oldu yerde dursun sadece helen puan ona doğru ilelrisin carptında score yazısı artsın ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Menü deki 120 fps seçildinde tıklama animasyonu ayrietten shock wawe oluşsun beyaz tıkladın yerde ve +1 yazsın ve score yazsın doğru gitsin ve score yazısının üstüne +1 yazsın ve 0 yazısının aşağına doğru insin ve 0 deydi anda 1 dönüşsün ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
120 fps seçiminde aynı şekilde yumurtaların dış görünüşüne güzelleşsin ve detaylarını artır ve aynı şekilde açılış animasyonu daha kaliteli kırılma animasyonu çatlama animasyonu ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Menü button birazdan sağa doğru çek
User prompt
Sol üste add menü buton 2 tane alt altta 3 tane düz kalım çizgi olsun açmak için üstüne tıklıyalım kapatmak için bşdaha üstüne tıklıyaoım menü açıldında en üste grapichs olsun 3 tane birisi 30fps için ekran bilan animasyon kötü w. 60 fps yani normal herşey 90fos yüksek bütün animasyonlar kaliteli aha çok yumurtalar daha detaylı olsun en yüksek 90 fps yanında 120 fps ve ultra gerçekçi yumurtalar çok detaylı olsun tıklayınca gelen animasyon detayı gelen score animasyonlu şekilde üste doğru gitsin ve +1 yazarak eklensin ve ultra gerçekçi grafikler görüntüler olsun ama çok fazla örneği yumurta açılış animasyonu sağ sola haraket etsin ve ensende çatlasın ve aralıkla ışık çıksın ve ondan pet çıksın ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Lucky boost class delete
User prompt
Lucky boost Shop add 1 mimitues 10000 score 5 mimitues 50000 scoe 10 minitues 100000 score Lucky boost yumurtaları etkili her zaman en düşük ihtimalle çıkan 2 peti şansını 10x artırrır ama en çok ihtimalle çıkan pet 10x duyurur yani 1 peti duyurur diyr en duşun ve en çok score olan me çok düşük ihtimalle çıkan 2 peti 10x arttır şansını ama diğeri en çok ihtimalle çıkanın en güçsüz peti 10x şansını düşürür
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x2c3e50 // Dark blue-gray background }); /**** * Game Code ****/ // Reset all storage on game start storage.currentMultiplier = 1; storage.inventory = []; storage.equippedAnimals = []; // Global game variables var currentMultiplier = 1; var inventory = []; var isInventoryOpen = false; var inventoryOverlay = null; var equippedAnimals = []; var maxEquippedPets = 3; var fallingEgg = null; var eggClickCount = 0; var deleteMode = false; var selectedDeleteAnimalType = null; var luckyBoostActive = false; var luckyBoostEndTime = 0; var isLuckyBoostShopOpen = false; var luckyBoostOverlay = null; // Reset score to 0 on game start LK.setScore(0); // Initialize score display var scoreTxt = new Text2('0', { size: 120, fill: 0xFFFFFF }); // Set score text properties scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Position score text with some padding from top scoreTxt.y = 100; // Add tap instruction text var instructionTxt = new Text2('Tap anywhere to score!', { size: 60, fill: 0xBDC3C7 }); instructionTxt.anchor.set(0.5, 0.5); instructionTxt.x = 2048 / 2; instructionTxt.y = 2732 / 2; game.addChild(instructionTxt); // Handle tap events on the game area game.down = function (x, y, obj) { // Calculate pet bonus based on equipped animal quantities var petBonus = 0; // Count each animal type var dogCount = 0; var catCount = 0; var snakeCount = 0; var goldenDogCount = 0; var goldenCatCount = 0; var goldenSnakeCount = 0; var dinosaurCount = 0; var bearCount = 0; var beeCount = 0; var goldenDinosaurCount = 0; var goldenBearCount = 0; var goldenBeeCount = 0; var trexCount = 0; var velectorCount = 0; var titanaBullCount = 0; var goldenTrexCount = 0; var goldenVelectorCount = 0; var goldenTitanaBullCount = 0; var ironManCount = 0; var captainAmericaCount = 0; var spidermanCount = 0; var goldenIronManCount = 0; var goldenCaptainAmericaCount = 0; var goldenSpidermanCount = 0; var kingCount = 0; var knightCount = 0; var humanCount = 0; var goldenKingCount = 0; var goldenKnightCount = 0; var goldenHumanCount = 0; var earthCount = 0; var moonCount = 0; var meteorCount = 0; var sunCount = 0; var jupiterCount = 0; var neptuneCount = 0; var goldenEarthCount = 0; var goldenMoonCount = 0; var goldenMeteorCount = 0; var goldenSunCount = 0; var goldenJupiterCount = 0; var goldenNeptuneCount = 0; var andromedaGalaxyCount = 0; var normalGalaxyCount = 0; var milkyWayGalaxyCount = 0; var goldenAndromedaGalaxyCount = 0; var goldenNormalGalaxyCount = 0; var goldenMilkyWayGalaxyCount = 0; for (var j = 0; j < equippedAnimals.length; j++) { if (equippedAnimals[j] === 'dog') { dogCount++; } else if (equippedAnimals[j] === 'cat') { catCount++; } else if (equippedAnimals[j] === 'snake') { snakeCount++; } else if (equippedAnimals[j] === 'goldenDog') { goldenDogCount++; } else if (equippedAnimals[j] === 'goldenCat') { goldenCatCount++; } else if (equippedAnimals[j] === 'goldenSnake') { goldenSnakeCount++; } else if (equippedAnimals[j] === 'dinosaur') { dinosaurCount++; } else if (equippedAnimals[j] === 'bear') { bearCount++; } else if (equippedAnimals[j] === 'bee') { beeCount++; } else if (equippedAnimals[j] === 'goldenDinosaur') { goldenDinosaurCount++; } else if (equippedAnimals[j] === 'goldenBear') { goldenBearCount++; } else if (equippedAnimals[j] === 'goldenBee') { goldenBeeCount++; } else if (equippedAnimals[j] === 'trex') { trexCount++; } else if (equippedAnimals[j] === 'velector') { velectorCount++; } else if (equippedAnimals[j] === 'titanaBull') { titanaBullCount++; } else if (equippedAnimals[j] === 'goldenTrex') { goldenTrexCount++; } else if (equippedAnimals[j] === 'goldenVelector') { goldenVelectorCount++; } else if (equippedAnimals[j] === 'goldenTitanaBull') { goldenTitanaBullCount++; } else if (equippedAnimals[j] === 'ironMan') { ironManCount++; } else if (equippedAnimals[j] === 'captainAmerica') { captainAmericaCount++; } else if (equippedAnimals[j] === 'spiderman') { spidermanCount++; } else if (equippedAnimals[j] === 'goldenIronMan') { goldenIronManCount++; } else if (equippedAnimals[j] === 'goldenCaptainAmerica') { goldenCaptainAmericaCount++; } else if (equippedAnimals[j] === 'goldenSpiderman') { goldenSpidermanCount++; } else if (equippedAnimals[j] === 'king') { kingCount++; } else if (equippedAnimals[j] === 'knight') { knightCount++; } else if (equippedAnimals[j] === 'human') { humanCount++; } else if (equippedAnimals[j] === 'goldenKing') { goldenKingCount++; } else if (equippedAnimals[j] === 'goldenKnight') { goldenKnightCount++; } else if (equippedAnimals[j] === 'goldenHuman') { goldenHumanCount++; } else if (equippedAnimals[j] === 'earth') { earthCount++; } else if (equippedAnimals[j] === 'moon') { moonCount++; } else if (equippedAnimals[j] === 'meteor') { meteorCount++; } else if (equippedAnimals[j] === 'sun') { sunCount++; } else if (equippedAnimals[j] === 'jupiter') { jupiterCount++; } else if (equippedAnimals[j] === 'neptune') { neptuneCount++; } else if (equippedAnimals[j] === 'goldenEarth') { goldenEarthCount++; } else if (equippedAnimals[j] === 'goldenMoon') { goldenMoonCount++; } else if (equippedAnimals[j] === 'goldenMeteor') { goldenMeteorCount++; } else if (equippedAnimals[j] === 'goldenSun') { goldenSunCount++; } else if (equippedAnimals[j] === 'goldenJupiter') { goldenJupiterCount++; } else if (equippedAnimals[j] === 'goldenNeptune') { goldenNeptuneCount++; } else if (equippedAnimals[j] === 'andromedaGalaxy') { andromedaGalaxyCount++; } else if (equippedAnimals[j] === 'normalGalaxy') { normalGalaxyCount++; } else if (equippedAnimals[j] === 'milkyWayGalaxy') { milkyWayGalaxyCount++; } else if (equippedAnimals[j] === 'goldenAndromedaGalaxy') { goldenAndromedaGalaxyCount++; } else if (equippedAnimals[j] === 'goldenNormalGalaxy') { goldenNormalGalaxyCount++; } else if (equippedAnimals[j] === 'goldenMilkyWayGalaxy') { goldenMilkyWayGalaxyCount++; } } // Each dog gives +1 bonus per tap petBonus += dogCount; // Cats: 1 cat = +2, 2 cats = +4, 3 cats = +6 (total bonus) if (catCount === 1) { petBonus += 2; } else if (catCount === 2) { petBonus += 4; } else if (catCount === 3) { petBonus += 6; } // Snakes: 1 snake = +5, 2 snakes = +10, 3 snakes = +15 (total bonus) if (snakeCount === 1) { petBonus += 5; } else if (snakeCount === 2) { petBonus += 10; } else if (snakeCount === 3) { petBonus += 15; } // Golden pets bonuses // Golden dogs: 1 = +3, 2 = +6, 3 = +9 per tap if (goldenDogCount === 1) { petBonus += 3; } else if (goldenDogCount === 2) { petBonus += 6; } else if (goldenDogCount === 3) { petBonus += 9; } // Golden cats: 1 = +6, 2 = +12, 3 = +18 per tap if (goldenCatCount === 1) { petBonus += 6; } else if (goldenCatCount === 2) { petBonus += 12; } else if (goldenCatCount === 3) { petBonus += 18; } // Golden snakes: 1 = +10, 2 = +20, 3 = +30 per tap if (goldenSnakeCount === 1) { petBonus += 10; } else if (goldenSnakeCount === 2) { petBonus += 20; } else if (goldenSnakeCount === 3) { petBonus += 30; } // Green egg pets bonuses // Dinosaurs: 1 = +30, 2 = +60, 3 = +90 per tap if (dinosaurCount === 1) { petBonus += 30; } else if (dinosaurCount === 2) { petBonus += 60; } else if (dinosaurCount === 3) { petBonus += 90; } // Bears: 1 = +20, 2 = +40, 3 = +60 per tap if (bearCount === 1) { petBonus += 20; } else if (bearCount === 2) { petBonus += 40; } else if (bearCount === 3) { petBonus += 60; } // Bees: 1 = +10, 2 = +20, 3 = +30 per tap if (beeCount === 1) { petBonus += 10; } else if (beeCount === 2) { petBonus += 20; } else if (beeCount === 3) { petBonus += 30; } // Golden green egg pets bonuses (2x multiplier) // Golden dinosaurs: 1 = +60, 2 = +120, 3 = +180 per tap if (goldenDinosaurCount === 1) { petBonus += 60; } else if (goldenDinosaurCount === 2) { petBonus += 120; } else if (goldenDinosaurCount === 3) { petBonus += 180; } // Golden bears: 1 = +40, 2 = +80, 3 = +120 per tap if (goldenBearCount === 1) { petBonus += 40; } else if (goldenBearCount === 2) { petBonus += 80; } else if (goldenBearCount === 3) { petBonus += 120; } // Golden bees: 1 = +20, 2 = +40, 3 = +60 per tap if (goldenBeeCount === 1) { petBonus += 20; } else if (goldenBeeCount === 2) { petBonus += 40; } else if (goldenBeeCount === 3) { petBonus += 60; } // Red egg pets bonuses // T-rex: 1 = +100, 2 = +200, 3 = +300 per tap if (trexCount === 1) { petBonus += 100; } else if (trexCount === 2) { petBonus += 200; } else if (trexCount === 3) { petBonus += 300; } // Velector: 1 = +80, 2 = +160, 3 = +240 per tap if (velectorCount === 1) { petBonus += 80; } else if (velectorCount === 2) { petBonus += 160; } else if (velectorCount === 3) { petBonus += 240; } // Titana Bull: 1 = +50, 2 = +100, 3 = +150 per tap if (titanaBullCount === 1) { petBonus += 50; } else if (titanaBullCount === 2) { petBonus += 100; } else if (titanaBullCount === 3) { petBonus += 150; } // Golden red egg pets bonuses // Golden T-rex: 1 = +200, 2 = +400, 3 = +600 per tap if (goldenTrexCount === 1) { petBonus += 200; } else if (goldenTrexCount === 2) { petBonus += 400; } else if (goldenTrexCount === 3) { petBonus += 600; } // Golden Velector: 1 = +160, 2 = +320, 3 = +480 per tap if (goldenVelectorCount === 1) { petBonus += 160; } else if (goldenVelectorCount === 2) { petBonus += 320; } else if (goldenVelectorCount === 3) { petBonus += 480; } // Golden Titana Bull: 1 = +100, 2 = +200, 3 = +300 per tap if (goldenTitanaBullCount === 1) { petBonus += 100; } else if (goldenTitanaBullCount === 2) { petBonus += 200; } else if (goldenTitanaBullCount === 3) { petBonus += 300; } // Purple egg pets bonuses // Iron Man: 1 = +500, 2 = +1000, 3 = +1500 per tap if (ironManCount === 1) { petBonus += 500; } else if (ironManCount === 2) { petBonus += 1000; } else if (ironManCount === 3) { petBonus += 1500; } // Captain America: 1 = +300, 2 = +600, 3 = +900 per tap if (captainAmericaCount === 1) { petBonus += 300; } else if (captainAmericaCount === 2) { petBonus += 600; } else if (captainAmericaCount === 3) { petBonus += 900; } // Spiderman: 1 = +250, 2 = +500, 3 = +750 per tap if (spidermanCount === 1) { petBonus += 250; } else if (spidermanCount === 2) { petBonus += 500; } else if (spidermanCount === 3) { petBonus += 750; } // Golden purple egg pets bonuses (2x multiplier) // Golden Iron Man: 1 = +1000, 2 = +2000, 3 = +3000 per tap if (goldenIronManCount === 1) { petBonus += 1000; } else if (goldenIronManCount === 2) { petBonus += 2000; } else if (goldenIronManCount === 3) { petBonus += 3000; } // Golden Captain America: 1 = +600, 2 = +1200, 3 = +1800 per tap if (goldenCaptainAmericaCount === 1) { petBonus += 600; } else if (goldenCaptainAmericaCount === 2) { petBonus += 1200; } else if (goldenCaptainAmericaCount === 3) { petBonus += 1800; } // Golden Spiderman: 1 = +500, 2 = +1000, 3 = +1500 per tap if (goldenSpidermanCount === 1) { petBonus += 500; } else if (goldenSpidermanCount === 2) { petBonus += 1000; } else if (goldenSpidermanCount === 3) { petBonus += 1500; } // White egg pets bonuses // King: 1 = +10000, 2 = +20000, 3 = +30000 per tap if (kingCount === 1) { petBonus += 10000; } else if (kingCount === 2) { petBonus += 20000; } else if (kingCount === 3) { petBonus += 30000; } // Knight: 1 = +5000, 2 = +10000, 3 = +15000 per tap if (knightCount === 1) { petBonus += 5000; } else if (knightCount === 2) { petBonus += 10000; } else if (knightCount === 3) { petBonus += 15000; } // Human: 1 = +2500, 2 = +5000, 3 = +7500 per tap if (humanCount === 1) { petBonus += 2500; } else if (humanCount === 2) { petBonus += 5000; } else if (humanCount === 3) { petBonus += 7500; } // Golden white egg pets bonuses (2x multiplier) // Golden King: 1 = +20000, 2 = +40000, 3 = +60000 per tap if (goldenKingCount === 1) { petBonus += 20000; } else if (goldenKingCount === 2) { petBonus += 40000; } else if (goldenKingCount === 3) { petBonus += 60000; } // Golden Knight: 1 = +10000, 2 = +20000, 3 = +30000 per tap if (goldenKnightCount === 1) { petBonus += 10000; } else if (goldenKnightCount === 2) { petBonus += 20000; } else if (goldenKnightCount === 3) { petBonus += 30000; } // Golden Human: 1 = +5000, 2 = +10000, 3 = +15000 per tap if (goldenHumanCount === 1) { petBonus += 5000; } else if (goldenHumanCount === 2) { petBonus += 10000; } else if (goldenHumanCount === 3) { petBonus += 15000; } // Space egg pets bonuses // Earth: 1 = +100000, 2 = +200000, 3 = +300000 per tap if (earthCount === 1) { petBonus += 100000; } else if (earthCount === 2) { petBonus += 200000; } else if (earthCount === 3) { petBonus += 300000; } // Moon: 1 = +50000, 2 = +100000, 3 = +150000 per tap if (moonCount === 1) { petBonus += 50000; } else if (moonCount === 2) { petBonus += 100000; } else if (moonCount === 3) { petBonus += 150000; } // Meteor: 1 = +25000, 2 = +50000, 3 = +75000 per tap if (meteorCount === 1) { petBonus += 25000; } else if (meteorCount === 2) { petBonus += 50000; } else if (meteorCount === 3) { petBonus += 75000; } // Sun: 1 = +500000, 2 = +1000000, 3 = +1500000 per tap if (sunCount === 1) { petBonus += 500000; } else if (sunCount === 2) { petBonus += 1000000; } else if (sunCount === 3) { petBonus += 1500000; } // Jupiter: 1 = +250000, 2 = +500000, 3 = +750000 per tap if (jupiterCount === 1) { petBonus += 250000; } else if (jupiterCount === 2) { petBonus += 500000; } else if (jupiterCount === 3) { petBonus += 750000; } // Neptune: 1 = +200000, 2 = +400000, 3 = +600000 per tap if (neptuneCount === 1) { petBonus += 200000; } else if (neptuneCount === 2) { petBonus += 400000; } else if (neptuneCount === 3) { petBonus += 600000; } // Golden space egg pets bonuses (2x multiplier) // Golden Earth: 1 = +200000, 2 = +400000, 3 = +600000 per tap if (goldenEarthCount === 1) { petBonus += 200000; } else if (goldenEarthCount === 2) { petBonus += 400000; } else if (goldenEarthCount === 3) { petBonus += 600000; } // Golden Moon: 1 = +100000, 2 = +200000, 3 = +300000 per tap if (goldenMoonCount === 1) { petBonus += 100000; } else if (goldenMoonCount === 2) { petBonus += 200000; } else if (goldenMoonCount === 3) { petBonus += 300000; } // Golden Meteor: 1 = +50000, 2 = +100000, 3 = +150000 per tap if (goldenMeteorCount === 1) { petBonus += 50000; } else if (goldenMeteorCount === 2) { petBonus += 100000; } else if (goldenMeteorCount === 3) { petBonus += 150000; } // Golden Sun: 1 = +1000000, 2 = +2000000, 3 = +3000000 per tap if (goldenSunCount === 1) { petBonus += 1000000; } else if (goldenSunCount === 2) { petBonus += 2000000; } else if (goldenSunCount === 3) { petBonus += 3000000; } // Golden Jupiter: 1 = +500000, 2 = +1000000, 3 = +1500000 per tap if (goldenJupiterCount === 1) { petBonus += 500000; } else if (goldenJupiterCount === 2) { petBonus += 1000000; } else if (goldenJupiterCount === 3) { petBonus += 1500000; } // Golden Neptune: 1 = +400000, 2 = +800000, 3 = +1200000 per tap if (goldenNeptuneCount === 1) { petBonus += 400000; } else if (goldenNeptuneCount === 2) { petBonus += 800000; } else if (goldenNeptuneCount === 3) { petBonus += 1200000; } // Galaxy egg pets bonuses // Andromeda Galaxy: 1 = +5000000, 2 = +10000000, 3 = +15000000 per tap if (andromedaGalaxyCount === 1) { petBonus += 5000000; } else if (andromedaGalaxyCount === 2) { petBonus += 10000000; } else if (andromedaGalaxyCount === 3) { petBonus += 15000000; } // Normal Galaxy: 1 = +10000000, 2 = +20000000, 3 = +30000000 per tap if (normalGalaxyCount === 1) { petBonus += 10000000; } else if (normalGalaxyCount === 2) { petBonus += 20000000; } else if (normalGalaxyCount === 3) { petBonus += 30000000; } // Milky Way Galaxy: 1 = +20000000, 2 = +40000000, 3 = +60000000 per tap if (milkyWayGalaxyCount === 1) { petBonus += 20000000; } else if (milkyWayGalaxyCount === 2) { petBonus += 40000000; } else if (milkyWayGalaxyCount === 3) { petBonus += 60000000; } // Golden galaxy egg pets bonuses (2x multiplier) // Golden Andromeda Galaxy: 1 = +10000000, 2 = +20000000, 3 = +30000000 per tap if (goldenAndromedaGalaxyCount === 1) { petBonus += 10000000; } else if (goldenAndromedaGalaxyCount === 2) { petBonus += 20000000; } else if (goldenAndromedaGalaxyCount === 3) { petBonus += 30000000; } // Golden Normal Galaxy: 1 = +20000000, 2 = +40000000, 3 = +60000000 per tap if (goldenNormalGalaxyCount === 1) { petBonus += 20000000; } else if (goldenNormalGalaxyCount === 2) { petBonus += 40000000; } else if (goldenNormalGalaxyCount === 3) { petBonus += 60000000; } // Golden Milky Way Galaxy: 1 = +40000000, 2 = +80000000, 3 = +120000000 per tap if (goldenMilkyWayGalaxyCount === 1) { petBonus += 40000000; } else if (goldenMilkyWayGalaxyCount === 2) { petBonus += 80000000; } else if (goldenMilkyWayGalaxyCount === 3) { petBonus += 120000000; } // Base tap score is always 1, plus calculated pet bonus var totalScore = 1 + petBonus; LK.setScore(LK.getScore() + totalScore); // Update score display scoreTxt.setText(LK.getScore().toString()); // Create visual feedback at tap location showing total points gained var feedbackText = '+' + totalScore.toString(); var tapFeedback = new Text2(feedbackText, { size: 80, fill: 0x27AE60 }); tapFeedback.anchor.set(0.5, 0.5); tapFeedback.x = x; tapFeedback.y = y; tapFeedback.alpha = 1; game.addChild(tapFeedback); // Animate feedback text var startY = y; var animationDuration = 800; var startTime = Date.now(); var _animateCallback = function animateCallback() { var elapsed = Date.now() - startTime; var progress = elapsed / animationDuration; if (progress >= 1) { tapFeedback.destroy(); return; } // Move text upward and fade out tapFeedback.y = startY - progress * 100; tapFeedback.alpha = 1 - progress; LK.setTimeout(_animateCallback, 16); // ~60fps }; _animateCallback(); // Hide instruction text after first tap if (LK.getScore() === 1) { instructionTxt.alpha = 0; } }; // Add Shop button var shopBtn = new Text2('Shop', { size: 80, fill: 0xFFFFFF }); shopBtn.anchor.set(1, 0); LK.gui.topRight.addChild(shopBtn); shopBtn.x = -20; // Small padding from right edge shopBtn.y = 20; // Small padding from top // Shop interface state var isShopOpen = false; var shopOverlay = null; // Handle shop button tap shopBtn.down = function (x, y, obj) { if (!isShopOpen) { // Open shop - create black overlay using Container shopOverlay = new Container(); // Create black background shape for overlay var shopBackground = LK.getAsset('shopBg', { width: 2048, height: 2732, color: 0x000000, shape: 'box' }); shopOverlay.addChild(shopBackground); shopOverlay.x = 0; shopOverlay.y = 0; // NORMAL EGGS SECTION // Normal eggs data var normalEggs = [{ asset: 'egg', price: '1000 Score', color: 0xFFFFFF }, { asset: 'greenEgg', price: '15000 Score', color: 0x00ff00 }, { asset: 'redEgg', price: '50000 Score', color: 0xff0000 }, { asset: 'purpleEgg', price: '1250000 Score', color: 0x800080 }, { asset: 'whiteEgg', price: '10M', color: 0xffffff }, { asset: 'spaceEgg', price: '100M', color: 0x4169e1 }, { asset: 'space2Egg', price: '200M', color: 0x8a2be2 }, { asset: 'galaxyEgg', price: '500M', color: 0x800080 }]; // Golden eggs data var goldenEggs = [{ asset: 'goldenEgg', price: '10000 Score', color: 0xFFD700 }, { asset: 'goldenGreenEgg', price: '30000 Score', color: 0x90ee90 }, { asset: 'goldenRedEgg', price: '100000 Score', color: 0xff6600 }, { asset: 'goldenPurpleEgg', price: '2500000 Score', color: 0xdaa520 }, { asset: 'goldenWhiteEgg', price: '20M', color: 0xffd700 }, { asset: 'goldenSpaceEgg', price: '200M', color: 0xffd700 }, { asset: 'goldenSpace2Egg', price: '400M', color: 0xffd700 }, { asset: 'goldenGalaxyEgg', price: '1B', color: 0xffd700 }]; // Display normal eggs section var normalEggItems = []; var startY = 600; var eggSpacing = 300; var rowSpacing = 300; var maxEggsPerRow = 5; for (var i = 0; i < normalEggs.length; i++) { var row = Math.floor(i / maxEggsPerRow); var col = i % maxEggsPerRow; var startX = (2048 - (Math.min(normalEggs.length - row * maxEggsPerRow, maxEggsPerRow) - 1) * eggSpacing) / 2; var eggX = startX + col * eggSpacing; var eggY = startY + row * rowSpacing; var eggItem = LK.getAsset(normalEggs[i].asset, { anchorX: 0.5, anchorY: 0.5 }); eggItem.x = eggX; eggItem.y = eggY; shopOverlay.addChild(eggItem); normalEggItems.push(eggItem); var eggPriceText = new Text2(normalEggs[i].price, { size: 50, fill: normalEggs[i].color }); eggPriceText.anchor.set(0.5, 0); eggPriceText.x = eggX; eggPriceText.y = eggY + 120; shopOverlay.addChild(eggPriceText); } // Display golden eggs section var goldenEggItems = []; var goldenStartY = startY + Math.ceil(normalEggs.length / maxEggsPerRow) * rowSpacing + 300; for (var i = 0; i < goldenEggs.length; i++) { var row = Math.floor(i / maxEggsPerRow); var col = i % maxEggsPerRow; var startX = (2048 - (Math.min(goldenEggs.length - row * maxEggsPerRow, maxEggsPerRow) - 1) * eggSpacing) / 2; var eggX = startX + col * eggSpacing; var eggY = goldenStartY + row * rowSpacing; var goldenEggItem = LK.getAsset(goldenEggs[i].asset, { anchorX: 0.5, anchorY: 0.5 }); goldenEggItem.x = eggX; goldenEggItem.y = eggY; shopOverlay.addChild(goldenEggItem); goldenEggItems.push(goldenEggItem); var goldenEggPriceText = new Text2(goldenEggs[i].price, { size: 50, fill: goldenEggs[i].color }); goldenEggPriceText.anchor.set(0.5, 0); goldenEggPriceText.x = eggX; goldenEggPriceText.y = eggY + 120; shopOverlay.addChild(goldenEggPriceText); } // Add Lucky Boost button var luckyBoostBtnY = goldenStartY + Math.ceil(goldenEggs.length / maxEggsPerRow) * rowSpacing + 100; var luckyBoostBtn = new Text2('Lucky Boost', { size: 80, fill: 0xFFD700 }); luckyBoostBtn.anchor.set(0.5, 0); luckyBoostBtn.x = 2048 / 3; luckyBoostBtn.y = luckyBoostBtnY; shopOverlay.addChild(luckyBoostBtn); // Add inventory button var inventoryBtnY = goldenStartY + Math.ceil(goldenEggs.length / maxEggsPerRow) * rowSpacing + 100; var inventoryBtn = new Text2('Inventory', { size: 80, fill: 0xFFFFFF }); inventoryBtn.anchor.set(0.5, 0); inventoryBtn.x = 2048 * 2 / 3; inventoryBtn.y = inventoryBtnY; shopOverlay.addChild(inventoryBtn); // Store references for purchase handlers var eggItem = normalEggItems[0]; var greenEggItem = normalEggItems[1]; var redEggItem = normalEggItems[2]; var purpleEggItem = normalEggItems[3]; var whiteEggItem = normalEggItems[4]; var goldenEggItem = goldenEggItems[0]; var goldenGreenEggItem = goldenEggItems[1]; var goldenRedEggItem = goldenEggItems[2]; var goldenPurpleEggItem = goldenEggItems[3]; var goldenWhiteEggItem = goldenEggItems[4]; var spaceEggItem = normalEggItems[5]; var space2EggItem = normalEggItems[6]; var goldenSpaceEggItem = goldenEggItems[5]; var goldenSpace2EggItem = goldenEggItems[6]; var galaxyEggItem = normalEggItems[7]; var goldenGalaxyEggItem = goldenEggItems[7]; // Handle egg purchase eggItem.down = function () { if (LK.getScore() >= 1000) { LK.setScore(LK.getScore() - 1000); scoreTxt.setText(LK.getScore().toString()); // Close shop shopOverlay.destroy(); shopOverlay = null; isShopOpen = false; // Create falling egg fallingEgg = LK.getAsset('egg', { anchorX: 0.5, anchorY: 0.5 }); fallingEgg.x = 2048 / 2; fallingEgg.y = -200; eggClickCount = 0; game.addChild(fallingEgg); // Animate egg falling tween(fallingEgg, { y: 2732 / 2 }, { duration: 1000 }); // Handle egg clicking fallingEgg.down = function () { eggClickCount++; if (eggClickCount === 1) { // First crack var crackedEgg1 = LK.getAsset('crackedEgg1', { anchorX: 0.5, anchorY: 0.5 }); crackedEgg1.x = fallingEgg.x; crackedEgg1.y = fallingEgg.y; game.addChild(crackedEgg1); fallingEgg.destroy(); fallingEgg = crackedEgg1; fallingEgg.down = arguments.callee; } else if (eggClickCount === 2) { // Second crack var crackedEgg2 = LK.getAsset('crackedEgg2', { anchorX: 0.5, anchorY: 0.5 }); crackedEgg2.x = fallingEgg.x; crackedEgg2.y = fallingEgg.y; game.addChild(crackedEgg2); fallingEgg.destroy(); fallingEgg = crackedEgg2; fallingEgg.down = arguments.callee; } else if (eggClickCount === 3) { // Third crack - almost fully cracked var crackedEgg3 = LK.getAsset('crackedEgg3', { anchorX: 0.5, anchorY: 0.5 }); crackedEgg3.x = fallingEgg.x; crackedEgg3.y = fallingEgg.y; game.addChild(crackedEgg3); fallingEgg.destroy(); fallingEgg = crackedEgg3; fallingEgg.down = arguments.callee; } else if (eggClickCount === 4) { // Hatch the egg // Get list of animals that have less than 3 in inventory var availableAnimals = []; var animalTypes = ['dog', 'cat', 'snake']; for (var typeIndex = 0; typeIndex < animalTypes.length; typeIndex++) { var animalType = animalTypes[typeIndex]; var countInInventory = 0; for (var invIndex = 0; invIndex < inventory.length; invIndex++) { if (inventory[invIndex] === animalType) { countInInventory++; } } if (countInInventory < 3) { availableAnimals.push(animalType); } } var animal; if (availableAnimals.length > 0) { // Choose randomly from available animals var randomIndex = Math.floor(Math.random() * availableAnimals.length); animal = availableAnimals[randomIndex]; // Add to inventory inventory.push(animal); storage.inventory = inventory; } else { // All animal types have 3 in inventory, show message and don't give new pet animal = null; var allPetsText = new Text2('All pets maxed out!', { size: 60, fill: 0xff0000 }); allPetsText.anchor.set(0.5, 0.5); allPetsText.x = 2048 / 2; allPetsText.y = 1500; game.addChild(allPetsText); LK.setTimeout(function () { allPetsText.destroy(); }, 2000); } // Only show hatched animal if we got a new pet if (animal) { var animalSprite = LK.getAsset(animal, { anchorX: 0.5, anchorY: 0.5 }); animalSprite.x = fallingEgg.x; animalSprite.y = fallingEgg.y; game.addChild(animalSprite); // Remove animal after showing LK.setTimeout(function () { animalSprite.destroy(); }, 2000); } // Remove egg fallingEgg.destroy(); fallingEgg = null; } }; } }; // Handle green egg purchase greenEggItem.down = function () { if (LK.getScore() >= 15000) { LK.setScore(LK.getScore() - 15000); scoreTxt.setText(LK.getScore().toString()); // Close shop shopOverlay.destroy(); shopOverlay = null; isShopOpen = false; // Create falling green egg fallingEgg = LK.getAsset('greenEgg', { anchorX: 0.5, anchorY: 0.5 }); fallingEgg.x = 2048 / 2; fallingEgg.y = -200; eggClickCount = 0; game.addChild(fallingEgg); // Animate egg falling tween(fallingEgg, { y: 2732 / 2 }, { duration: 1000 }); // Handle green egg clicking fallingEgg.down = function () { eggClickCount++; if (eggClickCount === 1) { // First crack var crackedEgg1 = LK.getAsset('crackedEgg1', { anchorX: 0.5, anchorY: 0.5 }); crackedEgg1.x = fallingEgg.x; crackedEgg1.y = fallingEgg.y; game.addChild(crackedEgg1); fallingEgg.destroy(); fallingEgg = crackedEgg1; fallingEgg.down = arguments.callee; } else if (eggClickCount === 2) { // Second crack var crackedEgg2 = LK.getAsset('crackedEgg2', { anchorX: 0.5, anchorY: 0.5 }); crackedEgg2.x = fallingEgg.x; crackedEgg2.y = fallingEgg.y; game.addChild(crackedEgg2); fallingEgg.destroy(); fallingEgg = crackedEgg2; fallingEgg.down = arguments.callee; } else if (eggClickCount === 3) { // Third crack - almost fully cracked var crackedEgg3 = LK.getAsset('crackedEgg3', { anchorX: 0.5, anchorY: 0.5 }); crackedEgg3.x = fallingEgg.x; crackedEgg3.y = fallingEgg.y; game.addChild(crackedEgg3); fallingEgg.destroy(); fallingEgg = crackedEgg3; fallingEgg.down = arguments.callee; } else if (eggClickCount === 4) { // Hatch the green egg with special probabilities var availableGreenAnimals = []; var greenAnimalTypes = ['dinosaur', 'bear', 'bee']; for (var typeIndex = 0; typeIndex < greenAnimalTypes.length; typeIndex++) { var animalType = greenAnimalTypes[typeIndex]; var countInInventory = 0; for (var invIndex = 0; invIndex < inventory.length; invIndex++) { if (inventory[invIndex] === animalType) { countInInventory++; } } if (countInInventory < 3) { availableGreenAnimals.push(animalType); } } var animal; if (availableGreenAnimals.length > 0) { // Special probability distribution for green eggs with Lucky Boost effect var random = Math.random(); var selectedAnimal; var dinosaurChance = 0.05; var bearChance = 0.2; var beeChance = 1.0; // Apply Lucky Boost effect if (luckyBoostActive && Date.now() < luckyBoostEndTime) { // Increase chance for lowest probability pets (dinosaur, bear) by 10x // Decrease chance for highest probability pet (bee) by 10x dinosaurChance *= 10; // 50% chance bearChance = bearChance + (bearChance - 0.05) * 10; // Increase bear chance proportionally beeChance = 0.08; // Reduced from 80% to 8% } if (random < dinosaurChance) { selectedAnimal = 'dinosaur'; } else if (random < bearChance) { selectedAnimal = 'bear'; } else { selectedAnimal = 'bee'; } // Check if selected animal is available if (availableGreenAnimals.indexOf(selectedAnimal) !== -1) { animal = selectedAnimal; } else { // If selected animal is not available, choose randomly from available var randomIndex = Math.floor(Math.random() * availableGreenAnimals.length); animal = availableGreenAnimals[randomIndex]; } inventory.push(animal); storage.inventory = inventory; } else { // All green animal types have 3 in inventory animal = null; var allGreenPetsText = new Text2('All green pets maxed out!', { size: 60, fill: 0xff0000 }); allGreenPetsText.anchor.set(0.5, 0.5); allGreenPetsText.x = 2048 / 2; allGreenPetsText.y = 1500; game.addChild(allGreenPetsText); LK.setTimeout(function () { allGreenPetsText.destroy(); }, 2000); } // Only show hatched animal if we got a new pet if (animal) { var animalSprite = LK.getAsset(animal, { anchorX: 0.5, anchorY: 0.5 }); animalSprite.x = fallingEgg.x; animalSprite.y = fallingEgg.y; game.addChild(animalSprite); // Remove animal after showing LK.setTimeout(function () { animalSprite.destroy(); }, 2000); } // Remove egg fallingEgg.destroy(); fallingEgg = null; } }; } }; // Handle golden green egg purchase goldenGreenEggItem.down = function () { if (LK.getScore() >= 30000) { LK.setScore(LK.getScore() - 30000); scoreTxt.setText(LK.getScore().toString()); // Close shop shopOverlay.destroy(); shopOverlay = null; isShopOpen = false; // Create falling golden green egg fallingEgg = LK.getAsset('goldenGreenEgg', { anchorX: 0.5, anchorY: 0.5 }); fallingEgg.x = 2048 / 2; fallingEgg.y = -200; eggClickCount = 0; game.addChild(fallingEgg); // Animate egg falling tween(fallingEgg, { y: 2732 / 2 }, { duration: 1000 }); // Handle golden green egg clicking fallingEgg.down = function () { eggClickCount++; if (eggClickCount === 1) { // First crack var crackedEgg1 = LK.getAsset('crackedEgg1', { anchorX: 0.5, anchorY: 0.5 }); crackedEgg1.x = fallingEgg.x; crackedEgg1.y = fallingEgg.y; game.addChild(crackedEgg1); fallingEgg.destroy(); fallingEgg = crackedEgg1; fallingEgg.down = arguments.callee; } else if (eggClickCount === 2) { // Second crack var crackedEgg2 = LK.getAsset('crackedEgg2', { anchorX: 0.5, anchorY: 0.5 }); crackedEgg2.x = fallingEgg.x; crackedEgg2.y = fallingEgg.y; game.addChild(crackedEgg2); fallingEgg.destroy(); fallingEgg = crackedEgg2; fallingEgg.down = arguments.callee; } else if (eggClickCount === 3) { // Third crack - almost fully cracked var crackedEgg3 = LK.getAsset('crackedEgg3', { anchorX: 0.5, anchorY: 0.5 }); crackedEgg3.x = fallingEgg.x; crackedEgg3.y = fallingEgg.y; game.addChild(crackedEgg3); fallingEgg.destroy(); fallingEgg = crackedEgg3; fallingEgg.down = arguments.callee; } else if (eggClickCount === 4) { // Hatch the golden green egg with special probabilities var availableGoldenGreenAnimals = []; var goldenGreenAnimalTypes = ['goldenDinosaur', 'goldenBear', 'goldenBee']; for (var typeIndex = 0; typeIndex < goldenGreenAnimalTypes.length; typeIndex++) { var animalType = goldenGreenAnimalTypes[typeIndex]; var countInInventory = 0; for (var invIndex = 0; invIndex < inventory.length; invIndex++) { if (inventory[invIndex] === animalType) { countInInventory++; } } if (countInInventory < 3) { availableGoldenGreenAnimals.push(animalType); } } var animal; if (availableGoldenGreenAnimals.length > 0) { // Special probability distribution for golden green eggs (same as green) var random = Math.random(); var selectedAnimal; if (random < 0.05) { selectedAnimal = 'goldenDinosaur'; // 5% chance } else if (random < 0.2) { selectedAnimal = 'goldenBear'; // 15% chance } else { selectedAnimal = 'goldenBee'; // 80% chance } // Check if selected animal is available if (availableGoldenGreenAnimals.indexOf(selectedAnimal) !== -1) { animal = selectedAnimal; } else { // If selected animal is not available, choose randomly from available var randomIndex = Math.floor(Math.random() * availableGoldenGreenAnimals.length); animal = availableGoldenGreenAnimals[randomIndex]; } inventory.push(animal); storage.inventory = inventory; } else { // All golden green animal types have 3 in inventory animal = null; var allGoldenGreenPetsText = new Text2('All golden green pets maxed out!', { size: 60, fill: 0xff0000 }); allGoldenGreenPetsText.anchor.set(0.5, 0.5); allGoldenGreenPetsText.x = 2048 / 2; allGoldenGreenPetsText.y = 1500; game.addChild(allGoldenGreenPetsText); LK.setTimeout(function () { allGoldenGreenPetsText.destroy(); }, 2000); } // Only show hatched animal if we got a new pet if (animal) { var animalSprite = LK.getAsset(animal, { anchorX: 0.5, anchorY: 0.5 }); animalSprite.x = fallingEgg.x; animalSprite.y = fallingEgg.y; game.addChild(animalSprite); // Remove animal after showing LK.setTimeout(function () { animalSprite.destroy(); }, 2000); } // Remove egg fallingEgg.destroy(); fallingEgg = null; } }; } }; // Handle red egg purchase redEggItem.down = function () { if (LK.getScore() >= 50000) { LK.setScore(LK.getScore() - 50000); scoreTxt.setText(LK.getScore().toString()); // Close shop shopOverlay.destroy(); shopOverlay = null; isShopOpen = false; // Create falling red egg fallingEgg = LK.getAsset('redEgg', { anchorX: 0.5, anchorY: 0.5 }); fallingEgg.x = 2048 / 2; fallingEgg.y = -200; eggClickCount = 0; game.addChild(fallingEgg); // Animate egg falling tween(fallingEgg, { y: 2732 / 2 }, { duration: 1000 }); // Handle red egg clicking fallingEgg.down = function () { eggClickCount++; if (eggClickCount === 1) { // First crack var crackedEgg1 = LK.getAsset('crackedEgg1', { anchorX: 0.5, anchorY: 0.5 }); crackedEgg1.x = fallingEgg.x; crackedEgg1.y = fallingEgg.y; game.addChild(crackedEgg1); fallingEgg.destroy(); fallingEgg = crackedEgg1; fallingEgg.down = arguments.callee; } else if (eggClickCount === 2) { // Second crack var crackedEgg2 = LK.getAsset('crackedEgg2', { anchorX: 0.5, anchorY: 0.5 }); crackedEgg2.x = fallingEgg.x; crackedEgg2.y = fallingEgg.y; game.addChild(crackedEgg2); fallingEgg.destroy(); fallingEgg = crackedEgg2; fallingEgg.down = arguments.callee; } else if (eggClickCount === 3) { // Third crack - almost fully cracked var crackedEgg3 = LK.getAsset('crackedEgg3', { anchorX: 0.5, anchorY: 0.5 }); crackedEgg3.x = fallingEgg.x; crackedEgg3.y = fallingEgg.y; game.addChild(crackedEgg3); fallingEgg.destroy(); fallingEgg = crackedEgg3; fallingEgg.down = arguments.callee; } else if (eggClickCount === 4) { // Hatch the red egg with special probabilities var availableRedAnimals = []; var redAnimalTypes = ['trex', 'velector', 'titanaBull']; for (var typeIndex = 0; typeIndex < redAnimalTypes.length; typeIndex++) { var animalType = redAnimalTypes[typeIndex]; var countInInventory = 0; for (var invIndex = 0; invIndex < inventory.length; invIndex++) { if (inventory[invIndex] === animalType) { countInInventory++; } } if (countInInventory < 3) { availableRedAnimals.push(animalType); } } var animal; if (availableRedAnimals.length > 0) { // Special probability distribution for red eggs var random = Math.random(); var selectedAnimal; if (random < 0.05) { selectedAnimal = 'trex'; // 5% chance } else if (random < 0.3) { selectedAnimal = 'velector'; // 25% chance } else { selectedAnimal = 'titanaBull'; // 70% chance } // Check if selected animal is available if (availableRedAnimals.indexOf(selectedAnimal) !== -1) { animal = selectedAnimal; } else { // If selected animal is not available, choose randomly from available var randomIndex = Math.floor(Math.random() * availableRedAnimals.length); animal = availableRedAnimals[randomIndex]; } inventory.push(animal); storage.inventory = inventory; } else { // All red animal types have 3 in inventory animal = null; var allRedPetsText = new Text2('All red pets maxed out!', { size: 60, fill: 0xff0000 }); allRedPetsText.anchor.set(0.5, 0.5); allRedPetsText.x = 2048 / 2; allRedPetsText.y = 1500; game.addChild(allRedPetsText); LK.setTimeout(function () { allRedPetsText.destroy(); }, 2000); } // Only show hatched animal if we got a new pet if (animal) { var animalSprite = LK.getAsset(animal, { anchorX: 0.5, anchorY: 0.5 }); animalSprite.x = fallingEgg.x; animalSprite.y = fallingEgg.y; game.addChild(animalSprite); // Remove animal after showing LK.setTimeout(function () { animalSprite.destroy(); }, 2000); } // Remove egg fallingEgg.destroy(); fallingEgg = null; } }; } }; // Handle golden red egg purchase goldenRedEggItem.down = function () { if (LK.getScore() >= 100000) { LK.setScore(LK.getScore() - 100000); scoreTxt.setText(LK.getScore().toString()); // Close shop shopOverlay.destroy(); shopOverlay = null; isShopOpen = false; // Create falling golden red egg fallingEgg = LK.getAsset('goldenRedEgg', { anchorX: 0.5, anchorY: 0.5 }); fallingEgg.x = 2048 / 2; fallingEgg.y = -200; eggClickCount = 0; game.addChild(fallingEgg); // Animate egg falling tween(fallingEgg, { y: 2732 / 2 }, { duration: 1000 }); // Handle golden red egg clicking fallingEgg.down = function () { eggClickCount++; if (eggClickCount === 1) { // First crack var crackedEgg1 = LK.getAsset('crackedEgg1', { anchorX: 0.5, anchorY: 0.5 }); crackedEgg1.x = fallingEgg.x; crackedEgg1.y = fallingEgg.y; game.addChild(crackedEgg1); fallingEgg.destroy(); fallingEgg = crackedEgg1; fallingEgg.down = arguments.callee; } else if (eggClickCount === 2) { // Second crack var crackedEgg2 = LK.getAsset('crackedEgg2', { anchorX: 0.5, anchorY: 0.5 }); crackedEgg2.x = fallingEgg.x; crackedEgg2.y = fallingEgg.y; game.addChild(crackedEgg2); fallingEgg.destroy(); fallingEgg = crackedEgg2; fallingEgg.down = arguments.callee; } else if (eggClickCount === 3) { // Third crack - almost fully cracked var crackedEgg3 = LK.getAsset('crackedEgg3', { anchorX: 0.5, anchorY: 0.5 }); crackedEgg3.x = fallingEgg.x; crackedEgg3.y = fallingEgg.y; game.addChild(crackedEgg3); fallingEgg.destroy(); fallingEgg = crackedEgg3; fallingEgg.down = arguments.callee; } else if (eggClickCount === 4) { // Hatch the golden red egg with special probabilities var availableGoldenRedAnimals = []; var goldenRedAnimalTypes = ['goldenTrex', 'goldenVelector', 'goldenTitanaBull']; for (var typeIndex = 0; typeIndex < goldenRedAnimalTypes.length; typeIndex++) { var animalType = goldenRedAnimalTypes[typeIndex]; var countInInventory = 0; for (var invIndex = 0; invIndex < inventory.length; invIndex++) { if (inventory[invIndex] === animalType) { countInInventory++; } } if (countInInventory < 3) { availableGoldenRedAnimals.push(animalType); } } var animal; if (availableGoldenRedAnimals.length > 0) { // Special probability distribution for golden red eggs (same as red) var random = Math.random(); var selectedAnimal; if (random < 0.05) { selectedAnimal = 'goldenTrex'; // 5% chance } else if (random < 0.3) { selectedAnimal = 'goldenVelector'; // 25% chance } else { selectedAnimal = 'goldenTitanaBull'; // 70% chance } // Check if selected animal is available if (availableGoldenRedAnimals.indexOf(selectedAnimal) !== -1) { animal = selectedAnimal; } else { // If selected animal is not available, choose randomly from available var randomIndex = Math.floor(Math.random() * availableGoldenRedAnimals.length); animal = availableGoldenRedAnimals[randomIndex]; } inventory.push(animal); storage.inventory = inventory; } else { // All golden red animal types have 3 in inventory animal = null; var allGoldenRedPetsText = new Text2('All golden red pets maxed out!', { size: 60, fill: 0xff0000 }); allGoldenRedPetsText.anchor.set(0.5, 0.5); allGoldenRedPetsText.x = 2048 / 2; allGoldenRedPetsText.y = 1500; game.addChild(allGoldenRedPetsText); LK.setTimeout(function () { allGoldenRedPetsText.destroy(); }, 2000); } // Only show hatched animal if we got a new pet if (animal) { var animalSprite = LK.getAsset(animal, { anchorX: 0.5, anchorY: 0.5 }); animalSprite.x = fallingEgg.x; animalSprite.y = fallingEgg.y; game.addChild(animalSprite); // Remove animal after showing LK.setTimeout(function () { animalSprite.destroy(); }, 2000); } // Remove egg fallingEgg.destroy(); fallingEgg = null; } }; } }; // Handle purple egg purchase purpleEggItem.down = function () { if (LK.getScore() >= 1250000) { LK.setScore(LK.getScore() - 1250000); scoreTxt.setText(LK.getScore().toString()); // Close shop shopOverlay.destroy(); shopOverlay = null; isShopOpen = false; // Create falling purple egg fallingEgg = LK.getAsset('purpleEgg', { anchorX: 0.5, anchorY: 0.5 }); fallingEgg.x = 2048 / 2; fallingEgg.y = -200; eggClickCount = 0; game.addChild(fallingEgg); // Animate egg falling tween(fallingEgg, { y: 2732 / 2 }, { duration: 1000 }); // Handle purple egg clicking fallingEgg.down = function () { eggClickCount++; if (eggClickCount === 1) { // First crack var crackedEgg1 = LK.getAsset('crackedEgg1', { anchorX: 0.5, anchorY: 0.5 }); crackedEgg1.x = fallingEgg.x; crackedEgg1.y = fallingEgg.y; game.addChild(crackedEgg1); fallingEgg.destroy(); fallingEgg = crackedEgg1; fallingEgg.down = arguments.callee; } else if (eggClickCount === 2) { // Second crack var crackedEgg2 = LK.getAsset('crackedEgg2', { anchorX: 0.5, anchorY: 0.5 }); crackedEgg2.x = fallingEgg.x; crackedEgg2.y = fallingEgg.y; game.addChild(crackedEgg2); fallingEgg.destroy(); fallingEgg = crackedEgg2; fallingEgg.down = arguments.callee; } else if (eggClickCount === 3) { // Third crack - almost fully cracked var crackedEgg3 = LK.getAsset('crackedEgg3', { anchorX: 0.5, anchorY: 0.5 }); crackedEgg3.x = fallingEgg.x; crackedEgg3.y = fallingEgg.y; game.addChild(crackedEgg3); fallingEgg.destroy(); fallingEgg = crackedEgg3; fallingEgg.down = arguments.callee; } else if (eggClickCount === 4) { // Hatch the purple egg with special probabilities var availablePurpleAnimals = []; var purpleAnimalTypes = ['ironMan', 'captainAmerica', 'spiderman']; for (var typeIndex = 0; typeIndex < purpleAnimalTypes.length; typeIndex++) { var animalType = purpleAnimalTypes[typeIndex]; var countInInventory = 0; for (var invIndex = 0; invIndex < inventory.length; invIndex++) { if (inventory[invIndex] === animalType) { countInInventory++; } } if (countInInventory < 3) { availablePurpleAnimals.push(animalType); } } var animal; if (availablePurpleAnimals.length > 0) { // Special probability distribution for purple eggs var random = Math.random(); var selectedAnimal; if (random < 0.01) { selectedAnimal = 'ironMan'; // 1% chance } else if (random < 0.15) { selectedAnimal = 'captainAmerica'; // 14% chance } else { selectedAnimal = 'spiderman'; // 85% chance } // Check if selected animal is available if (availablePurpleAnimals.indexOf(selectedAnimal) !== -1) { animal = selectedAnimal; } else { // If selected animal is not available, choose randomly from available var randomIndex = Math.floor(Math.random() * availablePurpleAnimals.length); animal = availablePurpleAnimals[randomIndex]; } inventory.push(animal); storage.inventory = inventory; } else { // All purple animal types have 3 in inventory animal = null; var allPurplePetsText = new Text2('All purple pets maxed out!', { size: 60, fill: 0xff0000 }); allPurplePetsText.anchor.set(0.5, 0.5); allPurplePetsText.x = 2048 / 2; allPurplePetsText.y = 1500; game.addChild(allPurplePetsText); LK.setTimeout(function () { allPurplePetsText.destroy(); }, 2000); } // Only show hatched animal if we got a new pet if (animal) { var animalSprite = LK.getAsset(animal, { anchorX: 0.5, anchorY: 0.5 }); animalSprite.x = fallingEgg.x; animalSprite.y = fallingEgg.y; game.addChild(animalSprite); // Remove animal after showing LK.setTimeout(function () { animalSprite.destroy(); }, 2000); } // Remove egg fallingEgg.destroy(); fallingEgg = null; } }; } }; // Handle golden purple egg purchase goldenPurpleEggItem.down = function () { if (LK.getScore() >= 2500000) { LK.setScore(LK.getScore() - 2500000); scoreTxt.setText(LK.getScore().toString()); // Close shop shopOverlay.destroy(); shopOverlay = null; isShopOpen = false; // Create falling golden purple egg fallingEgg = LK.getAsset('goldenPurpleEgg', { anchorX: 0.5, anchorY: 0.5 }); fallingEgg.x = 2048 / 2; fallingEgg.y = -200; eggClickCount = 0; game.addChild(fallingEgg); // Animate egg falling tween(fallingEgg, { y: 2732 / 2 }, { duration: 1000 }); // Handle golden purple egg clicking fallingEgg.down = function () { eggClickCount++; if (eggClickCount === 1) { // First crack var crackedEgg1 = LK.getAsset('crackedEgg1', { anchorX: 0.5, anchorY: 0.5 }); crackedEgg1.x = fallingEgg.x; crackedEgg1.y = fallingEgg.y; game.addChild(crackedEgg1); fallingEgg.destroy(); fallingEgg = crackedEgg1; fallingEgg.down = arguments.callee; } else if (eggClickCount === 2) { // Second crack var crackedEgg2 = LK.getAsset('crackedEgg2', { anchorX: 0.5, anchorY: 0.5 }); crackedEgg2.x = fallingEgg.x; crackedEgg2.y = fallingEgg.y; game.addChild(crackedEgg2); fallingEgg.destroy(); fallingEgg = crackedEgg2; fallingEgg.down = arguments.callee; } else if (eggClickCount === 3) { // Third crack - almost fully cracked var crackedEgg3 = LK.getAsset('crackedEgg3', { anchorX: 0.5, anchorY: 0.5 }); crackedEgg3.x = fallingEgg.x; crackedEgg3.y = fallingEgg.y; game.addChild(crackedEgg3); fallingEgg.destroy(); fallingEgg = crackedEgg3; fallingEgg.down = arguments.callee; } else if (eggClickCount === 4) { // Hatch the golden purple egg with special probabilities var availableGoldenPurpleAnimals = []; var goldenPurpleAnimalTypes = ['goldenIronMan', 'goldenCaptainAmerica', 'goldenSpiderman']; for (var typeIndex = 0; typeIndex < goldenPurpleAnimalTypes.length; typeIndex++) { var animalType = goldenPurpleAnimalTypes[typeIndex]; var countInInventory = 0; for (var invIndex = 0; invIndex < inventory.length; invIndex++) { if (inventory[invIndex] === animalType) { countInInventory++; } } if (countInInventory < 3) { availableGoldenPurpleAnimals.push(animalType); } } var animal; if (availableGoldenPurpleAnimals.length > 0) { // Special probability distribution for golden purple eggs (same as purple) var random = Math.random(); var selectedAnimal; if (random < 0.01) { selectedAnimal = 'goldenIronMan'; // 1% chance } else if (random < 0.15) { selectedAnimal = 'goldenCaptainAmerica'; // 14% chance } else { selectedAnimal = 'goldenSpiderman'; // 85% chance } // Check if selected animal is available if (availableGoldenPurpleAnimals.indexOf(selectedAnimal) !== -1) { animal = selectedAnimal; } else { // If selected animal is not available, choose randomly from available var randomIndex = Math.floor(Math.random() * availableGoldenPurpleAnimals.length); animal = availableGoldenPurpleAnimals[randomIndex]; } inventory.push(animal); storage.inventory = inventory; } else { // All golden purple animal types have 3 in inventory animal = null; var allGoldenPurplePetsText = new Text2('All golden purple pets maxed out!', { size: 60, fill: 0xff0000 }); allGoldenPurplePetsText.anchor.set(0.5, 0.5); allGoldenPurplePetsText.x = 2048 / 2; allGoldenPurplePetsText.y = 1500; game.addChild(allGoldenPurplePetsText); LK.setTimeout(function () { allGoldenPurplePetsText.destroy(); }, 2000); } // Only show hatched animal if we got a new pet if (animal) { var animalSprite = LK.getAsset(animal, { anchorX: 0.5, anchorY: 0.5 }); animalSprite.x = fallingEgg.x; animalSprite.y = fallingEgg.y; game.addChild(animalSprite); // Remove animal after showing LK.setTimeout(function () { animalSprite.destroy(); }, 2000); } // Remove egg fallingEgg.destroy(); fallingEgg = null; } }; } }; // Handle white egg purchase whiteEggItem.down = function () { if (LK.getScore() >= 10000000) { LK.setScore(LK.getScore() - 10000000); scoreTxt.setText(LK.getScore().toString()); // Close shop shopOverlay.destroy(); shopOverlay = null; isShopOpen = false; // Create falling white egg fallingEgg = LK.getAsset('whiteEgg', { anchorX: 0.5, anchorY: 0.5 }); fallingEgg.x = 2048 / 2; fallingEgg.y = -200; eggClickCount = 0; game.addChild(fallingEgg); // Animate egg falling tween(fallingEgg, { y: 2732 / 2 }, { duration: 1000 }); // Handle white egg clicking fallingEgg.down = function () { eggClickCount++; if (eggClickCount === 1) { // First crack var crackedEgg1 = LK.getAsset('crackedEgg1', { anchorX: 0.5, anchorY: 0.5 }); crackedEgg1.x = fallingEgg.x; crackedEgg1.y = fallingEgg.y; game.addChild(crackedEgg1); fallingEgg.destroy(); fallingEgg = crackedEgg1; fallingEgg.down = arguments.callee; } else if (eggClickCount === 2) { // Second crack var crackedEgg2 = LK.getAsset('crackedEgg2', { anchorX: 0.5, anchorY: 0.5 }); crackedEgg2.x = fallingEgg.x; crackedEgg2.y = fallingEgg.y; game.addChild(crackedEgg2); fallingEgg.destroy(); fallingEgg = crackedEgg2; fallingEgg.down = arguments.callee; } else if (eggClickCount === 3) { // Third crack - almost fully cracked var crackedEgg3 = LK.getAsset('crackedEgg3', { anchorX: 0.5, anchorY: 0.5 }); crackedEgg3.x = fallingEgg.x; crackedEgg3.y = fallingEgg.y; game.addChild(crackedEgg3); fallingEgg.destroy(); fallingEgg = crackedEgg3; fallingEgg.down = arguments.callee; } else if (eggClickCount === 4) { // Hatch the white egg with special probabilities var availableWhiteAnimals = []; var whiteAnimalTypes = ['king', 'knight', 'human']; for (var typeIndex = 0; typeIndex < whiteAnimalTypes.length; typeIndex++) { var animalType = whiteAnimalTypes[typeIndex]; var countInInventory = 0; for (var invIndex = 0; invIndex < inventory.length; invIndex++) { if (inventory[invIndex] === animalType) { countInInventory++; } } if (countInInventory < 3) { availableWhiteAnimals.push(animalType); } } var animal; if (availableWhiteAnimals.length > 0) { // Special probability distribution for white eggs var random = Math.random(); var selectedAnimal; if (random < 0.005) { selectedAnimal = 'king'; // 0.5% chance } else if (random < 0.055) { selectedAnimal = 'knight'; // 5% chance } else { selectedAnimal = 'human'; // 94.5% chance } // Check if selected animal is available if (availableWhiteAnimals.indexOf(selectedAnimal) !== -1) { animal = selectedAnimal; } else { // If selected animal is not available, choose randomly from available var randomIndex = Math.floor(Math.random() * availableWhiteAnimals.length); animal = availableWhiteAnimals[randomIndex]; } inventory.push(animal); storage.inventory = inventory; } else { // All white animal types have 3 in inventory animal = null; var allWhitePetsText = new Text2('All white pets maxed out!', { size: 60, fill: 0xff0000 }); allWhitePetsText.anchor.set(0.5, 0.5); allWhitePetsText.x = 2048 / 2; allWhitePetsText.y = 1500; game.addChild(allWhitePetsText); LK.setTimeout(function () { allWhitePetsText.destroy(); }, 2000); } // Only show hatched animal if we got a new pet if (animal) { var animalSprite = LK.getAsset(animal, { anchorX: 0.5, anchorY: 0.5 }); animalSprite.x = fallingEgg.x; animalSprite.y = fallingEgg.y; game.addChild(animalSprite); // Remove animal after showing LK.setTimeout(function () { animalSprite.destroy(); }, 2000); } // Remove egg fallingEgg.destroy(); fallingEgg = null; } }; } }; // Handle golden white egg purchase goldenWhiteEggItem.down = function () { if (LK.getScore() >= 20000000) { LK.setScore(LK.getScore() - 20000000); scoreTxt.setText(LK.getScore().toString()); // Close shop shopOverlay.destroy(); shopOverlay = null; isShopOpen = false; // Create falling golden white egg fallingEgg = LK.getAsset('goldenWhiteEgg', { anchorX: 0.5, anchorY: 0.5 }); fallingEgg.x = 2048 / 2; fallingEgg.y = -200; eggClickCount = 0; game.addChild(fallingEgg); // Animate egg falling tween(fallingEgg, { y: 2732 / 2 }, { duration: 1000 }); // Handle golden white egg clicking fallingEgg.down = function () { eggClickCount++; if (eggClickCount === 1) { // First crack var crackedEgg1 = LK.getAsset('crackedEgg1', { anchorX: 0.5, anchorY: 0.5 }); crackedEgg1.x = fallingEgg.x; crackedEgg1.y = fallingEgg.y; game.addChild(crackedEgg1); fallingEgg.destroy(); fallingEgg = crackedEgg1; fallingEgg.down = arguments.callee; } else if (eggClickCount === 2) { // Second crack var crackedEgg2 = LK.getAsset('crackedEgg2', { anchorX: 0.5, anchorY: 0.5 }); crackedEgg2.x = fallingEgg.x; crackedEgg2.y = fallingEgg.y; game.addChild(crackedEgg2); fallingEgg.destroy(); fallingEgg = crackedEgg2; fallingEgg.down = arguments.callee; } else if (eggClickCount === 3) { // Third crack - almost fully cracked var crackedEgg3 = LK.getAsset('crackedEgg3', { anchorX: 0.5, anchorY: 0.5 }); crackedEgg3.x = fallingEgg.x; crackedEgg3.y = fallingEgg.y; game.addChild(crackedEgg3); fallingEgg.destroy(); fallingEgg = crackedEgg3; fallingEgg.down = arguments.callee; } else if (eggClickCount === 4) { // Hatch the golden white egg with special probabilities var availableGoldenWhiteAnimals = []; var goldenWhiteAnimalTypes = ['goldenKing', 'goldenKnight', 'goldenHuman']; for (var typeIndex = 0; typeIndex < goldenWhiteAnimalTypes.length; typeIndex++) { var animalType = goldenWhiteAnimalTypes[typeIndex]; var countInInventory = 0; for (var invIndex = 0; invIndex < inventory.length; invIndex++) { if (inventory[invIndex] === animalType) { countInInventory++; } } if (countInInventory < 3) { availableGoldenWhiteAnimals.push(animalType); } } var animal; if (availableGoldenWhiteAnimals.length > 0) { // Special probability distribution for golden white eggs (same as white) var random = Math.random(); var selectedAnimal; if (random < 0.005) { selectedAnimal = 'goldenKing'; // 0.5% chance } else if (random < 0.055) { selectedAnimal = 'goldenKnight'; // 5% chance } else { selectedAnimal = 'goldenHuman'; // 94.5% chance } // Check if selected animal is available if (availableGoldenWhiteAnimals.indexOf(selectedAnimal) !== -1) { animal = selectedAnimal; } else { // If selected animal is not available, choose randomly from available var randomIndex = Math.floor(Math.random() * availableGoldenWhiteAnimals.length); animal = availableGoldenWhiteAnimals[randomIndex]; } inventory.push(animal); storage.inventory = inventory; } else { // All golden white animal types have 3 in inventory animal = null; var allGoldenWhitePetsText = new Text2('All golden white pets maxed out!', { size: 60, fill: 0xff0000 }); allGoldenWhitePetsText.anchor.set(0.5, 0.5); allGoldenWhitePetsText.x = 2048 / 2; allGoldenWhitePetsText.y = 1500; game.addChild(allGoldenWhitePetsText); LK.setTimeout(function () { allGoldenWhitePetsText.destroy(); }, 2000); } // Only show hatched animal if we got a new pet if (animal) { var animalSprite = LK.getAsset(animal, { anchorX: 0.5, anchorY: 0.5 }); animalSprite.x = fallingEgg.x; animalSprite.y = fallingEgg.y; game.addChild(animalSprite); // Remove animal after showing LK.setTimeout(function () { animalSprite.destroy(); }, 2000); } // Remove egg fallingEgg.destroy(); fallingEgg = null; } }; } }; // Handle golden egg purchase goldenEggItem.down = function () { if (LK.getScore() >= 10000) { LK.setScore(LK.getScore() - 10000); scoreTxt.setText(LK.getScore().toString()); // Close shop shopOverlay.destroy(); shopOverlay = null; isShopOpen = false; // Create falling golden egg fallingEgg = LK.getAsset('goldenEgg', { anchorX: 0.5, anchorY: 0.5 }); fallingEgg.x = 2048 / 2; fallingEgg.y = -200; eggClickCount = 0; game.addChild(fallingEgg); // Animate egg falling tween(fallingEgg, { y: 2732 / 2 }, { duration: 1000 }); // Handle golden egg clicking fallingEgg.down = function () { eggClickCount++; if (eggClickCount === 1) { // First crack var crackedEgg1 = LK.getAsset('crackedEgg1', { anchorX: 0.5, anchorY: 0.5 }); crackedEgg1.x = fallingEgg.x; crackedEgg1.y = fallingEgg.y; game.addChild(crackedEgg1); fallingEgg.destroy(); fallingEgg = crackedEgg1; fallingEgg.down = arguments.callee; } else if (eggClickCount === 2) { // Second crack var crackedEgg2 = LK.getAsset('crackedEgg2', { anchorX: 0.5, anchorY: 0.5 }); crackedEgg2.x = fallingEgg.x; crackedEgg2.y = fallingEgg.y; game.addChild(crackedEgg2); fallingEgg.destroy(); fallingEgg = crackedEgg2; fallingEgg.down = arguments.callee; } else if (eggClickCount === 3) { // Third crack - almost fully cracked var crackedEgg3 = LK.getAsset('crackedEgg3', { anchorX: 0.5, anchorY: 0.5 }); crackedEgg3.x = fallingEgg.x; crackedEgg3.y = fallingEgg.y; game.addChild(crackedEgg3); fallingEgg.destroy(); fallingEgg = crackedEgg3; fallingEgg.down = arguments.callee; } else if (eggClickCount === 4) { // Hatch the golden egg with special probabilities var availableGoldenAnimals = []; var goldenAnimalTypes = ['goldenDog', 'goldenCat', 'goldenSnake']; for (var typeIndex = 0; typeIndex < goldenAnimalTypes.length; typeIndex++) { var animalType = goldenAnimalTypes[typeIndex]; var countInInventory = 0; for (var invIndex = 0; invIndex < inventory.length; invIndex++) { if (inventory[invIndex] === animalType) { countInInventory++; } } if (countInInventory < 3) { availableGoldenAnimals.push(animalType); } } var animal; if (availableGoldenAnimals.length > 0) { // Special probability distribution for golden eggs var random = Math.random(); var selectedAnimal; if (random < 0.6) { selectedAnimal = 'goldenDog'; // 60% chance } else if (random < 0.9) { selectedAnimal = 'goldenCat'; // 30% chance } else { selectedAnimal = 'goldenSnake'; // 10% chance } // Check if selected animal is available if (availableGoldenAnimals.indexOf(selectedAnimal) !== -1) { animal = selectedAnimal; } else { // If selected animal is not available, choose randomly from available var randomIndex = Math.floor(Math.random() * availableGoldenAnimals.length); animal = availableGoldenAnimals[randomIndex]; } inventory.push(animal); storage.inventory = inventory; } else { // All golden animal types have 3 in inventory animal = null; var allGoldenPetsText = new Text2('All golden pets maxed out!', { size: 60, fill: 0xff0000 }); allGoldenPetsText.anchor.set(0.5, 0.5); allGoldenPetsText.x = 2048 / 2; allGoldenPetsText.y = 1500; game.addChild(allGoldenPetsText); LK.setTimeout(function () { allGoldenPetsText.destroy(); }, 2000); } // Only show hatched animal if we got a new pet if (animal) { var animalSprite = LK.getAsset(animal, { anchorX: 0.5, anchorY: 0.5 }); animalSprite.x = fallingEgg.x; animalSprite.y = fallingEgg.y; game.addChild(animalSprite); // Remove animal after showing LK.setTimeout(function () { animalSprite.destroy(); }, 2000); } // Remove egg fallingEgg.destroy(); fallingEgg = null; } }; } }; // Handle space egg purchase spaceEggItem.down = function () { if (LK.getScore() >= 100000000) { LK.setScore(LK.getScore() - 100000000); scoreTxt.setText(LK.getScore().toString()); // Close shop shopOverlay.destroy(); shopOverlay = null; isShopOpen = false; // Create falling space egg fallingEgg = LK.getAsset('spaceEgg', { anchorX: 0.5, anchorY: 0.5 }); fallingEgg.x = 2048 / 2; fallingEgg.y = -200; eggClickCount = 0; game.addChild(fallingEgg); // Animate egg falling tween(fallingEgg, { y: 2732 / 2 }, { duration: 1000 }); // Handle space egg clicking fallingEgg.down = function () { eggClickCount++; if (eggClickCount === 1) { // First crack var crackedEgg1 = LK.getAsset('crackedEgg1', { anchorX: 0.5, anchorY: 0.5 }); crackedEgg1.x = fallingEgg.x; crackedEgg1.y = fallingEgg.y; game.addChild(crackedEgg1); fallingEgg.destroy(); fallingEgg = crackedEgg1; fallingEgg.down = arguments.callee; } else if (eggClickCount === 2) { // Second crack var crackedEgg2 = LK.getAsset('crackedEgg2', { anchorX: 0.5, anchorY: 0.5 }); crackedEgg2.x = fallingEgg.x; crackedEgg2.y = fallingEgg.y; game.addChild(crackedEgg2); fallingEgg.destroy(); fallingEgg = crackedEgg2; fallingEgg.down = arguments.callee; } else if (eggClickCount === 3) { // Third crack - almost fully cracked var crackedEgg3 = LK.getAsset('crackedEgg3', { anchorX: 0.5, anchorY: 0.5 }); crackedEgg3.x = fallingEgg.x; crackedEgg3.y = fallingEgg.y; game.addChild(crackedEgg3); fallingEgg.destroy(); fallingEgg = crackedEgg3; fallingEgg.down = arguments.callee; } else if (eggClickCount === 4) { // Hatch the space egg with special probabilities var availableSpaceAnimals = []; var spaceAnimalTypes = ['earth', 'moon', 'meteor']; for (var typeIndex = 0; typeIndex < spaceAnimalTypes.length; typeIndex++) { var animalType = spaceAnimalTypes[typeIndex]; var countInInventory = 0; for (var invIndex = 0; invIndex < inventory.length; invIndex++) { if (inventory[invIndex] === animalType) { countInInventory++; } } if (countInInventory < 3) { availableSpaceAnimals.push(animalType); } } var animal; if (availableSpaceAnimals.length > 0) { // Special probability distribution for space eggs var random = Math.random(); var selectedAnimal; if (random < 0.001) { selectedAnimal = 'earth'; // 0.1% chance } else if (random < 0.011) { selectedAnimal = 'moon'; // 1% chance } else { selectedAnimal = 'meteor'; // 98.9% chance } // Check if selected animal is available if (availableSpaceAnimals.indexOf(selectedAnimal) !== -1) { animal = selectedAnimal; } else { // If selected animal is not available, choose randomly from available var randomIndex = Math.floor(Math.random() * availableSpaceAnimals.length); animal = availableSpaceAnimals[randomIndex]; } inventory.push(animal); storage.inventory = inventory; } else { // All space animal types have 3 in inventory animal = null; var allSpacePetsText = new Text2('All space pets maxed out!', { size: 60, fill: 0xff0000 }); allSpacePetsText.anchor.set(0.5, 0.5); allSpacePetsText.x = 2048 / 2; allSpacePetsText.y = 1500; game.addChild(allSpacePetsText); LK.setTimeout(function () { allSpacePetsText.destroy(); }, 2000); } // Only show hatched animal if we got a new pet if (animal) { var animalSprite = LK.getAsset(animal, { anchorX: 0.5, anchorY: 0.5 }); animalSprite.x = fallingEgg.x; animalSprite.y = fallingEgg.y; game.addChild(animalSprite); // Remove animal after showing LK.setTimeout(function () { animalSprite.destroy(); }, 2000); } // Remove egg fallingEgg.destroy(); fallingEgg = null; } }; } }; // Handle space2 egg purchase space2EggItem.down = function () { if (LK.getScore() >= 200000000) { LK.setScore(LK.getScore() - 200000000); scoreTxt.setText(LK.getScore().toString()); // Close shop shopOverlay.destroy(); shopOverlay = null; isShopOpen = false; // Create falling space2 egg fallingEgg = LK.getAsset('space2Egg', { anchorX: 0.5, anchorY: 0.5 }); fallingEgg.x = 2048 / 2; fallingEgg.y = -200; eggClickCount = 0; game.addChild(fallingEgg); // Animate egg falling tween(fallingEgg, { y: 2732 / 2 }, { duration: 1000 }); // Handle space2 egg clicking fallingEgg.down = function () { eggClickCount++; if (eggClickCount === 1) { // First crack var crackedEgg1 = LK.getAsset('crackedEgg1', { anchorX: 0.5, anchorY: 0.5 }); crackedEgg1.x = fallingEgg.x; crackedEgg1.y = fallingEgg.y; game.addChild(crackedEgg1); fallingEgg.destroy(); fallingEgg = crackedEgg1; fallingEgg.down = arguments.callee; } else if (eggClickCount === 2) { // Second crack var crackedEgg2 = LK.getAsset('crackedEgg2', { anchorX: 0.5, anchorY: 0.5 }); crackedEgg2.x = fallingEgg.x; crackedEgg2.y = fallingEgg.y; game.addChild(crackedEgg2); fallingEgg.destroy(); fallingEgg = crackedEgg2; fallingEgg.down = arguments.callee; } else if (eggClickCount === 3) { // Third crack - almost fully cracked var crackedEgg3 = LK.getAsset('crackedEgg3', { anchorX: 0.5, anchorY: 0.5 }); crackedEgg3.x = fallingEgg.x; crackedEgg3.y = fallingEgg.y; game.addChild(crackedEgg3); fallingEgg.destroy(); fallingEgg = crackedEgg3; fallingEgg.down = arguments.callee; } else if (eggClickCount === 4) { // Hatch the space2 egg with special probabilities var availableSpace2Animals = []; var space2AnimalTypes = ['sun', 'jupiter', 'neptune']; for (var typeIndex = 0; typeIndex < space2AnimalTypes.length; typeIndex++) { var animalType = space2AnimalTypes[typeIndex]; var countInInventory = 0; for (var invIndex = 0; invIndex < inventory.length; invIndex++) { if (inventory[invIndex] === animalType) { countInInventory++; } } if (countInInventory < 3) { availableSpace2Animals.push(animalType); } } var animal; if (availableSpace2Animals.length > 0) { // Special probability distribution for space2 eggs var random = Math.random(); var selectedAnimal; if (random < 0.0001) { selectedAnimal = 'sun'; // 0.01% chance } else if (random < 0.0011) { selectedAnimal = 'jupiter'; // 0.1% chance } else { selectedAnimal = 'neptune'; // 99.9% chance } // Check if selected animal is available if (availableSpace2Animals.indexOf(selectedAnimal) !== -1) { animal = selectedAnimal; } else { // If selected animal is not available, choose randomly from available var randomIndex = Math.floor(Math.random() * availableSpace2Animals.length); animal = availableSpace2Animals[randomIndex]; } inventory.push(animal); storage.inventory = inventory; } else { // All space2 animal types have 3 in inventory animal = null; var allSpace2PetsText = new Text2('All space2 pets maxed out!', { size: 60, fill: 0xff0000 }); allSpace2PetsText.anchor.set(0.5, 0.5); allSpace2PetsText.x = 2048 / 2; allSpace2PetsText.y = 1500; game.addChild(allSpace2PetsText); LK.setTimeout(function () { allSpace2PetsText.destroy(); }, 2000); } // Only show hatched animal if we got a new pet if (animal) { var animalSprite = LK.getAsset(animal, { anchorX: 0.5, anchorY: 0.5 }); animalSprite.x = fallingEgg.x; animalSprite.y = fallingEgg.y; game.addChild(animalSprite); // Remove animal after showing LK.setTimeout(function () { animalSprite.destroy(); }, 2000); } // Remove egg fallingEgg.destroy(); fallingEgg = null; } }; } }; // Handle golden space egg purchase goldenSpaceEggItem.down = function () { if (LK.getScore() >= 200000000) { LK.setScore(LK.getScore() - 200000000); scoreTxt.setText(LK.getScore().toString()); // Close shop shopOverlay.destroy(); shopOverlay = null; isShopOpen = false; // Create falling golden space egg fallingEgg = LK.getAsset('goldenSpaceEgg', { anchorX: 0.5, anchorY: 0.5 }); fallingEgg.x = 2048 / 2; fallingEgg.y = -200; eggClickCount = 0; game.addChild(fallingEgg); // Animate egg falling tween(fallingEgg, { y: 2732 / 2 }, { duration: 1000 }); // Handle golden space egg clicking fallingEgg.down = function () { eggClickCount++; if (eggClickCount === 1) { // First crack var crackedEgg1 = LK.getAsset('crackedEgg1', { anchorX: 0.5, anchorY: 0.5 }); crackedEgg1.x = fallingEgg.x; crackedEgg1.y = fallingEgg.y; game.addChild(crackedEgg1); fallingEgg.destroy(); fallingEgg = crackedEgg1; fallingEgg.down = arguments.callee; } else if (eggClickCount === 2) { // Second crack var crackedEgg2 = LK.getAsset('crackedEgg2', { anchorX: 0.5, anchorY: 0.5 }); crackedEgg2.x = fallingEgg.x; crackedEgg2.y = fallingEgg.y; game.addChild(crackedEgg2); fallingEgg.destroy(); fallingEgg = crackedEgg2; fallingEgg.down = arguments.callee; } else if (eggClickCount === 3) { // Third crack - almost fully cracked var crackedEgg3 = LK.getAsset('crackedEgg3', { anchorX: 0.5, anchorY: 0.5 }); crackedEgg3.x = fallingEgg.x; crackedEgg3.y = fallingEgg.y; game.addChild(crackedEgg3); fallingEgg.destroy(); fallingEgg = crackedEgg3; fallingEgg.down = arguments.callee; } else if (eggClickCount === 4) { // Hatch the golden space egg with special probabilities var availableGoldenSpaceAnimals = []; var goldenSpaceAnimalTypes = ['goldenEarth', 'goldenMoon', 'goldenMeteor']; for (var typeIndex = 0; typeIndex < goldenSpaceAnimalTypes.length; typeIndex++) { var animalType = goldenSpaceAnimalTypes[typeIndex]; var countInInventory = 0; for (var invIndex = 0; invIndex < inventory.length; invIndex++) { if (inventory[invIndex] === animalType) { countInInventory++; } } if (countInInventory < 3) { availableGoldenSpaceAnimals.push(animalType); } } var animal; if (availableGoldenSpaceAnimals.length > 0) { // Special probability distribution for golden space eggs (same as space) var random = Math.random(); var selectedAnimal; if (random < 0.001) { selectedAnimal = 'goldenEarth'; // 0.1% chance } else if (random < 0.011) { selectedAnimal = 'goldenMoon'; // 1% chance } else { selectedAnimal = 'goldenMeteor'; // 98.9% chance } // Check if selected animal is available if (availableGoldenSpaceAnimals.indexOf(selectedAnimal) !== -1) { animal = selectedAnimal; } else { // If selected animal is not available, choose randomly from available var randomIndex = Math.floor(Math.random() * availableGoldenSpaceAnimals.length); animal = availableGoldenSpaceAnimals[randomIndex]; } inventory.push(animal); storage.inventory = inventory; } else { // All golden space animal types have 3 in inventory animal = null; var allGoldenSpacePetsText = new Text2('All golden space pets maxed out!', { size: 60, fill: 0xff0000 }); allGoldenSpacePetsText.anchor.set(0.5, 0.5); allGoldenSpacePetsText.x = 2048 / 2; allGoldenSpacePetsText.y = 1500; game.addChild(allGoldenSpacePetsText); LK.setTimeout(function () { allGoldenSpacePetsText.destroy(); }, 2000); } // Only show hatched animal if we got a new pet if (animal) { var animalSprite = LK.getAsset(animal, { anchorX: 0.5, anchorY: 0.5 }); animalSprite.x = fallingEgg.x; animalSprite.y = fallingEgg.y; game.addChild(animalSprite); // Remove animal after showing LK.setTimeout(function () { animalSprite.destroy(); }, 2000); } // Remove egg fallingEgg.destroy(); fallingEgg = null; } }; } }; // Handle golden space2 egg purchase goldenSpace2EggItem.down = function () { if (LK.getScore() >= 400000000) { LK.setScore(LK.getScore() - 400000000); scoreTxt.setText(LK.getScore().toString()); // Close shop shopOverlay.destroy(); shopOverlay = null; isShopOpen = false; // Create falling golden space2 egg fallingEgg = LK.getAsset('goldenSpace2Egg', { anchorX: 0.5, anchorY: 0.5 }); fallingEgg.x = 2048 / 2; fallingEgg.y = -200; eggClickCount = 0; game.addChild(fallingEgg); // Animate egg falling tween(fallingEgg, { y: 2732 / 2 }, { duration: 1000 }); // Handle golden space2 egg clicking fallingEgg.down = function () { eggClickCount++; if (eggClickCount === 1) { // First crack var crackedEgg1 = LK.getAsset('crackedEgg1', { anchorX: 0.5, anchorY: 0.5 }); crackedEgg1.x = fallingEgg.x; crackedEgg1.y = fallingEgg.y; game.addChild(crackedEgg1); fallingEgg.destroy(); fallingEgg = crackedEgg1; fallingEgg.down = arguments.callee; } else if (eggClickCount === 2) { // Second crack var crackedEgg2 = LK.getAsset('crackedEgg2', { anchorX: 0.5, anchorY: 0.5 }); crackedEgg2.x = fallingEgg.x; crackedEgg2.y = fallingEgg.y; game.addChild(crackedEgg2); fallingEgg.destroy(); fallingEgg = crackedEgg2; fallingEgg.down = arguments.callee; } else if (eggClickCount === 3) { // Third crack - almost fully cracked var crackedEgg3 = LK.getAsset('crackedEgg3', { anchorX: 0.5, anchorY: 0.5 }); crackedEgg3.x = fallingEgg.x; crackedEgg3.y = fallingEgg.y; game.addChild(crackedEgg3); fallingEgg.destroy(); fallingEgg = crackedEgg3; fallingEgg.down = arguments.callee; } else if (eggClickCount === 4) { // Hatch the golden space2 egg with special probabilities var availableGoldenSpace2Animals = []; var goldenSpace2AnimalTypes = ['goldenSun', 'goldenJupiter', 'goldenNeptune']; for (var typeIndex = 0; typeIndex < goldenSpace2AnimalTypes.length; typeIndex++) { var animalType = goldenSpace2AnimalTypes[typeIndex]; var countInInventory = 0; for (var invIndex = 0; invIndex < inventory.length; invIndex++) { if (inventory[invIndex] === animalType) { countInInventory++; } } if (countInInventory < 3) { availableGoldenSpace2Animals.push(animalType); } } var animal; if (availableGoldenSpace2Animals.length > 0) { // Special probability distribution for golden space2 eggs (same as space2) var random = Math.random(); var selectedAnimal; if (random < 0.0001) { selectedAnimal = 'goldenSun'; // 0.01% chance } else if (random < 0.0011) { selectedAnimal = 'goldenJupiter'; // 0.1% chance } else { selectedAnimal = 'goldenNeptune'; // 99.9% chance } // Check if selected animal is available if (availableGoldenSpace2Animals.indexOf(selectedAnimal) !== -1) { animal = selectedAnimal; } else { // If selected animal is not available, choose randomly from available var randomIndex = Math.floor(Math.random() * availableGoldenSpace2Animals.length); animal = availableGoldenSpace2Animals[randomIndex]; } inventory.push(animal); storage.inventory = inventory; } else { // All golden space2 animal types have 3 in inventory animal = null; var allGoldenSpace2PetsText = new Text2('All golden space2 pets maxed out!', { size: 60, fill: 0xff0000 }); allGoldenSpace2PetsText.anchor.set(0.5, 0.5); allGoldenSpace2PetsText.x = 2048 / 2; allGoldenSpace2PetsText.y = 1500; game.addChild(allGoldenSpace2PetsText); LK.setTimeout(function () { allGoldenSpace2PetsText.destroy(); }, 2000); } // Only show hatched animal if we got a new pet if (animal) { var animalSprite = LK.getAsset(animal, { anchorX: 0.5, anchorY: 0.5 }); animalSprite.x = fallingEgg.x; animalSprite.y = fallingEgg.y; game.addChild(animalSprite); // Remove animal after showing LK.setTimeout(function () { animalSprite.destroy(); }, 2000); } // Remove egg fallingEgg.destroy(); fallingEgg = null; } }; } }; // Handle galaxy egg purchase galaxyEggItem.down = function () { if (LK.getScore() >= 500000000) { LK.setScore(LK.getScore() - 500000000); scoreTxt.setText(LK.getScore().toString()); // Close shop shopOverlay.destroy(); shopOverlay = null; isShopOpen = false; // Create falling galaxy egg fallingEgg = LK.getAsset('galaxyEgg', { anchorX: 0.5, anchorY: 0.5 }); fallingEgg.x = 2048 / 2; fallingEgg.y = -200; eggClickCount = 0; game.addChild(fallingEgg); // Animate egg falling tween(fallingEgg, { y: 2732 / 2 }, { duration: 1000 }); // Handle galaxy egg clicking fallingEgg.down = function () { eggClickCount++; if (eggClickCount === 1) { // First crack var crackedEgg1 = LK.getAsset('crackedEgg1', { anchorX: 0.5, anchorY: 0.5 }); crackedEgg1.x = fallingEgg.x; crackedEgg1.y = fallingEgg.y; game.addChild(crackedEgg1); fallingEgg.destroy(); fallingEgg = crackedEgg1; fallingEgg.down = arguments.callee; } else if (eggClickCount === 2) { // Second crack var crackedEgg2 = LK.getAsset('crackedEgg2', { anchorX: 0.5, anchorY: 0.5 }); crackedEgg2.x = fallingEgg.x; crackedEgg2.y = fallingEgg.y; game.addChild(crackedEgg2); fallingEgg.destroy(); fallingEgg = crackedEgg2; fallingEgg.down = arguments.callee; } else if (eggClickCount === 3) { // Third crack - almost fully cracked var crackedEgg3 = LK.getAsset('crackedEgg3', { anchorX: 0.5, anchorY: 0.5 }); crackedEgg3.x = fallingEgg.x; crackedEgg3.y = fallingEgg.y; game.addChild(crackedEgg3); fallingEgg.destroy(); fallingEgg = crackedEgg3; fallingEgg.down = arguments.callee; } else if (eggClickCount === 4) { // Hatch the galaxy egg with special probabilities var availableGalaxyAnimals = []; var galaxyAnimalTypes = ['andromedaGalaxy', 'normalGalaxy', 'milkyWayGalaxy']; for (var typeIndex = 0; typeIndex < galaxyAnimalTypes.length; typeIndex++) { var animalType = galaxyAnimalTypes[typeIndex]; var countInInventory = 0; for (var invIndex = 0; invIndex < inventory.length; invIndex++) { if (inventory[invIndex] === animalType) { countInInventory++; } } if (countInInventory < 3) { availableGalaxyAnimals.push(animalType); } } var animal; if (availableGalaxyAnimals.length > 0) { // Special probability distribution for galaxy eggs var random = Math.random(); var selectedAnimal; if (random < 0.009) { selectedAnimal = 'milkyWayGalaxy'; // 0.9% chance } else if (random < 0.199) { selectedAnimal = 'normalGalaxy'; // 19% chance } else { selectedAnimal = 'andromedaGalaxy'; // 80.1% chance } // Check if selected animal is available if (availableGalaxyAnimals.indexOf(selectedAnimal) !== -1) { animal = selectedAnimal; } else { // If selected animal is not available, choose randomly from available var randomIndex = Math.floor(Math.random() * availableGalaxyAnimals.length); animal = availableGalaxyAnimals[randomIndex]; } inventory.push(animal); storage.inventory = inventory; } else { // All galaxy animal types have 3 in inventory animal = null; var allGalaxyPetsText = new Text2('All galaxy pets maxed out!', { size: 60, fill: 0xff0000 }); allGalaxyPetsText.anchor.set(0.5, 0.5); allGalaxyPetsText.x = 2048 / 2; allGalaxyPetsText.y = 1500; game.addChild(allGalaxyPetsText); LK.setTimeout(function () { allGalaxyPetsText.destroy(); }, 2000); } // Only show hatched animal if we got a new pet if (animal) { var animalSprite = LK.getAsset(animal, { anchorX: 0.5, anchorY: 0.5 }); animalSprite.x = fallingEgg.x; animalSprite.y = fallingEgg.y; game.addChild(animalSprite); // Remove animal after showing LK.setTimeout(function () { animalSprite.destroy(); }, 2000); } // Remove egg fallingEgg.destroy(); fallingEgg = null; } }; } }; // Handle golden galaxy egg purchase goldenGalaxyEggItem.down = function () { if (LK.getScore() >= 1000000000) { LK.setScore(LK.getScore() - 1000000000); scoreTxt.setText(LK.getScore().toString()); // Close shop shopOverlay.destroy(); shopOverlay = null; isShopOpen = false; // Create falling golden galaxy egg fallingEgg = LK.getAsset('goldenGalaxyEgg', { anchorX: 0.5, anchorY: 0.5 }); fallingEgg.x = 2048 / 2; fallingEgg.y = -200; eggClickCount = 0; game.addChild(fallingEgg); // Animate egg falling tween(fallingEgg, { y: 2732 / 2 }, { duration: 1000 }); // Handle golden galaxy egg clicking fallingEgg.down = function () { eggClickCount++; if (eggClickCount === 1) { // First crack var crackedEgg1 = LK.getAsset('crackedEgg1', { anchorX: 0.5, anchorY: 0.5 }); crackedEgg1.x = fallingEgg.x; crackedEgg1.y = fallingEgg.y; game.addChild(crackedEgg1); fallingEgg.destroy(); fallingEgg = crackedEgg1; fallingEgg.down = arguments.callee; } else if (eggClickCount === 2) { // Second crack var crackedEgg2 = LK.getAsset('crackedEgg2', { anchorX: 0.5, anchorY: 0.5 }); crackedEgg2.x = fallingEgg.x; crackedEgg2.y = fallingEgg.y; game.addChild(crackedEgg2); fallingEgg.destroy(); fallingEgg = crackedEgg2; fallingEgg.down = arguments.callee; } else if (eggClickCount === 3) { // Third crack - almost fully cracked var crackedEgg3 = LK.getAsset('crackedEgg3', { anchorX: 0.5, anchorY: 0.5 }); crackedEgg3.x = fallingEgg.x; crackedEgg3.y = fallingEgg.y; game.addChild(crackedEgg3); fallingEgg.destroy(); fallingEgg = crackedEgg3; fallingEgg.down = arguments.callee; } else if (eggClickCount === 4) { // Hatch the golden galaxy egg with special probabilities var availableGoldenGalaxyAnimals = []; var goldenGalaxyAnimalTypes = ['goldenAndromedaGalaxy', 'goldenNormalGalaxy', 'goldenMilkyWayGalaxy']; for (var typeIndex = 0; typeIndex < goldenGalaxyAnimalTypes.length; typeIndex++) { var animalType = goldenGalaxyAnimalTypes[typeIndex]; var countInInventory = 0; for (var invIndex = 0; invIndex < inventory.length; invIndex++) { if (inventory[invIndex] === animalType) { countInInventory++; } } if (countInInventory < 3) { availableGoldenGalaxyAnimals.push(animalType); } } var animal; if (availableGoldenGalaxyAnimals.length > 0) { // Special probability distribution for golden galaxy eggs (same as galaxy) var random = Math.random(); var selectedAnimal; if (random < 0.009) { selectedAnimal = 'goldenMilkyWayGalaxy'; // 0.9% chance } else if (random < 0.199) { selectedAnimal = 'goldenNormalGalaxy'; // 19% chance } else { selectedAnimal = 'goldenAndromedaGalaxy'; // 80.1% chance } // Check if selected animal is available if (availableGoldenGalaxyAnimals.indexOf(selectedAnimal) !== -1) { animal = selectedAnimal; } else { // If selected animal is not available, choose randomly from available var randomIndex = Math.floor(Math.random() * availableGoldenGalaxyAnimals.length); animal = availableGoldenGalaxyAnimals[randomIndex]; } inventory.push(animal); storage.inventory = inventory; } else { // All golden galaxy animal types have 3 in inventory animal = null; var allGoldenGalaxyPetsText = new Text2('All golden galaxy pets maxed out!', { size: 60, fill: 0xff0000 }); allGoldenGalaxyPetsText.anchor.set(0.5, 0.5); allGoldenGalaxyPetsText.x = 2048 / 2; allGoldenGalaxyPetsText.y = 1500; game.addChild(allGoldenGalaxyPetsText); LK.setTimeout(function () { allGoldenGalaxyPetsText.destroy(); }, 2000); } // Only show hatched animal if we got a new pet if (animal) { var animalSprite = LK.getAsset(animal, { anchorX: 0.5, anchorY: 0.5 }); animalSprite.x = fallingEgg.x; animalSprite.y = fallingEgg.y; game.addChild(animalSprite); // Remove animal after showing LK.setTimeout(function () { animalSprite.destroy(); }, 2000); } // Remove egg fallingEgg.destroy(); fallingEgg = null; } }; } }; // Handle inventory button inventoryBtn.down = function () { if (!isInventoryOpen) { // Close shop first if (shopOverlay) { shopOverlay.destroy(); } shopOverlay = null; isShopOpen = false; // Open inventory isInventoryOpen = true; inventoryOverlay = new Container(); var invBackground = LK.getAsset('shopBg', { width: 2048, height: 2732, color: 0x000000, shape: 'box' }); inventoryOverlay.addChild(invBackground); game.addChild(inventoryOverlay); // Display inventory items by unique pet types var yPos = 300; var uniqueTypes = []; var animalTypes = ['dog', 'cat', 'snake', 'goldenDog', 'goldenCat', 'goldenSnake', 'dinosaur', 'bear', 'bee', 'goldenDinosaur', 'goldenBear', 'goldenBee', 'trex', 'velector', 'titanaBull', 'goldenTrex', 'goldenVelector', 'goldenTitanaBull', 'ironMan', 'captainAmerica', 'spiderman', 'goldenIronMan', 'goldenCaptainAmerica', 'goldenSpiderman', 'king', 'knight', 'human', 'goldenKing', 'goldenKnight', 'goldenHuman', 'earth', 'moon', 'meteor', 'sun', 'jupiter', 'neptune', 'goldenEarth', 'goldenMoon', 'goldenMeteor', 'goldenSun', 'goldenJupiter', 'goldenNeptune', 'andromedaGalaxy', 'normalGalaxy', 'milkyWayGalaxy', 'goldenAndromedaGalaxy', 'goldenNormalGalaxy', 'goldenMilkyWayGalaxy']; for (var typeIndex = 0; typeIndex < animalTypes.length; typeIndex++) { var animalType = animalTypes[typeIndex]; var countInInventory = 0; for (var invIndex = 0; invIndex < inventory.length; invIndex++) { if (inventory[invIndex] === animalType) { countInInventory++; } } if (countInInventory > 0) { uniqueTypes.push({ type: animalType, count: countInInventory }); } } for (var i = 0; i < uniqueTypes.length; i++) { var petData = uniqueTypes[i]; var animalItem = LK.getAsset(petData.type, { anchorX: 0.5, anchorY: 0.5 }); animalItem.x = 300; animalItem.y = yPos; animalItem.animalType = petData.type; animalItem.inventoryIndex = i; inventoryOverlay.addChild(animalItem); // Handle pet deletion when in delete mode animalItem.down = function () { if (deleteMode && selectedDeleteAnimalType === this.animalType) { // Delete the pet // Remove one instance of this pet from inventory for (var removeIndex = 0; removeIndex < inventory.length; removeIndex++) { if (inventory[removeIndex] === this.animalType) { inventory.splice(removeIndex, 1); break; } } storage.inventory = inventory; // Also remove from equipped animals if it was equipped for (var removeIndex = equippedAnimals.length - 1; removeIndex >= 0; removeIndex--) { if (equippedAnimals[removeIndex] === this.animalType) { equippedAnimals.splice(removeIndex, 1); break; } } // Recalculate pet bonus after removing var petBonus = 0; // Count each animal type var dogCount = 0; var catCount = 0; var snakeCount = 0; for (var j = 0; j < equippedAnimals.length; j++) { if (equippedAnimals[j] === 'dog') { dogCount++; } else if (equippedAnimals[j] === 'cat') { catCount++; } else if (equippedAnimals[j] === 'snake') { snakeCount++; } } // Each dog gives +1 bonus per tap petBonus += dogCount; // Cats: 1 cat = +2, 2 cats = +4, 3 cats = +6 (total bonus) if (catCount === 1) { petBonus += 2; } else if (catCount === 2) { petBonus += 4; } else if (catCount === 3) { petBonus += 6; } // Snakes: 1 snake = +5, 2 snakes = +10, 3 snakes = +15 (total bonus) if (snakeCount === 1) { petBonus += 5; } else if (snakeCount === 2) { petBonus += 10; } else if (snakeCount === 3) { petBonus += 15; } // Store as multiplier format (base 1 + bonus) currentMultiplier = 1 + petBonus; storage.equippedAnimals = equippedAnimals; storage.currentMultiplier = currentMultiplier; // Exit delete mode deleteMode = false; selectedDeleteAnimalType = null; // Close and reopen inventory to refresh display inventoryOverlay.destroy(); inventoryOverlay = null; isInventoryOpen = false; // Reopen inventory to show updated counts inventoryBtn.down(); } }; // Count how many of this type are equipped var equippedCount = 0; for (var k = 0; k < equippedAnimals.length; k++) { if (equippedAnimals[k] === petData.type) { equippedCount++; } } // Add equip button var equipBtn = new Text2('Equip', { size: 50, fill: 0xFFFFFF }); equipBtn.anchor.set(0.5, 0.5); equipBtn.x = 550; equipBtn.y = yPos; equipBtn.animalType = inventory[i]; equipBtn.inventoryIndex = i; inventoryOverlay.addChild(equipBtn); // Add unequip button var unequipBtn = new Text2('Unequip', { size: 50, fill: 0xFF6B6B }); unequipBtn.anchor.set(0.5, 0.5); unequipBtn.x = 700; unequipBtn.y = yPos; unequipBtn.animalType = inventory[i]; unequipBtn.inventoryIndex = i; inventoryOverlay.addChild(unequipBtn); // Add delete button var deleteBtn = new Text2('Delete', { size: 50, fill: 0xFF0000 }); deleteBtn.anchor.set(0.5, 0.5); deleteBtn.x = 850; deleteBtn.y = yPos; deleteBtn.animalType = inventory[i]; deleteBtn.inventoryIndex = i; inventoryOverlay.addChild(deleteBtn); // Add count display var countText = new Text2('Owned: ' + petData.count + ' | Equipped: ' + equippedCount, { size: 40, fill: 0xFFFFFF }); countText.anchor.set(0.5, 0.5); countText.x = 1000; countText.y = yPos; inventoryOverlay.addChild(countText); // Handle delete functionality deleteBtn.down = function () { if (!deleteMode) { // First press - enter delete mode deleteMode = true; selectedDeleteAnimalType = this.animalType; // Show message to click on pet var deleteInstructionText = new Text2('Click on the pet to delete it', { size: 40, fill: 0xff0000 }); deleteInstructionText.anchor.set(0.5, 0.5); deleteInstructionText.x = 2048 / 2; deleteInstructionText.y = 2500; inventoryOverlay.addChild(deleteInstructionText); // Auto-hide instruction after 3 seconds LK.setTimeout(function () { if (deleteInstructionText && deleteInstructionText.parent) { deleteInstructionText.destroy(); } }, 3000); } else if (deleteMode && selectedDeleteAnimalType === this.animalType) { // Second press on same delete button - cancel delete mode deleteMode = false; selectedDeleteAnimalType = null; } }; // Handle unequip functionality unequipBtn.down = function () { // Find and remove one instance of this pet type from equipped animals for (var removeIndex = 0; removeIndex < equippedAnimals.length; removeIndex++) { if (equippedAnimals[removeIndex] === this.animalType) { equippedAnimals.splice(removeIndex, 1); break; } } // Recalculate pet bonus after unequipping var petBonus = 0; // Count each animal type var dogCount = 0; var catCount = 0; var snakeCount = 0; for (var j = 0; j < equippedAnimals.length; j++) { if (equippedAnimals[j] === 'dog') { dogCount++; } else if (equippedAnimals[j] === 'cat') { catCount++; } else if (equippedAnimals[j] === 'snake') { snakeCount++; } } // Each dog gives +1 bonus per tap petBonus += dogCount; // Cats: 1 cat = +2, 2 cats = +4, 3 cats = +6 (total bonus) if (catCount === 1) { petBonus += 2; } else if (catCount === 2) { petBonus += 4; } else if (catCount === 3) { petBonus += 6; } // Snakes: 1 snake = +5, 2 snakes = +10, 3 snakes = +15 (total bonus) if (snakeCount === 1) { petBonus += 5; } else if (snakeCount === 2) { petBonus += 10; } else if (snakeCount === 3) { petBonus += 15; } // Store as multiplier format (base 1 + bonus) currentMultiplier = 1 + petBonus; storage.equippedAnimals = equippedAnimals; storage.currentMultiplier = currentMultiplier; // Close and reopen inventory to refresh display inventoryOverlay.destroy(); inventoryOverlay = null; isInventoryOpen = false; // Reopen inventory to show updated counts inventoryBtn.down(); }; equipBtn.down = function () { // Count how many of this pet type are in inventory var inventoryCount = 0; for (var invIndex = 0; invIndex < inventory.length; invIndex++) { if (inventory[invIndex] === this.animalType) { inventoryCount++; } } // Count how many of this pet type are already equipped var equippedCount = 0; for (var checkIndex = 0; checkIndex < equippedAnimals.length; checkIndex++) { if (equippedAnimals[checkIndex] === this.animalType) { equippedCount++; } } // Check if we have this pet available in inventory to equip if (equippedCount >= inventoryCount) { var noPetText = new Text2('Need more pets to equip!', { size: 40, fill: 0xff0000 }); noPetText.anchor.set(0.5, 0.5); noPetText.x = this.x; noPetText.y = this.y - 50; inventoryOverlay.addChild(noPetText); LK.setTimeout(function () { noPetText.destroy(); }, 1500); return; } // Check if we can equip more pets (total limit of 3) if (equippedAnimals.length < maxEquippedPets) { // Equip this pet equippedAnimals.push(this.animalType); } else { // Show message that max pets reached var maxText = new Text2('Max 3 pets total!', { size: 40, fill: 0xff0000 }); maxText.anchor.set(0.5, 0.5); maxText.x = this.x; maxText.y = this.y - 50; inventoryOverlay.addChild(maxText); LK.setTimeout(function () { maxText.destroy(); }, 1500); return; } // Calculate pet bonus based on equipped animal quantities var petBonus = 0; // Count each animal type var dogCount = 0; var catCount = 0; var snakeCount = 0; for (var j = 0; j < equippedAnimals.length; j++) { if (equippedAnimals[j] === 'dog') { dogCount++; } else if (equippedAnimals[j] === 'cat') { catCount++; } else if (equippedAnimals[j] === 'snake') { snakeCount++; } } // Each dog gives +1 bonus per tap petBonus += dogCount; // Cats: 1 cat = +2, 2 cats = +4, 3 cats = +6 (total bonus) if (catCount === 1) { petBonus += 2; } else if (catCount === 2) { petBonus += 4; } else if (catCount === 3) { petBonus += 6; } // Snakes: 1 snake = +5, 2 snakes = +10, 3 snakes = +15 (total bonus) if (snakeCount === 1) { petBonus += 5; } else if (snakeCount === 2) { petBonus += 10; } else if (snakeCount === 3) { petBonus += 15; } // Store as multiplier format (base 1 + bonus) currentMultiplier = 1 + petBonus; storage.equippedAnimals = equippedAnimals; storage.currentMultiplier = currentMultiplier; // Close and reopen inventory to refresh display inventoryOverlay.destroy(); inventoryOverlay = null; isInventoryOpen = false; // Reopen inventory to show updated counts inventoryBtn.down(); }; yPos += 200; } // Add close inventory button var closeInvBtn = new Text2('Close', { size: 80, fill: 0xFFFFFF }); closeInvBtn.anchor.set(0.5, 0.5); closeInvBtn.x = 2048 / 2; closeInvBtn.y = 2400; inventoryOverlay.addChild(closeInvBtn); closeInvBtn.down = function () { // Reset delete mode when closing inventory deleteMode = false; selectedDeleteAnimalType = null; inventoryOverlay.destroy(); inventoryOverlay = null; isInventoryOpen = false; }; } // Handle Lucky Boost button luckyBoostBtn.down = function () { if (!isLuckyBoostShopOpen) { // Close shop first if (shopOverlay) { shopOverlay.destroy(); } shopOverlay = null; isShopOpen = false; // Open Lucky Boost shop isLuckyBoostShopOpen = true; luckyBoostOverlay = new Container(); var boostBackground = LK.getAsset('shopBg', { width: 2048, height: 2732, color: 0x000000, shape: 'box' }); luckyBoostOverlay.addChild(boostBackground); // Lucky Boost title var boostTitle = new Text2('Lucky Boost Shop', { size: 100, fill: 0xFFD700 }); boostTitle.anchor.set(0.5, 0); boostTitle.x = 2048 / 2; boostTitle.y = 300; luckyBoostOverlay.addChild(boostTitle); // Boost option 1: 1 minute var boost1Btn = new Text2('1 Minute Boost\n10,000 Score', { size: 60, fill: 0xFFFFFF }); boost1Btn.anchor.set(0.5, 0.5); boost1Btn.x = 2048 / 2; boost1Btn.y = 800; luckyBoostOverlay.addChild(boost1Btn); // Boost option 2: 5 minutes var boost5Btn = new Text2('5 Minutes Boost\n50,000 Score', { size: 60, fill: 0xFFFFFF }); boost5Btn.anchor.set(0.5, 0.5); boost5Btn.x = 2048 / 2; boost5Btn.y = 1200; luckyBoostOverlay.addChild(boost5Btn); // Boost option 3: 10 minutes var boost10Btn = new Text2('10 Minutes Boost\n100,000 Score', { size: 60, fill: 0xFFFFFF }); boost10Btn.anchor.set(0.5, 0.5); boost10Btn.x = 2048 / 2; boost10Btn.y = 1600; luckyBoostOverlay.addChild(boost10Btn); // Close button var closeBoostBtn = new Text2('Close', { size: 80, fill: 0xFFFFFF }); closeBoostBtn.anchor.set(0.5, 0.5); closeBoostBtn.x = 2048 / 2; closeBoostBtn.y = 2200; luckyBoostOverlay.addChild(closeBoostBtn); // Handle boost purchases boost1Btn.down = function () { if (LK.getScore() >= 10000) { LK.setScore(LK.getScore() - 10000); luckyBoostActive = true; luckyBoostEndTime = Date.now() + 60000; // 1 minute scoreTxt.setText(LK.getScore().toString()); luckyBoostOverlay.destroy(); luckyBoostOverlay = null; isLuckyBoostShopOpen = false; } }; boost5Btn.down = function () { if (LK.getScore() >= 50000) { LK.setScore(LK.getScore() - 50000); luckyBoostActive = true; luckyBoostEndTime = Date.now() + 300000; // 5 minutes scoreTxt.setText(LK.getScore().toString()); luckyBoostOverlay.destroy(); luckyBoostOverlay = null; isLuckyBoostShopOpen = false; } }; boost10Btn.down = function () { if (LK.getScore() >= 100000) { LK.setScore(LK.getScore() - 100000); luckyBoostActive = true; luckyBoostEndTime = Date.now() + 600000; // 10 minutes scoreTxt.setText(LK.getScore().toString()); luckyBoostOverlay.destroy(); luckyBoostOverlay = null; isLuckyBoostShopOpen = false; } }; closeBoostBtn.down = function () { luckyBoostOverlay.destroy(); luckyBoostOverlay = null; isLuckyBoostShopOpen = false; }; game.addChild(luckyBoostOverlay); } }; }; // Add shop overlay to main game game.addChild(shopOverlay); isShopOpen = true; } else { // Close shop - remove overlay if (shopOverlay) { shopOverlay.destroy(); shopOverlay = null; } isShopOpen = false; } }; // Update score display on game start game.update = function () { // Keep score text updated (in case it changes from other sources) scoreTxt.setText(LK.getScore().toString()); // Check if Lucky Boost has expired if (luckyBoostActive && Date.now() >= luckyBoostEndTime) { luckyBoostActive = false; } };
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x2c3e50 // Dark blue-gray background
});
/****
* Game Code
****/
// Reset all storage on game start
storage.currentMultiplier = 1;
storage.inventory = [];
storage.equippedAnimals = [];
// Global game variables
var currentMultiplier = 1;
var inventory = [];
var isInventoryOpen = false;
var inventoryOverlay = null;
var equippedAnimals = [];
var maxEquippedPets = 3;
var fallingEgg = null;
var eggClickCount = 0;
var deleteMode = false;
var selectedDeleteAnimalType = null;
var luckyBoostActive = false;
var luckyBoostEndTime = 0;
var isLuckyBoostShopOpen = false;
var luckyBoostOverlay = null;
// Reset score to 0 on game start
LK.setScore(0);
// Initialize score display
var scoreTxt = new Text2('0', {
size: 120,
fill: 0xFFFFFF
});
// Set score text properties
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Position score text with some padding from top
scoreTxt.y = 100;
// Add tap instruction text
var instructionTxt = new Text2('Tap anywhere to score!', {
size: 60,
fill: 0xBDC3C7
});
instructionTxt.anchor.set(0.5, 0.5);
instructionTxt.x = 2048 / 2;
instructionTxt.y = 2732 / 2;
game.addChild(instructionTxt);
// Handle tap events on the game area
game.down = function (x, y, obj) {
// Calculate pet bonus based on equipped animal quantities
var petBonus = 0;
// Count each animal type
var dogCount = 0;
var catCount = 0;
var snakeCount = 0;
var goldenDogCount = 0;
var goldenCatCount = 0;
var goldenSnakeCount = 0;
var dinosaurCount = 0;
var bearCount = 0;
var beeCount = 0;
var goldenDinosaurCount = 0;
var goldenBearCount = 0;
var goldenBeeCount = 0;
var trexCount = 0;
var velectorCount = 0;
var titanaBullCount = 0;
var goldenTrexCount = 0;
var goldenVelectorCount = 0;
var goldenTitanaBullCount = 0;
var ironManCount = 0;
var captainAmericaCount = 0;
var spidermanCount = 0;
var goldenIronManCount = 0;
var goldenCaptainAmericaCount = 0;
var goldenSpidermanCount = 0;
var kingCount = 0;
var knightCount = 0;
var humanCount = 0;
var goldenKingCount = 0;
var goldenKnightCount = 0;
var goldenHumanCount = 0;
var earthCount = 0;
var moonCount = 0;
var meteorCount = 0;
var sunCount = 0;
var jupiterCount = 0;
var neptuneCount = 0;
var goldenEarthCount = 0;
var goldenMoonCount = 0;
var goldenMeteorCount = 0;
var goldenSunCount = 0;
var goldenJupiterCount = 0;
var goldenNeptuneCount = 0;
var andromedaGalaxyCount = 0;
var normalGalaxyCount = 0;
var milkyWayGalaxyCount = 0;
var goldenAndromedaGalaxyCount = 0;
var goldenNormalGalaxyCount = 0;
var goldenMilkyWayGalaxyCount = 0;
for (var j = 0; j < equippedAnimals.length; j++) {
if (equippedAnimals[j] === 'dog') {
dogCount++;
} else if (equippedAnimals[j] === 'cat') {
catCount++;
} else if (equippedAnimals[j] === 'snake') {
snakeCount++;
} else if (equippedAnimals[j] === 'goldenDog') {
goldenDogCount++;
} else if (equippedAnimals[j] === 'goldenCat') {
goldenCatCount++;
} else if (equippedAnimals[j] === 'goldenSnake') {
goldenSnakeCount++;
} else if (equippedAnimals[j] === 'dinosaur') {
dinosaurCount++;
} else if (equippedAnimals[j] === 'bear') {
bearCount++;
} else if (equippedAnimals[j] === 'bee') {
beeCount++;
} else if (equippedAnimals[j] === 'goldenDinosaur') {
goldenDinosaurCount++;
} else if (equippedAnimals[j] === 'goldenBear') {
goldenBearCount++;
} else if (equippedAnimals[j] === 'goldenBee') {
goldenBeeCount++;
} else if (equippedAnimals[j] === 'trex') {
trexCount++;
} else if (equippedAnimals[j] === 'velector') {
velectorCount++;
} else if (equippedAnimals[j] === 'titanaBull') {
titanaBullCount++;
} else if (equippedAnimals[j] === 'goldenTrex') {
goldenTrexCount++;
} else if (equippedAnimals[j] === 'goldenVelector') {
goldenVelectorCount++;
} else if (equippedAnimals[j] === 'goldenTitanaBull') {
goldenTitanaBullCount++;
} else if (equippedAnimals[j] === 'ironMan') {
ironManCount++;
} else if (equippedAnimals[j] === 'captainAmerica') {
captainAmericaCount++;
} else if (equippedAnimals[j] === 'spiderman') {
spidermanCount++;
} else if (equippedAnimals[j] === 'goldenIronMan') {
goldenIronManCount++;
} else if (equippedAnimals[j] === 'goldenCaptainAmerica') {
goldenCaptainAmericaCount++;
} else if (equippedAnimals[j] === 'goldenSpiderman') {
goldenSpidermanCount++;
} else if (equippedAnimals[j] === 'king') {
kingCount++;
} else if (equippedAnimals[j] === 'knight') {
knightCount++;
} else if (equippedAnimals[j] === 'human') {
humanCount++;
} else if (equippedAnimals[j] === 'goldenKing') {
goldenKingCount++;
} else if (equippedAnimals[j] === 'goldenKnight') {
goldenKnightCount++;
} else if (equippedAnimals[j] === 'goldenHuman') {
goldenHumanCount++;
} else if (equippedAnimals[j] === 'earth') {
earthCount++;
} else if (equippedAnimals[j] === 'moon') {
moonCount++;
} else if (equippedAnimals[j] === 'meteor') {
meteorCount++;
} else if (equippedAnimals[j] === 'sun') {
sunCount++;
} else if (equippedAnimals[j] === 'jupiter') {
jupiterCount++;
} else if (equippedAnimals[j] === 'neptune') {
neptuneCount++;
} else if (equippedAnimals[j] === 'goldenEarth') {
goldenEarthCount++;
} else if (equippedAnimals[j] === 'goldenMoon') {
goldenMoonCount++;
} else if (equippedAnimals[j] === 'goldenMeteor') {
goldenMeteorCount++;
} else if (equippedAnimals[j] === 'goldenSun') {
goldenSunCount++;
} else if (equippedAnimals[j] === 'goldenJupiter') {
goldenJupiterCount++;
} else if (equippedAnimals[j] === 'goldenNeptune') {
goldenNeptuneCount++;
} else if (equippedAnimals[j] === 'andromedaGalaxy') {
andromedaGalaxyCount++;
} else if (equippedAnimals[j] === 'normalGalaxy') {
normalGalaxyCount++;
} else if (equippedAnimals[j] === 'milkyWayGalaxy') {
milkyWayGalaxyCount++;
} else if (equippedAnimals[j] === 'goldenAndromedaGalaxy') {
goldenAndromedaGalaxyCount++;
} else if (equippedAnimals[j] === 'goldenNormalGalaxy') {
goldenNormalGalaxyCount++;
} else if (equippedAnimals[j] === 'goldenMilkyWayGalaxy') {
goldenMilkyWayGalaxyCount++;
}
}
// Each dog gives +1 bonus per tap
petBonus += dogCount;
// Cats: 1 cat = +2, 2 cats = +4, 3 cats = +6 (total bonus)
if (catCount === 1) {
petBonus += 2;
} else if (catCount === 2) {
petBonus += 4;
} else if (catCount === 3) {
petBonus += 6;
}
// Snakes: 1 snake = +5, 2 snakes = +10, 3 snakes = +15 (total bonus)
if (snakeCount === 1) {
petBonus += 5;
} else if (snakeCount === 2) {
petBonus += 10;
} else if (snakeCount === 3) {
petBonus += 15;
}
// Golden pets bonuses
// Golden dogs: 1 = +3, 2 = +6, 3 = +9 per tap
if (goldenDogCount === 1) {
petBonus += 3;
} else if (goldenDogCount === 2) {
petBonus += 6;
} else if (goldenDogCount === 3) {
petBonus += 9;
}
// Golden cats: 1 = +6, 2 = +12, 3 = +18 per tap
if (goldenCatCount === 1) {
petBonus += 6;
} else if (goldenCatCount === 2) {
petBonus += 12;
} else if (goldenCatCount === 3) {
petBonus += 18;
}
// Golden snakes: 1 = +10, 2 = +20, 3 = +30 per tap
if (goldenSnakeCount === 1) {
petBonus += 10;
} else if (goldenSnakeCount === 2) {
petBonus += 20;
} else if (goldenSnakeCount === 3) {
petBonus += 30;
}
// Green egg pets bonuses
// Dinosaurs: 1 = +30, 2 = +60, 3 = +90 per tap
if (dinosaurCount === 1) {
petBonus += 30;
} else if (dinosaurCount === 2) {
petBonus += 60;
} else if (dinosaurCount === 3) {
petBonus += 90;
}
// Bears: 1 = +20, 2 = +40, 3 = +60 per tap
if (bearCount === 1) {
petBonus += 20;
} else if (bearCount === 2) {
petBonus += 40;
} else if (bearCount === 3) {
petBonus += 60;
}
// Bees: 1 = +10, 2 = +20, 3 = +30 per tap
if (beeCount === 1) {
petBonus += 10;
} else if (beeCount === 2) {
petBonus += 20;
} else if (beeCount === 3) {
petBonus += 30;
}
// Golden green egg pets bonuses (2x multiplier)
// Golden dinosaurs: 1 = +60, 2 = +120, 3 = +180 per tap
if (goldenDinosaurCount === 1) {
petBonus += 60;
} else if (goldenDinosaurCount === 2) {
petBonus += 120;
} else if (goldenDinosaurCount === 3) {
petBonus += 180;
}
// Golden bears: 1 = +40, 2 = +80, 3 = +120 per tap
if (goldenBearCount === 1) {
petBonus += 40;
} else if (goldenBearCount === 2) {
petBonus += 80;
} else if (goldenBearCount === 3) {
petBonus += 120;
}
// Golden bees: 1 = +20, 2 = +40, 3 = +60 per tap
if (goldenBeeCount === 1) {
petBonus += 20;
} else if (goldenBeeCount === 2) {
petBonus += 40;
} else if (goldenBeeCount === 3) {
petBonus += 60;
}
// Red egg pets bonuses
// T-rex: 1 = +100, 2 = +200, 3 = +300 per tap
if (trexCount === 1) {
petBonus += 100;
} else if (trexCount === 2) {
petBonus += 200;
} else if (trexCount === 3) {
petBonus += 300;
}
// Velector: 1 = +80, 2 = +160, 3 = +240 per tap
if (velectorCount === 1) {
petBonus += 80;
} else if (velectorCount === 2) {
petBonus += 160;
} else if (velectorCount === 3) {
petBonus += 240;
}
// Titana Bull: 1 = +50, 2 = +100, 3 = +150 per tap
if (titanaBullCount === 1) {
petBonus += 50;
} else if (titanaBullCount === 2) {
petBonus += 100;
} else if (titanaBullCount === 3) {
petBonus += 150;
}
// Golden red egg pets bonuses
// Golden T-rex: 1 = +200, 2 = +400, 3 = +600 per tap
if (goldenTrexCount === 1) {
petBonus += 200;
} else if (goldenTrexCount === 2) {
petBonus += 400;
} else if (goldenTrexCount === 3) {
petBonus += 600;
}
// Golden Velector: 1 = +160, 2 = +320, 3 = +480 per tap
if (goldenVelectorCount === 1) {
petBonus += 160;
} else if (goldenVelectorCount === 2) {
petBonus += 320;
} else if (goldenVelectorCount === 3) {
petBonus += 480;
}
// Golden Titana Bull: 1 = +100, 2 = +200, 3 = +300 per tap
if (goldenTitanaBullCount === 1) {
petBonus += 100;
} else if (goldenTitanaBullCount === 2) {
petBonus += 200;
} else if (goldenTitanaBullCount === 3) {
petBonus += 300;
}
// Purple egg pets bonuses
// Iron Man: 1 = +500, 2 = +1000, 3 = +1500 per tap
if (ironManCount === 1) {
petBonus += 500;
} else if (ironManCount === 2) {
petBonus += 1000;
} else if (ironManCount === 3) {
petBonus += 1500;
}
// Captain America: 1 = +300, 2 = +600, 3 = +900 per tap
if (captainAmericaCount === 1) {
petBonus += 300;
} else if (captainAmericaCount === 2) {
petBonus += 600;
} else if (captainAmericaCount === 3) {
petBonus += 900;
}
// Spiderman: 1 = +250, 2 = +500, 3 = +750 per tap
if (spidermanCount === 1) {
petBonus += 250;
} else if (spidermanCount === 2) {
petBonus += 500;
} else if (spidermanCount === 3) {
petBonus += 750;
}
// Golden purple egg pets bonuses (2x multiplier)
// Golden Iron Man: 1 = +1000, 2 = +2000, 3 = +3000 per tap
if (goldenIronManCount === 1) {
petBonus += 1000;
} else if (goldenIronManCount === 2) {
petBonus += 2000;
} else if (goldenIronManCount === 3) {
petBonus += 3000;
}
// Golden Captain America: 1 = +600, 2 = +1200, 3 = +1800 per tap
if (goldenCaptainAmericaCount === 1) {
petBonus += 600;
} else if (goldenCaptainAmericaCount === 2) {
petBonus += 1200;
} else if (goldenCaptainAmericaCount === 3) {
petBonus += 1800;
}
// Golden Spiderman: 1 = +500, 2 = +1000, 3 = +1500 per tap
if (goldenSpidermanCount === 1) {
petBonus += 500;
} else if (goldenSpidermanCount === 2) {
petBonus += 1000;
} else if (goldenSpidermanCount === 3) {
petBonus += 1500;
}
// White egg pets bonuses
// King: 1 = +10000, 2 = +20000, 3 = +30000 per tap
if (kingCount === 1) {
petBonus += 10000;
} else if (kingCount === 2) {
petBonus += 20000;
} else if (kingCount === 3) {
petBonus += 30000;
}
// Knight: 1 = +5000, 2 = +10000, 3 = +15000 per tap
if (knightCount === 1) {
petBonus += 5000;
} else if (knightCount === 2) {
petBonus += 10000;
} else if (knightCount === 3) {
petBonus += 15000;
}
// Human: 1 = +2500, 2 = +5000, 3 = +7500 per tap
if (humanCount === 1) {
petBonus += 2500;
} else if (humanCount === 2) {
petBonus += 5000;
} else if (humanCount === 3) {
petBonus += 7500;
}
// Golden white egg pets bonuses (2x multiplier)
// Golden King: 1 = +20000, 2 = +40000, 3 = +60000 per tap
if (goldenKingCount === 1) {
petBonus += 20000;
} else if (goldenKingCount === 2) {
petBonus += 40000;
} else if (goldenKingCount === 3) {
petBonus += 60000;
}
// Golden Knight: 1 = +10000, 2 = +20000, 3 = +30000 per tap
if (goldenKnightCount === 1) {
petBonus += 10000;
} else if (goldenKnightCount === 2) {
petBonus += 20000;
} else if (goldenKnightCount === 3) {
petBonus += 30000;
}
// Golden Human: 1 = +5000, 2 = +10000, 3 = +15000 per tap
if (goldenHumanCount === 1) {
petBonus += 5000;
} else if (goldenHumanCount === 2) {
petBonus += 10000;
} else if (goldenHumanCount === 3) {
petBonus += 15000;
}
// Space egg pets bonuses
// Earth: 1 = +100000, 2 = +200000, 3 = +300000 per tap
if (earthCount === 1) {
petBonus += 100000;
} else if (earthCount === 2) {
petBonus += 200000;
} else if (earthCount === 3) {
petBonus += 300000;
}
// Moon: 1 = +50000, 2 = +100000, 3 = +150000 per tap
if (moonCount === 1) {
petBonus += 50000;
} else if (moonCount === 2) {
petBonus += 100000;
} else if (moonCount === 3) {
petBonus += 150000;
}
// Meteor: 1 = +25000, 2 = +50000, 3 = +75000 per tap
if (meteorCount === 1) {
petBonus += 25000;
} else if (meteorCount === 2) {
petBonus += 50000;
} else if (meteorCount === 3) {
petBonus += 75000;
}
// Sun: 1 = +500000, 2 = +1000000, 3 = +1500000 per tap
if (sunCount === 1) {
petBonus += 500000;
} else if (sunCount === 2) {
petBonus += 1000000;
} else if (sunCount === 3) {
petBonus += 1500000;
}
// Jupiter: 1 = +250000, 2 = +500000, 3 = +750000 per tap
if (jupiterCount === 1) {
petBonus += 250000;
} else if (jupiterCount === 2) {
petBonus += 500000;
} else if (jupiterCount === 3) {
petBonus += 750000;
}
// Neptune: 1 = +200000, 2 = +400000, 3 = +600000 per tap
if (neptuneCount === 1) {
petBonus += 200000;
} else if (neptuneCount === 2) {
petBonus += 400000;
} else if (neptuneCount === 3) {
petBonus += 600000;
}
// Golden space egg pets bonuses (2x multiplier)
// Golden Earth: 1 = +200000, 2 = +400000, 3 = +600000 per tap
if (goldenEarthCount === 1) {
petBonus += 200000;
} else if (goldenEarthCount === 2) {
petBonus += 400000;
} else if (goldenEarthCount === 3) {
petBonus += 600000;
}
// Golden Moon: 1 = +100000, 2 = +200000, 3 = +300000 per tap
if (goldenMoonCount === 1) {
petBonus += 100000;
} else if (goldenMoonCount === 2) {
petBonus += 200000;
} else if (goldenMoonCount === 3) {
petBonus += 300000;
}
// Golden Meteor: 1 = +50000, 2 = +100000, 3 = +150000 per tap
if (goldenMeteorCount === 1) {
petBonus += 50000;
} else if (goldenMeteorCount === 2) {
petBonus += 100000;
} else if (goldenMeteorCount === 3) {
petBonus += 150000;
}
// Golden Sun: 1 = +1000000, 2 = +2000000, 3 = +3000000 per tap
if (goldenSunCount === 1) {
petBonus += 1000000;
} else if (goldenSunCount === 2) {
petBonus += 2000000;
} else if (goldenSunCount === 3) {
petBonus += 3000000;
}
// Golden Jupiter: 1 = +500000, 2 = +1000000, 3 = +1500000 per tap
if (goldenJupiterCount === 1) {
petBonus += 500000;
} else if (goldenJupiterCount === 2) {
petBonus += 1000000;
} else if (goldenJupiterCount === 3) {
petBonus += 1500000;
}
// Golden Neptune: 1 = +400000, 2 = +800000, 3 = +1200000 per tap
if (goldenNeptuneCount === 1) {
petBonus += 400000;
} else if (goldenNeptuneCount === 2) {
petBonus += 800000;
} else if (goldenNeptuneCount === 3) {
petBonus += 1200000;
}
// Galaxy egg pets bonuses
// Andromeda Galaxy: 1 = +5000000, 2 = +10000000, 3 = +15000000 per tap
if (andromedaGalaxyCount === 1) {
petBonus += 5000000;
} else if (andromedaGalaxyCount === 2) {
petBonus += 10000000;
} else if (andromedaGalaxyCount === 3) {
petBonus += 15000000;
}
// Normal Galaxy: 1 = +10000000, 2 = +20000000, 3 = +30000000 per tap
if (normalGalaxyCount === 1) {
petBonus += 10000000;
} else if (normalGalaxyCount === 2) {
petBonus += 20000000;
} else if (normalGalaxyCount === 3) {
petBonus += 30000000;
}
// Milky Way Galaxy: 1 = +20000000, 2 = +40000000, 3 = +60000000 per tap
if (milkyWayGalaxyCount === 1) {
petBonus += 20000000;
} else if (milkyWayGalaxyCount === 2) {
petBonus += 40000000;
} else if (milkyWayGalaxyCount === 3) {
petBonus += 60000000;
}
// Golden galaxy egg pets bonuses (2x multiplier)
// Golden Andromeda Galaxy: 1 = +10000000, 2 = +20000000, 3 = +30000000 per tap
if (goldenAndromedaGalaxyCount === 1) {
petBonus += 10000000;
} else if (goldenAndromedaGalaxyCount === 2) {
petBonus += 20000000;
} else if (goldenAndromedaGalaxyCount === 3) {
petBonus += 30000000;
}
// Golden Normal Galaxy: 1 = +20000000, 2 = +40000000, 3 = +60000000 per tap
if (goldenNormalGalaxyCount === 1) {
petBonus += 20000000;
} else if (goldenNormalGalaxyCount === 2) {
petBonus += 40000000;
} else if (goldenNormalGalaxyCount === 3) {
petBonus += 60000000;
}
// Golden Milky Way Galaxy: 1 = +40000000, 2 = +80000000, 3 = +120000000 per tap
if (goldenMilkyWayGalaxyCount === 1) {
petBonus += 40000000;
} else if (goldenMilkyWayGalaxyCount === 2) {
petBonus += 80000000;
} else if (goldenMilkyWayGalaxyCount === 3) {
petBonus += 120000000;
}
// Base tap score is always 1, plus calculated pet bonus
var totalScore = 1 + petBonus;
LK.setScore(LK.getScore() + totalScore);
// Update score display
scoreTxt.setText(LK.getScore().toString());
// Create visual feedback at tap location showing total points gained
var feedbackText = '+' + totalScore.toString();
var tapFeedback = new Text2(feedbackText, {
size: 80,
fill: 0x27AE60
});
tapFeedback.anchor.set(0.5, 0.5);
tapFeedback.x = x;
tapFeedback.y = y;
tapFeedback.alpha = 1;
game.addChild(tapFeedback);
// Animate feedback text
var startY = y;
var animationDuration = 800;
var startTime = Date.now();
var _animateCallback = function animateCallback() {
var elapsed = Date.now() - startTime;
var progress = elapsed / animationDuration;
if (progress >= 1) {
tapFeedback.destroy();
return;
}
// Move text upward and fade out
tapFeedback.y = startY - progress * 100;
tapFeedback.alpha = 1 - progress;
LK.setTimeout(_animateCallback, 16); // ~60fps
};
_animateCallback();
// Hide instruction text after first tap
if (LK.getScore() === 1) {
instructionTxt.alpha = 0;
}
};
// Add Shop button
var shopBtn = new Text2('Shop', {
size: 80,
fill: 0xFFFFFF
});
shopBtn.anchor.set(1, 0);
LK.gui.topRight.addChild(shopBtn);
shopBtn.x = -20; // Small padding from right edge
shopBtn.y = 20; // Small padding from top
// Shop interface state
var isShopOpen = false;
var shopOverlay = null;
// Handle shop button tap
shopBtn.down = function (x, y, obj) {
if (!isShopOpen) {
// Open shop - create black overlay using Container
shopOverlay = new Container();
// Create black background shape for overlay
var shopBackground = LK.getAsset('shopBg', {
width: 2048,
height: 2732,
color: 0x000000,
shape: 'box'
});
shopOverlay.addChild(shopBackground);
shopOverlay.x = 0;
shopOverlay.y = 0;
// NORMAL EGGS SECTION
// Normal eggs data
var normalEggs = [{
asset: 'egg',
price: '1000 Score',
color: 0xFFFFFF
}, {
asset: 'greenEgg',
price: '15000 Score',
color: 0x00ff00
}, {
asset: 'redEgg',
price: '50000 Score',
color: 0xff0000
}, {
asset: 'purpleEgg',
price: '1250000 Score',
color: 0x800080
}, {
asset: 'whiteEgg',
price: '10M',
color: 0xffffff
}, {
asset: 'spaceEgg',
price: '100M',
color: 0x4169e1
}, {
asset: 'space2Egg',
price: '200M',
color: 0x8a2be2
}, {
asset: 'galaxyEgg',
price: '500M',
color: 0x800080
}];
// Golden eggs data
var goldenEggs = [{
asset: 'goldenEgg',
price: '10000 Score',
color: 0xFFD700
}, {
asset: 'goldenGreenEgg',
price: '30000 Score',
color: 0x90ee90
}, {
asset: 'goldenRedEgg',
price: '100000 Score',
color: 0xff6600
}, {
asset: 'goldenPurpleEgg',
price: '2500000 Score',
color: 0xdaa520
}, {
asset: 'goldenWhiteEgg',
price: '20M',
color: 0xffd700
}, {
asset: 'goldenSpaceEgg',
price: '200M',
color: 0xffd700
}, {
asset: 'goldenSpace2Egg',
price: '400M',
color: 0xffd700
}, {
asset: 'goldenGalaxyEgg',
price: '1B',
color: 0xffd700
}];
// Display normal eggs section
var normalEggItems = [];
var startY = 600;
var eggSpacing = 300;
var rowSpacing = 300;
var maxEggsPerRow = 5;
for (var i = 0; i < normalEggs.length; i++) {
var row = Math.floor(i / maxEggsPerRow);
var col = i % maxEggsPerRow;
var startX = (2048 - (Math.min(normalEggs.length - row * maxEggsPerRow, maxEggsPerRow) - 1) * eggSpacing) / 2;
var eggX = startX + col * eggSpacing;
var eggY = startY + row * rowSpacing;
var eggItem = LK.getAsset(normalEggs[i].asset, {
anchorX: 0.5,
anchorY: 0.5
});
eggItem.x = eggX;
eggItem.y = eggY;
shopOverlay.addChild(eggItem);
normalEggItems.push(eggItem);
var eggPriceText = new Text2(normalEggs[i].price, {
size: 50,
fill: normalEggs[i].color
});
eggPriceText.anchor.set(0.5, 0);
eggPriceText.x = eggX;
eggPriceText.y = eggY + 120;
shopOverlay.addChild(eggPriceText);
}
// Display golden eggs section
var goldenEggItems = [];
var goldenStartY = startY + Math.ceil(normalEggs.length / maxEggsPerRow) * rowSpacing + 300;
for (var i = 0; i < goldenEggs.length; i++) {
var row = Math.floor(i / maxEggsPerRow);
var col = i % maxEggsPerRow;
var startX = (2048 - (Math.min(goldenEggs.length - row * maxEggsPerRow, maxEggsPerRow) - 1) * eggSpacing) / 2;
var eggX = startX + col * eggSpacing;
var eggY = goldenStartY + row * rowSpacing;
var goldenEggItem = LK.getAsset(goldenEggs[i].asset, {
anchorX: 0.5,
anchorY: 0.5
});
goldenEggItem.x = eggX;
goldenEggItem.y = eggY;
shopOverlay.addChild(goldenEggItem);
goldenEggItems.push(goldenEggItem);
var goldenEggPriceText = new Text2(goldenEggs[i].price, {
size: 50,
fill: goldenEggs[i].color
});
goldenEggPriceText.anchor.set(0.5, 0);
goldenEggPriceText.x = eggX;
goldenEggPriceText.y = eggY + 120;
shopOverlay.addChild(goldenEggPriceText);
}
// Add Lucky Boost button
var luckyBoostBtnY = goldenStartY + Math.ceil(goldenEggs.length / maxEggsPerRow) * rowSpacing + 100;
var luckyBoostBtn = new Text2('Lucky Boost', {
size: 80,
fill: 0xFFD700
});
luckyBoostBtn.anchor.set(0.5, 0);
luckyBoostBtn.x = 2048 / 3;
luckyBoostBtn.y = luckyBoostBtnY;
shopOverlay.addChild(luckyBoostBtn);
// Add inventory button
var inventoryBtnY = goldenStartY + Math.ceil(goldenEggs.length / maxEggsPerRow) * rowSpacing + 100;
var inventoryBtn = new Text2('Inventory', {
size: 80,
fill: 0xFFFFFF
});
inventoryBtn.anchor.set(0.5, 0);
inventoryBtn.x = 2048 * 2 / 3;
inventoryBtn.y = inventoryBtnY;
shopOverlay.addChild(inventoryBtn);
// Store references for purchase handlers
var eggItem = normalEggItems[0];
var greenEggItem = normalEggItems[1];
var redEggItem = normalEggItems[2];
var purpleEggItem = normalEggItems[3];
var whiteEggItem = normalEggItems[4];
var goldenEggItem = goldenEggItems[0];
var goldenGreenEggItem = goldenEggItems[1];
var goldenRedEggItem = goldenEggItems[2];
var goldenPurpleEggItem = goldenEggItems[3];
var goldenWhiteEggItem = goldenEggItems[4];
var spaceEggItem = normalEggItems[5];
var space2EggItem = normalEggItems[6];
var goldenSpaceEggItem = goldenEggItems[5];
var goldenSpace2EggItem = goldenEggItems[6];
var galaxyEggItem = normalEggItems[7];
var goldenGalaxyEggItem = goldenEggItems[7];
// Handle egg purchase
eggItem.down = function () {
if (LK.getScore() >= 1000) {
LK.setScore(LK.getScore() - 1000);
scoreTxt.setText(LK.getScore().toString());
// Close shop
shopOverlay.destroy();
shopOverlay = null;
isShopOpen = false;
// Create falling egg
fallingEgg = LK.getAsset('egg', {
anchorX: 0.5,
anchorY: 0.5
});
fallingEgg.x = 2048 / 2;
fallingEgg.y = -200;
eggClickCount = 0;
game.addChild(fallingEgg);
// Animate egg falling
tween(fallingEgg, {
y: 2732 / 2
}, {
duration: 1000
});
// Handle egg clicking
fallingEgg.down = function () {
eggClickCount++;
if (eggClickCount === 1) {
// First crack
var crackedEgg1 = LK.getAsset('crackedEgg1', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg1.x = fallingEgg.x;
crackedEgg1.y = fallingEgg.y;
game.addChild(crackedEgg1);
fallingEgg.destroy();
fallingEgg = crackedEgg1;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 2) {
// Second crack
var crackedEgg2 = LK.getAsset('crackedEgg2', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg2.x = fallingEgg.x;
crackedEgg2.y = fallingEgg.y;
game.addChild(crackedEgg2);
fallingEgg.destroy();
fallingEgg = crackedEgg2;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 3) {
// Third crack - almost fully cracked
var crackedEgg3 = LK.getAsset('crackedEgg3', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg3.x = fallingEgg.x;
crackedEgg3.y = fallingEgg.y;
game.addChild(crackedEgg3);
fallingEgg.destroy();
fallingEgg = crackedEgg3;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 4) {
// Hatch the egg
// Get list of animals that have less than 3 in inventory
var availableAnimals = [];
var animalTypes = ['dog', 'cat', 'snake'];
for (var typeIndex = 0; typeIndex < animalTypes.length; typeIndex++) {
var animalType = animalTypes[typeIndex];
var countInInventory = 0;
for (var invIndex = 0; invIndex < inventory.length; invIndex++) {
if (inventory[invIndex] === animalType) {
countInInventory++;
}
}
if (countInInventory < 3) {
availableAnimals.push(animalType);
}
}
var animal;
if (availableAnimals.length > 0) {
// Choose randomly from available animals
var randomIndex = Math.floor(Math.random() * availableAnimals.length);
animal = availableAnimals[randomIndex];
// Add to inventory
inventory.push(animal);
storage.inventory = inventory;
} else {
// All animal types have 3 in inventory, show message and don't give new pet
animal = null;
var allPetsText = new Text2('All pets maxed out!', {
size: 60,
fill: 0xff0000
});
allPetsText.anchor.set(0.5, 0.5);
allPetsText.x = 2048 / 2;
allPetsText.y = 1500;
game.addChild(allPetsText);
LK.setTimeout(function () {
allPetsText.destroy();
}, 2000);
}
// Only show hatched animal if we got a new pet
if (animal) {
var animalSprite = LK.getAsset(animal, {
anchorX: 0.5,
anchorY: 0.5
});
animalSprite.x = fallingEgg.x;
animalSprite.y = fallingEgg.y;
game.addChild(animalSprite);
// Remove animal after showing
LK.setTimeout(function () {
animalSprite.destroy();
}, 2000);
}
// Remove egg
fallingEgg.destroy();
fallingEgg = null;
}
};
}
};
// Handle green egg purchase
greenEggItem.down = function () {
if (LK.getScore() >= 15000) {
LK.setScore(LK.getScore() - 15000);
scoreTxt.setText(LK.getScore().toString());
// Close shop
shopOverlay.destroy();
shopOverlay = null;
isShopOpen = false;
// Create falling green egg
fallingEgg = LK.getAsset('greenEgg', {
anchorX: 0.5,
anchorY: 0.5
});
fallingEgg.x = 2048 / 2;
fallingEgg.y = -200;
eggClickCount = 0;
game.addChild(fallingEgg);
// Animate egg falling
tween(fallingEgg, {
y: 2732 / 2
}, {
duration: 1000
});
// Handle green egg clicking
fallingEgg.down = function () {
eggClickCount++;
if (eggClickCount === 1) {
// First crack
var crackedEgg1 = LK.getAsset('crackedEgg1', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg1.x = fallingEgg.x;
crackedEgg1.y = fallingEgg.y;
game.addChild(crackedEgg1);
fallingEgg.destroy();
fallingEgg = crackedEgg1;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 2) {
// Second crack
var crackedEgg2 = LK.getAsset('crackedEgg2', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg2.x = fallingEgg.x;
crackedEgg2.y = fallingEgg.y;
game.addChild(crackedEgg2);
fallingEgg.destroy();
fallingEgg = crackedEgg2;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 3) {
// Third crack - almost fully cracked
var crackedEgg3 = LK.getAsset('crackedEgg3', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg3.x = fallingEgg.x;
crackedEgg3.y = fallingEgg.y;
game.addChild(crackedEgg3);
fallingEgg.destroy();
fallingEgg = crackedEgg3;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 4) {
// Hatch the green egg with special probabilities
var availableGreenAnimals = [];
var greenAnimalTypes = ['dinosaur', 'bear', 'bee'];
for (var typeIndex = 0; typeIndex < greenAnimalTypes.length; typeIndex++) {
var animalType = greenAnimalTypes[typeIndex];
var countInInventory = 0;
for (var invIndex = 0; invIndex < inventory.length; invIndex++) {
if (inventory[invIndex] === animalType) {
countInInventory++;
}
}
if (countInInventory < 3) {
availableGreenAnimals.push(animalType);
}
}
var animal;
if (availableGreenAnimals.length > 0) {
// Special probability distribution for green eggs with Lucky Boost effect
var random = Math.random();
var selectedAnimal;
var dinosaurChance = 0.05;
var bearChance = 0.2;
var beeChance = 1.0;
// Apply Lucky Boost effect
if (luckyBoostActive && Date.now() < luckyBoostEndTime) {
// Increase chance for lowest probability pets (dinosaur, bear) by 10x
// Decrease chance for highest probability pet (bee) by 10x
dinosaurChance *= 10; // 50% chance
bearChance = bearChance + (bearChance - 0.05) * 10; // Increase bear chance proportionally
beeChance = 0.08; // Reduced from 80% to 8%
}
if (random < dinosaurChance) {
selectedAnimal = 'dinosaur';
} else if (random < bearChance) {
selectedAnimal = 'bear';
} else {
selectedAnimal = 'bee';
}
// Check if selected animal is available
if (availableGreenAnimals.indexOf(selectedAnimal) !== -1) {
animal = selectedAnimal;
} else {
// If selected animal is not available, choose randomly from available
var randomIndex = Math.floor(Math.random() * availableGreenAnimals.length);
animal = availableGreenAnimals[randomIndex];
}
inventory.push(animal);
storage.inventory = inventory;
} else {
// All green animal types have 3 in inventory
animal = null;
var allGreenPetsText = new Text2('All green pets maxed out!', {
size: 60,
fill: 0xff0000
});
allGreenPetsText.anchor.set(0.5, 0.5);
allGreenPetsText.x = 2048 / 2;
allGreenPetsText.y = 1500;
game.addChild(allGreenPetsText);
LK.setTimeout(function () {
allGreenPetsText.destroy();
}, 2000);
}
// Only show hatched animal if we got a new pet
if (animal) {
var animalSprite = LK.getAsset(animal, {
anchorX: 0.5,
anchorY: 0.5
});
animalSprite.x = fallingEgg.x;
animalSprite.y = fallingEgg.y;
game.addChild(animalSprite);
// Remove animal after showing
LK.setTimeout(function () {
animalSprite.destroy();
}, 2000);
}
// Remove egg
fallingEgg.destroy();
fallingEgg = null;
}
};
}
};
// Handle golden green egg purchase
goldenGreenEggItem.down = function () {
if (LK.getScore() >= 30000) {
LK.setScore(LK.getScore() - 30000);
scoreTxt.setText(LK.getScore().toString());
// Close shop
shopOverlay.destroy();
shopOverlay = null;
isShopOpen = false;
// Create falling golden green egg
fallingEgg = LK.getAsset('goldenGreenEgg', {
anchorX: 0.5,
anchorY: 0.5
});
fallingEgg.x = 2048 / 2;
fallingEgg.y = -200;
eggClickCount = 0;
game.addChild(fallingEgg);
// Animate egg falling
tween(fallingEgg, {
y: 2732 / 2
}, {
duration: 1000
});
// Handle golden green egg clicking
fallingEgg.down = function () {
eggClickCount++;
if (eggClickCount === 1) {
// First crack
var crackedEgg1 = LK.getAsset('crackedEgg1', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg1.x = fallingEgg.x;
crackedEgg1.y = fallingEgg.y;
game.addChild(crackedEgg1);
fallingEgg.destroy();
fallingEgg = crackedEgg1;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 2) {
// Second crack
var crackedEgg2 = LK.getAsset('crackedEgg2', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg2.x = fallingEgg.x;
crackedEgg2.y = fallingEgg.y;
game.addChild(crackedEgg2);
fallingEgg.destroy();
fallingEgg = crackedEgg2;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 3) {
// Third crack - almost fully cracked
var crackedEgg3 = LK.getAsset('crackedEgg3', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg3.x = fallingEgg.x;
crackedEgg3.y = fallingEgg.y;
game.addChild(crackedEgg3);
fallingEgg.destroy();
fallingEgg = crackedEgg3;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 4) {
// Hatch the golden green egg with special probabilities
var availableGoldenGreenAnimals = [];
var goldenGreenAnimalTypes = ['goldenDinosaur', 'goldenBear', 'goldenBee'];
for (var typeIndex = 0; typeIndex < goldenGreenAnimalTypes.length; typeIndex++) {
var animalType = goldenGreenAnimalTypes[typeIndex];
var countInInventory = 0;
for (var invIndex = 0; invIndex < inventory.length; invIndex++) {
if (inventory[invIndex] === animalType) {
countInInventory++;
}
}
if (countInInventory < 3) {
availableGoldenGreenAnimals.push(animalType);
}
}
var animal;
if (availableGoldenGreenAnimals.length > 0) {
// Special probability distribution for golden green eggs (same as green)
var random = Math.random();
var selectedAnimal;
if (random < 0.05) {
selectedAnimal = 'goldenDinosaur'; // 5% chance
} else if (random < 0.2) {
selectedAnimal = 'goldenBear'; // 15% chance
} else {
selectedAnimal = 'goldenBee'; // 80% chance
}
// Check if selected animal is available
if (availableGoldenGreenAnimals.indexOf(selectedAnimal) !== -1) {
animal = selectedAnimal;
} else {
// If selected animal is not available, choose randomly from available
var randomIndex = Math.floor(Math.random() * availableGoldenGreenAnimals.length);
animal = availableGoldenGreenAnimals[randomIndex];
}
inventory.push(animal);
storage.inventory = inventory;
} else {
// All golden green animal types have 3 in inventory
animal = null;
var allGoldenGreenPetsText = new Text2('All golden green pets maxed out!', {
size: 60,
fill: 0xff0000
});
allGoldenGreenPetsText.anchor.set(0.5, 0.5);
allGoldenGreenPetsText.x = 2048 / 2;
allGoldenGreenPetsText.y = 1500;
game.addChild(allGoldenGreenPetsText);
LK.setTimeout(function () {
allGoldenGreenPetsText.destroy();
}, 2000);
}
// Only show hatched animal if we got a new pet
if (animal) {
var animalSprite = LK.getAsset(animal, {
anchorX: 0.5,
anchorY: 0.5
});
animalSprite.x = fallingEgg.x;
animalSprite.y = fallingEgg.y;
game.addChild(animalSprite);
// Remove animal after showing
LK.setTimeout(function () {
animalSprite.destroy();
}, 2000);
}
// Remove egg
fallingEgg.destroy();
fallingEgg = null;
}
};
}
};
// Handle red egg purchase
redEggItem.down = function () {
if (LK.getScore() >= 50000) {
LK.setScore(LK.getScore() - 50000);
scoreTxt.setText(LK.getScore().toString());
// Close shop
shopOverlay.destroy();
shopOverlay = null;
isShopOpen = false;
// Create falling red egg
fallingEgg = LK.getAsset('redEgg', {
anchorX: 0.5,
anchorY: 0.5
});
fallingEgg.x = 2048 / 2;
fallingEgg.y = -200;
eggClickCount = 0;
game.addChild(fallingEgg);
// Animate egg falling
tween(fallingEgg, {
y: 2732 / 2
}, {
duration: 1000
});
// Handle red egg clicking
fallingEgg.down = function () {
eggClickCount++;
if (eggClickCount === 1) {
// First crack
var crackedEgg1 = LK.getAsset('crackedEgg1', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg1.x = fallingEgg.x;
crackedEgg1.y = fallingEgg.y;
game.addChild(crackedEgg1);
fallingEgg.destroy();
fallingEgg = crackedEgg1;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 2) {
// Second crack
var crackedEgg2 = LK.getAsset('crackedEgg2', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg2.x = fallingEgg.x;
crackedEgg2.y = fallingEgg.y;
game.addChild(crackedEgg2);
fallingEgg.destroy();
fallingEgg = crackedEgg2;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 3) {
// Third crack - almost fully cracked
var crackedEgg3 = LK.getAsset('crackedEgg3', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg3.x = fallingEgg.x;
crackedEgg3.y = fallingEgg.y;
game.addChild(crackedEgg3);
fallingEgg.destroy();
fallingEgg = crackedEgg3;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 4) {
// Hatch the red egg with special probabilities
var availableRedAnimals = [];
var redAnimalTypes = ['trex', 'velector', 'titanaBull'];
for (var typeIndex = 0; typeIndex < redAnimalTypes.length; typeIndex++) {
var animalType = redAnimalTypes[typeIndex];
var countInInventory = 0;
for (var invIndex = 0; invIndex < inventory.length; invIndex++) {
if (inventory[invIndex] === animalType) {
countInInventory++;
}
}
if (countInInventory < 3) {
availableRedAnimals.push(animalType);
}
}
var animal;
if (availableRedAnimals.length > 0) {
// Special probability distribution for red eggs
var random = Math.random();
var selectedAnimal;
if (random < 0.05) {
selectedAnimal = 'trex'; // 5% chance
} else if (random < 0.3) {
selectedAnimal = 'velector'; // 25% chance
} else {
selectedAnimal = 'titanaBull'; // 70% chance
}
// Check if selected animal is available
if (availableRedAnimals.indexOf(selectedAnimal) !== -1) {
animal = selectedAnimal;
} else {
// If selected animal is not available, choose randomly from available
var randomIndex = Math.floor(Math.random() * availableRedAnimals.length);
animal = availableRedAnimals[randomIndex];
}
inventory.push(animal);
storage.inventory = inventory;
} else {
// All red animal types have 3 in inventory
animal = null;
var allRedPetsText = new Text2('All red pets maxed out!', {
size: 60,
fill: 0xff0000
});
allRedPetsText.anchor.set(0.5, 0.5);
allRedPetsText.x = 2048 / 2;
allRedPetsText.y = 1500;
game.addChild(allRedPetsText);
LK.setTimeout(function () {
allRedPetsText.destroy();
}, 2000);
}
// Only show hatched animal if we got a new pet
if (animal) {
var animalSprite = LK.getAsset(animal, {
anchorX: 0.5,
anchorY: 0.5
});
animalSprite.x = fallingEgg.x;
animalSprite.y = fallingEgg.y;
game.addChild(animalSprite);
// Remove animal after showing
LK.setTimeout(function () {
animalSprite.destroy();
}, 2000);
}
// Remove egg
fallingEgg.destroy();
fallingEgg = null;
}
};
}
};
// Handle golden red egg purchase
goldenRedEggItem.down = function () {
if (LK.getScore() >= 100000) {
LK.setScore(LK.getScore() - 100000);
scoreTxt.setText(LK.getScore().toString());
// Close shop
shopOverlay.destroy();
shopOverlay = null;
isShopOpen = false;
// Create falling golden red egg
fallingEgg = LK.getAsset('goldenRedEgg', {
anchorX: 0.5,
anchorY: 0.5
});
fallingEgg.x = 2048 / 2;
fallingEgg.y = -200;
eggClickCount = 0;
game.addChild(fallingEgg);
// Animate egg falling
tween(fallingEgg, {
y: 2732 / 2
}, {
duration: 1000
});
// Handle golden red egg clicking
fallingEgg.down = function () {
eggClickCount++;
if (eggClickCount === 1) {
// First crack
var crackedEgg1 = LK.getAsset('crackedEgg1', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg1.x = fallingEgg.x;
crackedEgg1.y = fallingEgg.y;
game.addChild(crackedEgg1);
fallingEgg.destroy();
fallingEgg = crackedEgg1;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 2) {
// Second crack
var crackedEgg2 = LK.getAsset('crackedEgg2', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg2.x = fallingEgg.x;
crackedEgg2.y = fallingEgg.y;
game.addChild(crackedEgg2);
fallingEgg.destroy();
fallingEgg = crackedEgg2;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 3) {
// Third crack - almost fully cracked
var crackedEgg3 = LK.getAsset('crackedEgg3', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg3.x = fallingEgg.x;
crackedEgg3.y = fallingEgg.y;
game.addChild(crackedEgg3);
fallingEgg.destroy();
fallingEgg = crackedEgg3;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 4) {
// Hatch the golden red egg with special probabilities
var availableGoldenRedAnimals = [];
var goldenRedAnimalTypes = ['goldenTrex', 'goldenVelector', 'goldenTitanaBull'];
for (var typeIndex = 0; typeIndex < goldenRedAnimalTypes.length; typeIndex++) {
var animalType = goldenRedAnimalTypes[typeIndex];
var countInInventory = 0;
for (var invIndex = 0; invIndex < inventory.length; invIndex++) {
if (inventory[invIndex] === animalType) {
countInInventory++;
}
}
if (countInInventory < 3) {
availableGoldenRedAnimals.push(animalType);
}
}
var animal;
if (availableGoldenRedAnimals.length > 0) {
// Special probability distribution for golden red eggs (same as red)
var random = Math.random();
var selectedAnimal;
if (random < 0.05) {
selectedAnimal = 'goldenTrex'; // 5% chance
} else if (random < 0.3) {
selectedAnimal = 'goldenVelector'; // 25% chance
} else {
selectedAnimal = 'goldenTitanaBull'; // 70% chance
}
// Check if selected animal is available
if (availableGoldenRedAnimals.indexOf(selectedAnimal) !== -1) {
animal = selectedAnimal;
} else {
// If selected animal is not available, choose randomly from available
var randomIndex = Math.floor(Math.random() * availableGoldenRedAnimals.length);
animal = availableGoldenRedAnimals[randomIndex];
}
inventory.push(animal);
storage.inventory = inventory;
} else {
// All golden red animal types have 3 in inventory
animal = null;
var allGoldenRedPetsText = new Text2('All golden red pets maxed out!', {
size: 60,
fill: 0xff0000
});
allGoldenRedPetsText.anchor.set(0.5, 0.5);
allGoldenRedPetsText.x = 2048 / 2;
allGoldenRedPetsText.y = 1500;
game.addChild(allGoldenRedPetsText);
LK.setTimeout(function () {
allGoldenRedPetsText.destroy();
}, 2000);
}
// Only show hatched animal if we got a new pet
if (animal) {
var animalSprite = LK.getAsset(animal, {
anchorX: 0.5,
anchorY: 0.5
});
animalSprite.x = fallingEgg.x;
animalSprite.y = fallingEgg.y;
game.addChild(animalSprite);
// Remove animal after showing
LK.setTimeout(function () {
animalSprite.destroy();
}, 2000);
}
// Remove egg
fallingEgg.destroy();
fallingEgg = null;
}
};
}
};
// Handle purple egg purchase
purpleEggItem.down = function () {
if (LK.getScore() >= 1250000) {
LK.setScore(LK.getScore() - 1250000);
scoreTxt.setText(LK.getScore().toString());
// Close shop
shopOverlay.destroy();
shopOverlay = null;
isShopOpen = false;
// Create falling purple egg
fallingEgg = LK.getAsset('purpleEgg', {
anchorX: 0.5,
anchorY: 0.5
});
fallingEgg.x = 2048 / 2;
fallingEgg.y = -200;
eggClickCount = 0;
game.addChild(fallingEgg);
// Animate egg falling
tween(fallingEgg, {
y: 2732 / 2
}, {
duration: 1000
});
// Handle purple egg clicking
fallingEgg.down = function () {
eggClickCount++;
if (eggClickCount === 1) {
// First crack
var crackedEgg1 = LK.getAsset('crackedEgg1', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg1.x = fallingEgg.x;
crackedEgg1.y = fallingEgg.y;
game.addChild(crackedEgg1);
fallingEgg.destroy();
fallingEgg = crackedEgg1;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 2) {
// Second crack
var crackedEgg2 = LK.getAsset('crackedEgg2', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg2.x = fallingEgg.x;
crackedEgg2.y = fallingEgg.y;
game.addChild(crackedEgg2);
fallingEgg.destroy();
fallingEgg = crackedEgg2;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 3) {
// Third crack - almost fully cracked
var crackedEgg3 = LK.getAsset('crackedEgg3', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg3.x = fallingEgg.x;
crackedEgg3.y = fallingEgg.y;
game.addChild(crackedEgg3);
fallingEgg.destroy();
fallingEgg = crackedEgg3;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 4) {
// Hatch the purple egg with special probabilities
var availablePurpleAnimals = [];
var purpleAnimalTypes = ['ironMan', 'captainAmerica', 'spiderman'];
for (var typeIndex = 0; typeIndex < purpleAnimalTypes.length; typeIndex++) {
var animalType = purpleAnimalTypes[typeIndex];
var countInInventory = 0;
for (var invIndex = 0; invIndex < inventory.length; invIndex++) {
if (inventory[invIndex] === animalType) {
countInInventory++;
}
}
if (countInInventory < 3) {
availablePurpleAnimals.push(animalType);
}
}
var animal;
if (availablePurpleAnimals.length > 0) {
// Special probability distribution for purple eggs
var random = Math.random();
var selectedAnimal;
if (random < 0.01) {
selectedAnimal = 'ironMan'; // 1% chance
} else if (random < 0.15) {
selectedAnimal = 'captainAmerica'; // 14% chance
} else {
selectedAnimal = 'spiderman'; // 85% chance
}
// Check if selected animal is available
if (availablePurpleAnimals.indexOf(selectedAnimal) !== -1) {
animal = selectedAnimal;
} else {
// If selected animal is not available, choose randomly from available
var randomIndex = Math.floor(Math.random() * availablePurpleAnimals.length);
animal = availablePurpleAnimals[randomIndex];
}
inventory.push(animal);
storage.inventory = inventory;
} else {
// All purple animal types have 3 in inventory
animal = null;
var allPurplePetsText = new Text2('All purple pets maxed out!', {
size: 60,
fill: 0xff0000
});
allPurplePetsText.anchor.set(0.5, 0.5);
allPurplePetsText.x = 2048 / 2;
allPurplePetsText.y = 1500;
game.addChild(allPurplePetsText);
LK.setTimeout(function () {
allPurplePetsText.destroy();
}, 2000);
}
// Only show hatched animal if we got a new pet
if (animal) {
var animalSprite = LK.getAsset(animal, {
anchorX: 0.5,
anchorY: 0.5
});
animalSprite.x = fallingEgg.x;
animalSprite.y = fallingEgg.y;
game.addChild(animalSprite);
// Remove animal after showing
LK.setTimeout(function () {
animalSprite.destroy();
}, 2000);
}
// Remove egg
fallingEgg.destroy();
fallingEgg = null;
}
};
}
};
// Handle golden purple egg purchase
goldenPurpleEggItem.down = function () {
if (LK.getScore() >= 2500000) {
LK.setScore(LK.getScore() - 2500000);
scoreTxt.setText(LK.getScore().toString());
// Close shop
shopOverlay.destroy();
shopOverlay = null;
isShopOpen = false;
// Create falling golden purple egg
fallingEgg = LK.getAsset('goldenPurpleEgg', {
anchorX: 0.5,
anchorY: 0.5
});
fallingEgg.x = 2048 / 2;
fallingEgg.y = -200;
eggClickCount = 0;
game.addChild(fallingEgg);
// Animate egg falling
tween(fallingEgg, {
y: 2732 / 2
}, {
duration: 1000
});
// Handle golden purple egg clicking
fallingEgg.down = function () {
eggClickCount++;
if (eggClickCount === 1) {
// First crack
var crackedEgg1 = LK.getAsset('crackedEgg1', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg1.x = fallingEgg.x;
crackedEgg1.y = fallingEgg.y;
game.addChild(crackedEgg1);
fallingEgg.destroy();
fallingEgg = crackedEgg1;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 2) {
// Second crack
var crackedEgg2 = LK.getAsset('crackedEgg2', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg2.x = fallingEgg.x;
crackedEgg2.y = fallingEgg.y;
game.addChild(crackedEgg2);
fallingEgg.destroy();
fallingEgg = crackedEgg2;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 3) {
// Third crack - almost fully cracked
var crackedEgg3 = LK.getAsset('crackedEgg3', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg3.x = fallingEgg.x;
crackedEgg3.y = fallingEgg.y;
game.addChild(crackedEgg3);
fallingEgg.destroy();
fallingEgg = crackedEgg3;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 4) {
// Hatch the golden purple egg with special probabilities
var availableGoldenPurpleAnimals = [];
var goldenPurpleAnimalTypes = ['goldenIronMan', 'goldenCaptainAmerica', 'goldenSpiderman'];
for (var typeIndex = 0; typeIndex < goldenPurpleAnimalTypes.length; typeIndex++) {
var animalType = goldenPurpleAnimalTypes[typeIndex];
var countInInventory = 0;
for (var invIndex = 0; invIndex < inventory.length; invIndex++) {
if (inventory[invIndex] === animalType) {
countInInventory++;
}
}
if (countInInventory < 3) {
availableGoldenPurpleAnimals.push(animalType);
}
}
var animal;
if (availableGoldenPurpleAnimals.length > 0) {
// Special probability distribution for golden purple eggs (same as purple)
var random = Math.random();
var selectedAnimal;
if (random < 0.01) {
selectedAnimal = 'goldenIronMan'; // 1% chance
} else if (random < 0.15) {
selectedAnimal = 'goldenCaptainAmerica'; // 14% chance
} else {
selectedAnimal = 'goldenSpiderman'; // 85% chance
}
// Check if selected animal is available
if (availableGoldenPurpleAnimals.indexOf(selectedAnimal) !== -1) {
animal = selectedAnimal;
} else {
// If selected animal is not available, choose randomly from available
var randomIndex = Math.floor(Math.random() * availableGoldenPurpleAnimals.length);
animal = availableGoldenPurpleAnimals[randomIndex];
}
inventory.push(animal);
storage.inventory = inventory;
} else {
// All golden purple animal types have 3 in inventory
animal = null;
var allGoldenPurplePetsText = new Text2('All golden purple pets maxed out!', {
size: 60,
fill: 0xff0000
});
allGoldenPurplePetsText.anchor.set(0.5, 0.5);
allGoldenPurplePetsText.x = 2048 / 2;
allGoldenPurplePetsText.y = 1500;
game.addChild(allGoldenPurplePetsText);
LK.setTimeout(function () {
allGoldenPurplePetsText.destroy();
}, 2000);
}
// Only show hatched animal if we got a new pet
if (animal) {
var animalSprite = LK.getAsset(animal, {
anchorX: 0.5,
anchorY: 0.5
});
animalSprite.x = fallingEgg.x;
animalSprite.y = fallingEgg.y;
game.addChild(animalSprite);
// Remove animal after showing
LK.setTimeout(function () {
animalSprite.destroy();
}, 2000);
}
// Remove egg
fallingEgg.destroy();
fallingEgg = null;
}
};
}
};
// Handle white egg purchase
whiteEggItem.down = function () {
if (LK.getScore() >= 10000000) {
LK.setScore(LK.getScore() - 10000000);
scoreTxt.setText(LK.getScore().toString());
// Close shop
shopOverlay.destroy();
shopOverlay = null;
isShopOpen = false;
// Create falling white egg
fallingEgg = LK.getAsset('whiteEgg', {
anchorX: 0.5,
anchorY: 0.5
});
fallingEgg.x = 2048 / 2;
fallingEgg.y = -200;
eggClickCount = 0;
game.addChild(fallingEgg);
// Animate egg falling
tween(fallingEgg, {
y: 2732 / 2
}, {
duration: 1000
});
// Handle white egg clicking
fallingEgg.down = function () {
eggClickCount++;
if (eggClickCount === 1) {
// First crack
var crackedEgg1 = LK.getAsset('crackedEgg1', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg1.x = fallingEgg.x;
crackedEgg1.y = fallingEgg.y;
game.addChild(crackedEgg1);
fallingEgg.destroy();
fallingEgg = crackedEgg1;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 2) {
// Second crack
var crackedEgg2 = LK.getAsset('crackedEgg2', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg2.x = fallingEgg.x;
crackedEgg2.y = fallingEgg.y;
game.addChild(crackedEgg2);
fallingEgg.destroy();
fallingEgg = crackedEgg2;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 3) {
// Third crack - almost fully cracked
var crackedEgg3 = LK.getAsset('crackedEgg3', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg3.x = fallingEgg.x;
crackedEgg3.y = fallingEgg.y;
game.addChild(crackedEgg3);
fallingEgg.destroy();
fallingEgg = crackedEgg3;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 4) {
// Hatch the white egg with special probabilities
var availableWhiteAnimals = [];
var whiteAnimalTypes = ['king', 'knight', 'human'];
for (var typeIndex = 0; typeIndex < whiteAnimalTypes.length; typeIndex++) {
var animalType = whiteAnimalTypes[typeIndex];
var countInInventory = 0;
for (var invIndex = 0; invIndex < inventory.length; invIndex++) {
if (inventory[invIndex] === animalType) {
countInInventory++;
}
}
if (countInInventory < 3) {
availableWhiteAnimals.push(animalType);
}
}
var animal;
if (availableWhiteAnimals.length > 0) {
// Special probability distribution for white eggs
var random = Math.random();
var selectedAnimal;
if (random < 0.005) {
selectedAnimal = 'king'; // 0.5% chance
} else if (random < 0.055) {
selectedAnimal = 'knight'; // 5% chance
} else {
selectedAnimal = 'human'; // 94.5% chance
}
// Check if selected animal is available
if (availableWhiteAnimals.indexOf(selectedAnimal) !== -1) {
animal = selectedAnimal;
} else {
// If selected animal is not available, choose randomly from available
var randomIndex = Math.floor(Math.random() * availableWhiteAnimals.length);
animal = availableWhiteAnimals[randomIndex];
}
inventory.push(animal);
storage.inventory = inventory;
} else {
// All white animal types have 3 in inventory
animal = null;
var allWhitePetsText = new Text2('All white pets maxed out!', {
size: 60,
fill: 0xff0000
});
allWhitePetsText.anchor.set(0.5, 0.5);
allWhitePetsText.x = 2048 / 2;
allWhitePetsText.y = 1500;
game.addChild(allWhitePetsText);
LK.setTimeout(function () {
allWhitePetsText.destroy();
}, 2000);
}
// Only show hatched animal if we got a new pet
if (animal) {
var animalSprite = LK.getAsset(animal, {
anchorX: 0.5,
anchorY: 0.5
});
animalSprite.x = fallingEgg.x;
animalSprite.y = fallingEgg.y;
game.addChild(animalSprite);
// Remove animal after showing
LK.setTimeout(function () {
animalSprite.destroy();
}, 2000);
}
// Remove egg
fallingEgg.destroy();
fallingEgg = null;
}
};
}
};
// Handle golden white egg purchase
goldenWhiteEggItem.down = function () {
if (LK.getScore() >= 20000000) {
LK.setScore(LK.getScore() - 20000000);
scoreTxt.setText(LK.getScore().toString());
// Close shop
shopOverlay.destroy();
shopOverlay = null;
isShopOpen = false;
// Create falling golden white egg
fallingEgg = LK.getAsset('goldenWhiteEgg', {
anchorX: 0.5,
anchorY: 0.5
});
fallingEgg.x = 2048 / 2;
fallingEgg.y = -200;
eggClickCount = 0;
game.addChild(fallingEgg);
// Animate egg falling
tween(fallingEgg, {
y: 2732 / 2
}, {
duration: 1000
});
// Handle golden white egg clicking
fallingEgg.down = function () {
eggClickCount++;
if (eggClickCount === 1) {
// First crack
var crackedEgg1 = LK.getAsset('crackedEgg1', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg1.x = fallingEgg.x;
crackedEgg1.y = fallingEgg.y;
game.addChild(crackedEgg1);
fallingEgg.destroy();
fallingEgg = crackedEgg1;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 2) {
// Second crack
var crackedEgg2 = LK.getAsset('crackedEgg2', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg2.x = fallingEgg.x;
crackedEgg2.y = fallingEgg.y;
game.addChild(crackedEgg2);
fallingEgg.destroy();
fallingEgg = crackedEgg2;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 3) {
// Third crack - almost fully cracked
var crackedEgg3 = LK.getAsset('crackedEgg3', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg3.x = fallingEgg.x;
crackedEgg3.y = fallingEgg.y;
game.addChild(crackedEgg3);
fallingEgg.destroy();
fallingEgg = crackedEgg3;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 4) {
// Hatch the golden white egg with special probabilities
var availableGoldenWhiteAnimals = [];
var goldenWhiteAnimalTypes = ['goldenKing', 'goldenKnight', 'goldenHuman'];
for (var typeIndex = 0; typeIndex < goldenWhiteAnimalTypes.length; typeIndex++) {
var animalType = goldenWhiteAnimalTypes[typeIndex];
var countInInventory = 0;
for (var invIndex = 0; invIndex < inventory.length; invIndex++) {
if (inventory[invIndex] === animalType) {
countInInventory++;
}
}
if (countInInventory < 3) {
availableGoldenWhiteAnimals.push(animalType);
}
}
var animal;
if (availableGoldenWhiteAnimals.length > 0) {
// Special probability distribution for golden white eggs (same as white)
var random = Math.random();
var selectedAnimal;
if (random < 0.005) {
selectedAnimal = 'goldenKing'; // 0.5% chance
} else if (random < 0.055) {
selectedAnimal = 'goldenKnight'; // 5% chance
} else {
selectedAnimal = 'goldenHuman'; // 94.5% chance
}
// Check if selected animal is available
if (availableGoldenWhiteAnimals.indexOf(selectedAnimal) !== -1) {
animal = selectedAnimal;
} else {
// If selected animal is not available, choose randomly from available
var randomIndex = Math.floor(Math.random() * availableGoldenWhiteAnimals.length);
animal = availableGoldenWhiteAnimals[randomIndex];
}
inventory.push(animal);
storage.inventory = inventory;
} else {
// All golden white animal types have 3 in inventory
animal = null;
var allGoldenWhitePetsText = new Text2('All golden white pets maxed out!', {
size: 60,
fill: 0xff0000
});
allGoldenWhitePetsText.anchor.set(0.5, 0.5);
allGoldenWhitePetsText.x = 2048 / 2;
allGoldenWhitePetsText.y = 1500;
game.addChild(allGoldenWhitePetsText);
LK.setTimeout(function () {
allGoldenWhitePetsText.destroy();
}, 2000);
}
// Only show hatched animal if we got a new pet
if (animal) {
var animalSprite = LK.getAsset(animal, {
anchorX: 0.5,
anchorY: 0.5
});
animalSprite.x = fallingEgg.x;
animalSprite.y = fallingEgg.y;
game.addChild(animalSprite);
// Remove animal after showing
LK.setTimeout(function () {
animalSprite.destroy();
}, 2000);
}
// Remove egg
fallingEgg.destroy();
fallingEgg = null;
}
};
}
};
// Handle golden egg purchase
goldenEggItem.down = function () {
if (LK.getScore() >= 10000) {
LK.setScore(LK.getScore() - 10000);
scoreTxt.setText(LK.getScore().toString());
// Close shop
shopOverlay.destroy();
shopOverlay = null;
isShopOpen = false;
// Create falling golden egg
fallingEgg = LK.getAsset('goldenEgg', {
anchorX: 0.5,
anchorY: 0.5
});
fallingEgg.x = 2048 / 2;
fallingEgg.y = -200;
eggClickCount = 0;
game.addChild(fallingEgg);
// Animate egg falling
tween(fallingEgg, {
y: 2732 / 2
}, {
duration: 1000
});
// Handle golden egg clicking
fallingEgg.down = function () {
eggClickCount++;
if (eggClickCount === 1) {
// First crack
var crackedEgg1 = LK.getAsset('crackedEgg1', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg1.x = fallingEgg.x;
crackedEgg1.y = fallingEgg.y;
game.addChild(crackedEgg1);
fallingEgg.destroy();
fallingEgg = crackedEgg1;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 2) {
// Second crack
var crackedEgg2 = LK.getAsset('crackedEgg2', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg2.x = fallingEgg.x;
crackedEgg2.y = fallingEgg.y;
game.addChild(crackedEgg2);
fallingEgg.destroy();
fallingEgg = crackedEgg2;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 3) {
// Third crack - almost fully cracked
var crackedEgg3 = LK.getAsset('crackedEgg3', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg3.x = fallingEgg.x;
crackedEgg3.y = fallingEgg.y;
game.addChild(crackedEgg3);
fallingEgg.destroy();
fallingEgg = crackedEgg3;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 4) {
// Hatch the golden egg with special probabilities
var availableGoldenAnimals = [];
var goldenAnimalTypes = ['goldenDog', 'goldenCat', 'goldenSnake'];
for (var typeIndex = 0; typeIndex < goldenAnimalTypes.length; typeIndex++) {
var animalType = goldenAnimalTypes[typeIndex];
var countInInventory = 0;
for (var invIndex = 0; invIndex < inventory.length; invIndex++) {
if (inventory[invIndex] === animalType) {
countInInventory++;
}
}
if (countInInventory < 3) {
availableGoldenAnimals.push(animalType);
}
}
var animal;
if (availableGoldenAnimals.length > 0) {
// Special probability distribution for golden eggs
var random = Math.random();
var selectedAnimal;
if (random < 0.6) {
selectedAnimal = 'goldenDog'; // 60% chance
} else if (random < 0.9) {
selectedAnimal = 'goldenCat'; // 30% chance
} else {
selectedAnimal = 'goldenSnake'; // 10% chance
}
// Check if selected animal is available
if (availableGoldenAnimals.indexOf(selectedAnimal) !== -1) {
animal = selectedAnimal;
} else {
// If selected animal is not available, choose randomly from available
var randomIndex = Math.floor(Math.random() * availableGoldenAnimals.length);
animal = availableGoldenAnimals[randomIndex];
}
inventory.push(animal);
storage.inventory = inventory;
} else {
// All golden animal types have 3 in inventory
animal = null;
var allGoldenPetsText = new Text2('All golden pets maxed out!', {
size: 60,
fill: 0xff0000
});
allGoldenPetsText.anchor.set(0.5, 0.5);
allGoldenPetsText.x = 2048 / 2;
allGoldenPetsText.y = 1500;
game.addChild(allGoldenPetsText);
LK.setTimeout(function () {
allGoldenPetsText.destroy();
}, 2000);
}
// Only show hatched animal if we got a new pet
if (animal) {
var animalSprite = LK.getAsset(animal, {
anchorX: 0.5,
anchorY: 0.5
});
animalSprite.x = fallingEgg.x;
animalSprite.y = fallingEgg.y;
game.addChild(animalSprite);
// Remove animal after showing
LK.setTimeout(function () {
animalSprite.destroy();
}, 2000);
}
// Remove egg
fallingEgg.destroy();
fallingEgg = null;
}
};
}
};
// Handle space egg purchase
spaceEggItem.down = function () {
if (LK.getScore() >= 100000000) {
LK.setScore(LK.getScore() - 100000000);
scoreTxt.setText(LK.getScore().toString());
// Close shop
shopOverlay.destroy();
shopOverlay = null;
isShopOpen = false;
// Create falling space egg
fallingEgg = LK.getAsset('spaceEgg', {
anchorX: 0.5,
anchorY: 0.5
});
fallingEgg.x = 2048 / 2;
fallingEgg.y = -200;
eggClickCount = 0;
game.addChild(fallingEgg);
// Animate egg falling
tween(fallingEgg, {
y: 2732 / 2
}, {
duration: 1000
});
// Handle space egg clicking
fallingEgg.down = function () {
eggClickCount++;
if (eggClickCount === 1) {
// First crack
var crackedEgg1 = LK.getAsset('crackedEgg1', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg1.x = fallingEgg.x;
crackedEgg1.y = fallingEgg.y;
game.addChild(crackedEgg1);
fallingEgg.destroy();
fallingEgg = crackedEgg1;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 2) {
// Second crack
var crackedEgg2 = LK.getAsset('crackedEgg2', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg2.x = fallingEgg.x;
crackedEgg2.y = fallingEgg.y;
game.addChild(crackedEgg2);
fallingEgg.destroy();
fallingEgg = crackedEgg2;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 3) {
// Third crack - almost fully cracked
var crackedEgg3 = LK.getAsset('crackedEgg3', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg3.x = fallingEgg.x;
crackedEgg3.y = fallingEgg.y;
game.addChild(crackedEgg3);
fallingEgg.destroy();
fallingEgg = crackedEgg3;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 4) {
// Hatch the space egg with special probabilities
var availableSpaceAnimals = [];
var spaceAnimalTypes = ['earth', 'moon', 'meteor'];
for (var typeIndex = 0; typeIndex < spaceAnimalTypes.length; typeIndex++) {
var animalType = spaceAnimalTypes[typeIndex];
var countInInventory = 0;
for (var invIndex = 0; invIndex < inventory.length; invIndex++) {
if (inventory[invIndex] === animalType) {
countInInventory++;
}
}
if (countInInventory < 3) {
availableSpaceAnimals.push(animalType);
}
}
var animal;
if (availableSpaceAnimals.length > 0) {
// Special probability distribution for space eggs
var random = Math.random();
var selectedAnimal;
if (random < 0.001) {
selectedAnimal = 'earth'; // 0.1% chance
} else if (random < 0.011) {
selectedAnimal = 'moon'; // 1% chance
} else {
selectedAnimal = 'meteor'; // 98.9% chance
}
// Check if selected animal is available
if (availableSpaceAnimals.indexOf(selectedAnimal) !== -1) {
animal = selectedAnimal;
} else {
// If selected animal is not available, choose randomly from available
var randomIndex = Math.floor(Math.random() * availableSpaceAnimals.length);
animal = availableSpaceAnimals[randomIndex];
}
inventory.push(animal);
storage.inventory = inventory;
} else {
// All space animal types have 3 in inventory
animal = null;
var allSpacePetsText = new Text2('All space pets maxed out!', {
size: 60,
fill: 0xff0000
});
allSpacePetsText.anchor.set(0.5, 0.5);
allSpacePetsText.x = 2048 / 2;
allSpacePetsText.y = 1500;
game.addChild(allSpacePetsText);
LK.setTimeout(function () {
allSpacePetsText.destroy();
}, 2000);
}
// Only show hatched animal if we got a new pet
if (animal) {
var animalSprite = LK.getAsset(animal, {
anchorX: 0.5,
anchorY: 0.5
});
animalSprite.x = fallingEgg.x;
animalSprite.y = fallingEgg.y;
game.addChild(animalSprite);
// Remove animal after showing
LK.setTimeout(function () {
animalSprite.destroy();
}, 2000);
}
// Remove egg
fallingEgg.destroy();
fallingEgg = null;
}
};
}
};
// Handle space2 egg purchase
space2EggItem.down = function () {
if (LK.getScore() >= 200000000) {
LK.setScore(LK.getScore() - 200000000);
scoreTxt.setText(LK.getScore().toString());
// Close shop
shopOverlay.destroy();
shopOverlay = null;
isShopOpen = false;
// Create falling space2 egg
fallingEgg = LK.getAsset('space2Egg', {
anchorX: 0.5,
anchorY: 0.5
});
fallingEgg.x = 2048 / 2;
fallingEgg.y = -200;
eggClickCount = 0;
game.addChild(fallingEgg);
// Animate egg falling
tween(fallingEgg, {
y: 2732 / 2
}, {
duration: 1000
});
// Handle space2 egg clicking
fallingEgg.down = function () {
eggClickCount++;
if (eggClickCount === 1) {
// First crack
var crackedEgg1 = LK.getAsset('crackedEgg1', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg1.x = fallingEgg.x;
crackedEgg1.y = fallingEgg.y;
game.addChild(crackedEgg1);
fallingEgg.destroy();
fallingEgg = crackedEgg1;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 2) {
// Second crack
var crackedEgg2 = LK.getAsset('crackedEgg2', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg2.x = fallingEgg.x;
crackedEgg2.y = fallingEgg.y;
game.addChild(crackedEgg2);
fallingEgg.destroy();
fallingEgg = crackedEgg2;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 3) {
// Third crack - almost fully cracked
var crackedEgg3 = LK.getAsset('crackedEgg3', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg3.x = fallingEgg.x;
crackedEgg3.y = fallingEgg.y;
game.addChild(crackedEgg3);
fallingEgg.destroy();
fallingEgg = crackedEgg3;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 4) {
// Hatch the space2 egg with special probabilities
var availableSpace2Animals = [];
var space2AnimalTypes = ['sun', 'jupiter', 'neptune'];
for (var typeIndex = 0; typeIndex < space2AnimalTypes.length; typeIndex++) {
var animalType = space2AnimalTypes[typeIndex];
var countInInventory = 0;
for (var invIndex = 0; invIndex < inventory.length; invIndex++) {
if (inventory[invIndex] === animalType) {
countInInventory++;
}
}
if (countInInventory < 3) {
availableSpace2Animals.push(animalType);
}
}
var animal;
if (availableSpace2Animals.length > 0) {
// Special probability distribution for space2 eggs
var random = Math.random();
var selectedAnimal;
if (random < 0.0001) {
selectedAnimal = 'sun'; // 0.01% chance
} else if (random < 0.0011) {
selectedAnimal = 'jupiter'; // 0.1% chance
} else {
selectedAnimal = 'neptune'; // 99.9% chance
}
// Check if selected animal is available
if (availableSpace2Animals.indexOf(selectedAnimal) !== -1) {
animal = selectedAnimal;
} else {
// If selected animal is not available, choose randomly from available
var randomIndex = Math.floor(Math.random() * availableSpace2Animals.length);
animal = availableSpace2Animals[randomIndex];
}
inventory.push(animal);
storage.inventory = inventory;
} else {
// All space2 animal types have 3 in inventory
animal = null;
var allSpace2PetsText = new Text2('All space2 pets maxed out!', {
size: 60,
fill: 0xff0000
});
allSpace2PetsText.anchor.set(0.5, 0.5);
allSpace2PetsText.x = 2048 / 2;
allSpace2PetsText.y = 1500;
game.addChild(allSpace2PetsText);
LK.setTimeout(function () {
allSpace2PetsText.destroy();
}, 2000);
}
// Only show hatched animal if we got a new pet
if (animal) {
var animalSprite = LK.getAsset(animal, {
anchorX: 0.5,
anchorY: 0.5
});
animalSprite.x = fallingEgg.x;
animalSprite.y = fallingEgg.y;
game.addChild(animalSprite);
// Remove animal after showing
LK.setTimeout(function () {
animalSprite.destroy();
}, 2000);
}
// Remove egg
fallingEgg.destroy();
fallingEgg = null;
}
};
}
};
// Handle golden space egg purchase
goldenSpaceEggItem.down = function () {
if (LK.getScore() >= 200000000) {
LK.setScore(LK.getScore() - 200000000);
scoreTxt.setText(LK.getScore().toString());
// Close shop
shopOverlay.destroy();
shopOverlay = null;
isShopOpen = false;
// Create falling golden space egg
fallingEgg = LK.getAsset('goldenSpaceEgg', {
anchorX: 0.5,
anchorY: 0.5
});
fallingEgg.x = 2048 / 2;
fallingEgg.y = -200;
eggClickCount = 0;
game.addChild(fallingEgg);
// Animate egg falling
tween(fallingEgg, {
y: 2732 / 2
}, {
duration: 1000
});
// Handle golden space egg clicking
fallingEgg.down = function () {
eggClickCount++;
if (eggClickCount === 1) {
// First crack
var crackedEgg1 = LK.getAsset('crackedEgg1', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg1.x = fallingEgg.x;
crackedEgg1.y = fallingEgg.y;
game.addChild(crackedEgg1);
fallingEgg.destroy();
fallingEgg = crackedEgg1;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 2) {
// Second crack
var crackedEgg2 = LK.getAsset('crackedEgg2', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg2.x = fallingEgg.x;
crackedEgg2.y = fallingEgg.y;
game.addChild(crackedEgg2);
fallingEgg.destroy();
fallingEgg = crackedEgg2;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 3) {
// Third crack - almost fully cracked
var crackedEgg3 = LK.getAsset('crackedEgg3', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg3.x = fallingEgg.x;
crackedEgg3.y = fallingEgg.y;
game.addChild(crackedEgg3);
fallingEgg.destroy();
fallingEgg = crackedEgg3;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 4) {
// Hatch the golden space egg with special probabilities
var availableGoldenSpaceAnimals = [];
var goldenSpaceAnimalTypes = ['goldenEarth', 'goldenMoon', 'goldenMeteor'];
for (var typeIndex = 0; typeIndex < goldenSpaceAnimalTypes.length; typeIndex++) {
var animalType = goldenSpaceAnimalTypes[typeIndex];
var countInInventory = 0;
for (var invIndex = 0; invIndex < inventory.length; invIndex++) {
if (inventory[invIndex] === animalType) {
countInInventory++;
}
}
if (countInInventory < 3) {
availableGoldenSpaceAnimals.push(animalType);
}
}
var animal;
if (availableGoldenSpaceAnimals.length > 0) {
// Special probability distribution for golden space eggs (same as space)
var random = Math.random();
var selectedAnimal;
if (random < 0.001) {
selectedAnimal = 'goldenEarth'; // 0.1% chance
} else if (random < 0.011) {
selectedAnimal = 'goldenMoon'; // 1% chance
} else {
selectedAnimal = 'goldenMeteor'; // 98.9% chance
}
// Check if selected animal is available
if (availableGoldenSpaceAnimals.indexOf(selectedAnimal) !== -1) {
animal = selectedAnimal;
} else {
// If selected animal is not available, choose randomly from available
var randomIndex = Math.floor(Math.random() * availableGoldenSpaceAnimals.length);
animal = availableGoldenSpaceAnimals[randomIndex];
}
inventory.push(animal);
storage.inventory = inventory;
} else {
// All golden space animal types have 3 in inventory
animal = null;
var allGoldenSpacePetsText = new Text2('All golden space pets maxed out!', {
size: 60,
fill: 0xff0000
});
allGoldenSpacePetsText.anchor.set(0.5, 0.5);
allGoldenSpacePetsText.x = 2048 / 2;
allGoldenSpacePetsText.y = 1500;
game.addChild(allGoldenSpacePetsText);
LK.setTimeout(function () {
allGoldenSpacePetsText.destroy();
}, 2000);
}
// Only show hatched animal if we got a new pet
if (animal) {
var animalSprite = LK.getAsset(animal, {
anchorX: 0.5,
anchorY: 0.5
});
animalSprite.x = fallingEgg.x;
animalSprite.y = fallingEgg.y;
game.addChild(animalSprite);
// Remove animal after showing
LK.setTimeout(function () {
animalSprite.destroy();
}, 2000);
}
// Remove egg
fallingEgg.destroy();
fallingEgg = null;
}
};
}
};
// Handle golden space2 egg purchase
goldenSpace2EggItem.down = function () {
if (LK.getScore() >= 400000000) {
LK.setScore(LK.getScore() - 400000000);
scoreTxt.setText(LK.getScore().toString());
// Close shop
shopOverlay.destroy();
shopOverlay = null;
isShopOpen = false;
// Create falling golden space2 egg
fallingEgg = LK.getAsset('goldenSpace2Egg', {
anchorX: 0.5,
anchorY: 0.5
});
fallingEgg.x = 2048 / 2;
fallingEgg.y = -200;
eggClickCount = 0;
game.addChild(fallingEgg);
// Animate egg falling
tween(fallingEgg, {
y: 2732 / 2
}, {
duration: 1000
});
// Handle golden space2 egg clicking
fallingEgg.down = function () {
eggClickCount++;
if (eggClickCount === 1) {
// First crack
var crackedEgg1 = LK.getAsset('crackedEgg1', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg1.x = fallingEgg.x;
crackedEgg1.y = fallingEgg.y;
game.addChild(crackedEgg1);
fallingEgg.destroy();
fallingEgg = crackedEgg1;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 2) {
// Second crack
var crackedEgg2 = LK.getAsset('crackedEgg2', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg2.x = fallingEgg.x;
crackedEgg2.y = fallingEgg.y;
game.addChild(crackedEgg2);
fallingEgg.destroy();
fallingEgg = crackedEgg2;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 3) {
// Third crack - almost fully cracked
var crackedEgg3 = LK.getAsset('crackedEgg3', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg3.x = fallingEgg.x;
crackedEgg3.y = fallingEgg.y;
game.addChild(crackedEgg3);
fallingEgg.destroy();
fallingEgg = crackedEgg3;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 4) {
// Hatch the golden space2 egg with special probabilities
var availableGoldenSpace2Animals = [];
var goldenSpace2AnimalTypes = ['goldenSun', 'goldenJupiter', 'goldenNeptune'];
for (var typeIndex = 0; typeIndex < goldenSpace2AnimalTypes.length; typeIndex++) {
var animalType = goldenSpace2AnimalTypes[typeIndex];
var countInInventory = 0;
for (var invIndex = 0; invIndex < inventory.length; invIndex++) {
if (inventory[invIndex] === animalType) {
countInInventory++;
}
}
if (countInInventory < 3) {
availableGoldenSpace2Animals.push(animalType);
}
}
var animal;
if (availableGoldenSpace2Animals.length > 0) {
// Special probability distribution for golden space2 eggs (same as space2)
var random = Math.random();
var selectedAnimal;
if (random < 0.0001) {
selectedAnimal = 'goldenSun'; // 0.01% chance
} else if (random < 0.0011) {
selectedAnimal = 'goldenJupiter'; // 0.1% chance
} else {
selectedAnimal = 'goldenNeptune'; // 99.9% chance
}
// Check if selected animal is available
if (availableGoldenSpace2Animals.indexOf(selectedAnimal) !== -1) {
animal = selectedAnimal;
} else {
// If selected animal is not available, choose randomly from available
var randomIndex = Math.floor(Math.random() * availableGoldenSpace2Animals.length);
animal = availableGoldenSpace2Animals[randomIndex];
}
inventory.push(animal);
storage.inventory = inventory;
} else {
// All golden space2 animal types have 3 in inventory
animal = null;
var allGoldenSpace2PetsText = new Text2('All golden space2 pets maxed out!', {
size: 60,
fill: 0xff0000
});
allGoldenSpace2PetsText.anchor.set(0.5, 0.5);
allGoldenSpace2PetsText.x = 2048 / 2;
allGoldenSpace2PetsText.y = 1500;
game.addChild(allGoldenSpace2PetsText);
LK.setTimeout(function () {
allGoldenSpace2PetsText.destroy();
}, 2000);
}
// Only show hatched animal if we got a new pet
if (animal) {
var animalSprite = LK.getAsset(animal, {
anchorX: 0.5,
anchorY: 0.5
});
animalSprite.x = fallingEgg.x;
animalSprite.y = fallingEgg.y;
game.addChild(animalSprite);
// Remove animal after showing
LK.setTimeout(function () {
animalSprite.destroy();
}, 2000);
}
// Remove egg
fallingEgg.destroy();
fallingEgg = null;
}
};
}
};
// Handle galaxy egg purchase
galaxyEggItem.down = function () {
if (LK.getScore() >= 500000000) {
LK.setScore(LK.getScore() - 500000000);
scoreTxt.setText(LK.getScore().toString());
// Close shop
shopOverlay.destroy();
shopOverlay = null;
isShopOpen = false;
// Create falling galaxy egg
fallingEgg = LK.getAsset('galaxyEgg', {
anchorX: 0.5,
anchorY: 0.5
});
fallingEgg.x = 2048 / 2;
fallingEgg.y = -200;
eggClickCount = 0;
game.addChild(fallingEgg);
// Animate egg falling
tween(fallingEgg, {
y: 2732 / 2
}, {
duration: 1000
});
// Handle galaxy egg clicking
fallingEgg.down = function () {
eggClickCount++;
if (eggClickCount === 1) {
// First crack
var crackedEgg1 = LK.getAsset('crackedEgg1', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg1.x = fallingEgg.x;
crackedEgg1.y = fallingEgg.y;
game.addChild(crackedEgg1);
fallingEgg.destroy();
fallingEgg = crackedEgg1;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 2) {
// Second crack
var crackedEgg2 = LK.getAsset('crackedEgg2', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg2.x = fallingEgg.x;
crackedEgg2.y = fallingEgg.y;
game.addChild(crackedEgg2);
fallingEgg.destroy();
fallingEgg = crackedEgg2;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 3) {
// Third crack - almost fully cracked
var crackedEgg3 = LK.getAsset('crackedEgg3', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg3.x = fallingEgg.x;
crackedEgg3.y = fallingEgg.y;
game.addChild(crackedEgg3);
fallingEgg.destroy();
fallingEgg = crackedEgg3;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 4) {
// Hatch the galaxy egg with special probabilities
var availableGalaxyAnimals = [];
var galaxyAnimalTypes = ['andromedaGalaxy', 'normalGalaxy', 'milkyWayGalaxy'];
for (var typeIndex = 0; typeIndex < galaxyAnimalTypes.length; typeIndex++) {
var animalType = galaxyAnimalTypes[typeIndex];
var countInInventory = 0;
for (var invIndex = 0; invIndex < inventory.length; invIndex++) {
if (inventory[invIndex] === animalType) {
countInInventory++;
}
}
if (countInInventory < 3) {
availableGalaxyAnimals.push(animalType);
}
}
var animal;
if (availableGalaxyAnimals.length > 0) {
// Special probability distribution for galaxy eggs
var random = Math.random();
var selectedAnimal;
if (random < 0.009) {
selectedAnimal = 'milkyWayGalaxy'; // 0.9% chance
} else if (random < 0.199) {
selectedAnimal = 'normalGalaxy'; // 19% chance
} else {
selectedAnimal = 'andromedaGalaxy'; // 80.1% chance
}
// Check if selected animal is available
if (availableGalaxyAnimals.indexOf(selectedAnimal) !== -1) {
animal = selectedAnimal;
} else {
// If selected animal is not available, choose randomly from available
var randomIndex = Math.floor(Math.random() * availableGalaxyAnimals.length);
animal = availableGalaxyAnimals[randomIndex];
}
inventory.push(animal);
storage.inventory = inventory;
} else {
// All galaxy animal types have 3 in inventory
animal = null;
var allGalaxyPetsText = new Text2('All galaxy pets maxed out!', {
size: 60,
fill: 0xff0000
});
allGalaxyPetsText.anchor.set(0.5, 0.5);
allGalaxyPetsText.x = 2048 / 2;
allGalaxyPetsText.y = 1500;
game.addChild(allGalaxyPetsText);
LK.setTimeout(function () {
allGalaxyPetsText.destroy();
}, 2000);
}
// Only show hatched animal if we got a new pet
if (animal) {
var animalSprite = LK.getAsset(animal, {
anchorX: 0.5,
anchorY: 0.5
});
animalSprite.x = fallingEgg.x;
animalSprite.y = fallingEgg.y;
game.addChild(animalSprite);
// Remove animal after showing
LK.setTimeout(function () {
animalSprite.destroy();
}, 2000);
}
// Remove egg
fallingEgg.destroy();
fallingEgg = null;
}
};
}
};
// Handle golden galaxy egg purchase
goldenGalaxyEggItem.down = function () {
if (LK.getScore() >= 1000000000) {
LK.setScore(LK.getScore() - 1000000000);
scoreTxt.setText(LK.getScore().toString());
// Close shop
shopOverlay.destroy();
shopOverlay = null;
isShopOpen = false;
// Create falling golden galaxy egg
fallingEgg = LK.getAsset('goldenGalaxyEgg', {
anchorX: 0.5,
anchorY: 0.5
});
fallingEgg.x = 2048 / 2;
fallingEgg.y = -200;
eggClickCount = 0;
game.addChild(fallingEgg);
// Animate egg falling
tween(fallingEgg, {
y: 2732 / 2
}, {
duration: 1000
});
// Handle golden galaxy egg clicking
fallingEgg.down = function () {
eggClickCount++;
if (eggClickCount === 1) {
// First crack
var crackedEgg1 = LK.getAsset('crackedEgg1', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg1.x = fallingEgg.x;
crackedEgg1.y = fallingEgg.y;
game.addChild(crackedEgg1);
fallingEgg.destroy();
fallingEgg = crackedEgg1;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 2) {
// Second crack
var crackedEgg2 = LK.getAsset('crackedEgg2', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg2.x = fallingEgg.x;
crackedEgg2.y = fallingEgg.y;
game.addChild(crackedEgg2);
fallingEgg.destroy();
fallingEgg = crackedEgg2;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 3) {
// Third crack - almost fully cracked
var crackedEgg3 = LK.getAsset('crackedEgg3', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg3.x = fallingEgg.x;
crackedEgg3.y = fallingEgg.y;
game.addChild(crackedEgg3);
fallingEgg.destroy();
fallingEgg = crackedEgg3;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 4) {
// Hatch the golden galaxy egg with special probabilities
var availableGoldenGalaxyAnimals = [];
var goldenGalaxyAnimalTypes = ['goldenAndromedaGalaxy', 'goldenNormalGalaxy', 'goldenMilkyWayGalaxy'];
for (var typeIndex = 0; typeIndex < goldenGalaxyAnimalTypes.length; typeIndex++) {
var animalType = goldenGalaxyAnimalTypes[typeIndex];
var countInInventory = 0;
for (var invIndex = 0; invIndex < inventory.length; invIndex++) {
if (inventory[invIndex] === animalType) {
countInInventory++;
}
}
if (countInInventory < 3) {
availableGoldenGalaxyAnimals.push(animalType);
}
}
var animal;
if (availableGoldenGalaxyAnimals.length > 0) {
// Special probability distribution for golden galaxy eggs (same as galaxy)
var random = Math.random();
var selectedAnimal;
if (random < 0.009) {
selectedAnimal = 'goldenMilkyWayGalaxy'; // 0.9% chance
} else if (random < 0.199) {
selectedAnimal = 'goldenNormalGalaxy'; // 19% chance
} else {
selectedAnimal = 'goldenAndromedaGalaxy'; // 80.1% chance
}
// Check if selected animal is available
if (availableGoldenGalaxyAnimals.indexOf(selectedAnimal) !== -1) {
animal = selectedAnimal;
} else {
// If selected animal is not available, choose randomly from available
var randomIndex = Math.floor(Math.random() * availableGoldenGalaxyAnimals.length);
animal = availableGoldenGalaxyAnimals[randomIndex];
}
inventory.push(animal);
storage.inventory = inventory;
} else {
// All golden galaxy animal types have 3 in inventory
animal = null;
var allGoldenGalaxyPetsText = new Text2('All golden galaxy pets maxed out!', {
size: 60,
fill: 0xff0000
});
allGoldenGalaxyPetsText.anchor.set(0.5, 0.5);
allGoldenGalaxyPetsText.x = 2048 / 2;
allGoldenGalaxyPetsText.y = 1500;
game.addChild(allGoldenGalaxyPetsText);
LK.setTimeout(function () {
allGoldenGalaxyPetsText.destroy();
}, 2000);
}
// Only show hatched animal if we got a new pet
if (animal) {
var animalSprite = LK.getAsset(animal, {
anchorX: 0.5,
anchorY: 0.5
});
animalSprite.x = fallingEgg.x;
animalSprite.y = fallingEgg.y;
game.addChild(animalSprite);
// Remove animal after showing
LK.setTimeout(function () {
animalSprite.destroy();
}, 2000);
}
// Remove egg
fallingEgg.destroy();
fallingEgg = null;
}
};
}
};
// Handle inventory button
inventoryBtn.down = function () {
if (!isInventoryOpen) {
// Close shop first
if (shopOverlay) {
shopOverlay.destroy();
}
shopOverlay = null;
isShopOpen = false;
// Open inventory
isInventoryOpen = true;
inventoryOverlay = new Container();
var invBackground = LK.getAsset('shopBg', {
width: 2048,
height: 2732,
color: 0x000000,
shape: 'box'
});
inventoryOverlay.addChild(invBackground);
game.addChild(inventoryOverlay);
// Display inventory items by unique pet types
var yPos = 300;
var uniqueTypes = [];
var animalTypes = ['dog', 'cat', 'snake', 'goldenDog', 'goldenCat', 'goldenSnake', 'dinosaur', 'bear', 'bee', 'goldenDinosaur', 'goldenBear', 'goldenBee', 'trex', 'velector', 'titanaBull', 'goldenTrex', 'goldenVelector', 'goldenTitanaBull', 'ironMan', 'captainAmerica', 'spiderman', 'goldenIronMan', 'goldenCaptainAmerica', 'goldenSpiderman', 'king', 'knight', 'human', 'goldenKing', 'goldenKnight', 'goldenHuman', 'earth', 'moon', 'meteor', 'sun', 'jupiter', 'neptune', 'goldenEarth', 'goldenMoon', 'goldenMeteor', 'goldenSun', 'goldenJupiter', 'goldenNeptune', 'andromedaGalaxy', 'normalGalaxy', 'milkyWayGalaxy', 'goldenAndromedaGalaxy', 'goldenNormalGalaxy', 'goldenMilkyWayGalaxy'];
for (var typeIndex = 0; typeIndex < animalTypes.length; typeIndex++) {
var animalType = animalTypes[typeIndex];
var countInInventory = 0;
for (var invIndex = 0; invIndex < inventory.length; invIndex++) {
if (inventory[invIndex] === animalType) {
countInInventory++;
}
}
if (countInInventory > 0) {
uniqueTypes.push({
type: animalType,
count: countInInventory
});
}
}
for (var i = 0; i < uniqueTypes.length; i++) {
var petData = uniqueTypes[i];
var animalItem = LK.getAsset(petData.type, {
anchorX: 0.5,
anchorY: 0.5
});
animalItem.x = 300;
animalItem.y = yPos;
animalItem.animalType = petData.type;
animalItem.inventoryIndex = i;
inventoryOverlay.addChild(animalItem);
// Handle pet deletion when in delete mode
animalItem.down = function () {
if (deleteMode && selectedDeleteAnimalType === this.animalType) {
// Delete the pet
// Remove one instance of this pet from inventory
for (var removeIndex = 0; removeIndex < inventory.length; removeIndex++) {
if (inventory[removeIndex] === this.animalType) {
inventory.splice(removeIndex, 1);
break;
}
}
storage.inventory = inventory;
// Also remove from equipped animals if it was equipped
for (var removeIndex = equippedAnimals.length - 1; removeIndex >= 0; removeIndex--) {
if (equippedAnimals[removeIndex] === this.animalType) {
equippedAnimals.splice(removeIndex, 1);
break;
}
}
// Recalculate pet bonus after removing
var petBonus = 0;
// Count each animal type
var dogCount = 0;
var catCount = 0;
var snakeCount = 0;
for (var j = 0; j < equippedAnimals.length; j++) {
if (equippedAnimals[j] === 'dog') {
dogCount++;
} else if (equippedAnimals[j] === 'cat') {
catCount++;
} else if (equippedAnimals[j] === 'snake') {
snakeCount++;
}
}
// Each dog gives +1 bonus per tap
petBonus += dogCount;
// Cats: 1 cat = +2, 2 cats = +4, 3 cats = +6 (total bonus)
if (catCount === 1) {
petBonus += 2;
} else if (catCount === 2) {
petBonus += 4;
} else if (catCount === 3) {
petBonus += 6;
}
// Snakes: 1 snake = +5, 2 snakes = +10, 3 snakes = +15 (total bonus)
if (snakeCount === 1) {
petBonus += 5;
} else if (snakeCount === 2) {
petBonus += 10;
} else if (snakeCount === 3) {
petBonus += 15;
}
// Store as multiplier format (base 1 + bonus)
currentMultiplier = 1 + petBonus;
storage.equippedAnimals = equippedAnimals;
storage.currentMultiplier = currentMultiplier;
// Exit delete mode
deleteMode = false;
selectedDeleteAnimalType = null;
// Close and reopen inventory to refresh display
inventoryOverlay.destroy();
inventoryOverlay = null;
isInventoryOpen = false;
// Reopen inventory to show updated counts
inventoryBtn.down();
}
};
// Count how many of this type are equipped
var equippedCount = 0;
for (var k = 0; k < equippedAnimals.length; k++) {
if (equippedAnimals[k] === petData.type) {
equippedCount++;
}
}
// Add equip button
var equipBtn = new Text2('Equip', {
size: 50,
fill: 0xFFFFFF
});
equipBtn.anchor.set(0.5, 0.5);
equipBtn.x = 550;
equipBtn.y = yPos;
equipBtn.animalType = inventory[i];
equipBtn.inventoryIndex = i;
inventoryOverlay.addChild(equipBtn);
// Add unequip button
var unequipBtn = new Text2('Unequip', {
size: 50,
fill: 0xFF6B6B
});
unequipBtn.anchor.set(0.5, 0.5);
unequipBtn.x = 700;
unequipBtn.y = yPos;
unequipBtn.animalType = inventory[i];
unequipBtn.inventoryIndex = i;
inventoryOverlay.addChild(unequipBtn);
// Add delete button
var deleteBtn = new Text2('Delete', {
size: 50,
fill: 0xFF0000
});
deleteBtn.anchor.set(0.5, 0.5);
deleteBtn.x = 850;
deleteBtn.y = yPos;
deleteBtn.animalType = inventory[i];
deleteBtn.inventoryIndex = i;
inventoryOverlay.addChild(deleteBtn);
// Add count display
var countText = new Text2('Owned: ' + petData.count + ' | Equipped: ' + equippedCount, {
size: 40,
fill: 0xFFFFFF
});
countText.anchor.set(0.5, 0.5);
countText.x = 1000;
countText.y = yPos;
inventoryOverlay.addChild(countText);
// Handle delete functionality
deleteBtn.down = function () {
if (!deleteMode) {
// First press - enter delete mode
deleteMode = true;
selectedDeleteAnimalType = this.animalType;
// Show message to click on pet
var deleteInstructionText = new Text2('Click on the pet to delete it', {
size: 40,
fill: 0xff0000
});
deleteInstructionText.anchor.set(0.5, 0.5);
deleteInstructionText.x = 2048 / 2;
deleteInstructionText.y = 2500;
inventoryOverlay.addChild(deleteInstructionText);
// Auto-hide instruction after 3 seconds
LK.setTimeout(function () {
if (deleteInstructionText && deleteInstructionText.parent) {
deleteInstructionText.destroy();
}
}, 3000);
} else if (deleteMode && selectedDeleteAnimalType === this.animalType) {
// Second press on same delete button - cancel delete mode
deleteMode = false;
selectedDeleteAnimalType = null;
}
};
// Handle unequip functionality
unequipBtn.down = function () {
// Find and remove one instance of this pet type from equipped animals
for (var removeIndex = 0; removeIndex < equippedAnimals.length; removeIndex++) {
if (equippedAnimals[removeIndex] === this.animalType) {
equippedAnimals.splice(removeIndex, 1);
break;
}
}
// Recalculate pet bonus after unequipping
var petBonus = 0;
// Count each animal type
var dogCount = 0;
var catCount = 0;
var snakeCount = 0;
for (var j = 0; j < equippedAnimals.length; j++) {
if (equippedAnimals[j] === 'dog') {
dogCount++;
} else if (equippedAnimals[j] === 'cat') {
catCount++;
} else if (equippedAnimals[j] === 'snake') {
snakeCount++;
}
}
// Each dog gives +1 bonus per tap
petBonus += dogCount;
// Cats: 1 cat = +2, 2 cats = +4, 3 cats = +6 (total bonus)
if (catCount === 1) {
petBonus += 2;
} else if (catCount === 2) {
petBonus += 4;
} else if (catCount === 3) {
petBonus += 6;
}
// Snakes: 1 snake = +5, 2 snakes = +10, 3 snakes = +15 (total bonus)
if (snakeCount === 1) {
petBonus += 5;
} else if (snakeCount === 2) {
petBonus += 10;
} else if (snakeCount === 3) {
petBonus += 15;
}
// Store as multiplier format (base 1 + bonus)
currentMultiplier = 1 + petBonus;
storage.equippedAnimals = equippedAnimals;
storage.currentMultiplier = currentMultiplier;
// Close and reopen inventory to refresh display
inventoryOverlay.destroy();
inventoryOverlay = null;
isInventoryOpen = false;
// Reopen inventory to show updated counts
inventoryBtn.down();
};
equipBtn.down = function () {
// Count how many of this pet type are in inventory
var inventoryCount = 0;
for (var invIndex = 0; invIndex < inventory.length; invIndex++) {
if (inventory[invIndex] === this.animalType) {
inventoryCount++;
}
}
// Count how many of this pet type are already equipped
var equippedCount = 0;
for (var checkIndex = 0; checkIndex < equippedAnimals.length; checkIndex++) {
if (equippedAnimals[checkIndex] === this.animalType) {
equippedCount++;
}
}
// Check if we have this pet available in inventory to equip
if (equippedCount >= inventoryCount) {
var noPetText = new Text2('Need more pets to equip!', {
size: 40,
fill: 0xff0000
});
noPetText.anchor.set(0.5, 0.5);
noPetText.x = this.x;
noPetText.y = this.y - 50;
inventoryOverlay.addChild(noPetText);
LK.setTimeout(function () {
noPetText.destroy();
}, 1500);
return;
}
// Check if we can equip more pets (total limit of 3)
if (equippedAnimals.length < maxEquippedPets) {
// Equip this pet
equippedAnimals.push(this.animalType);
} else {
// Show message that max pets reached
var maxText = new Text2('Max 3 pets total!', {
size: 40,
fill: 0xff0000
});
maxText.anchor.set(0.5, 0.5);
maxText.x = this.x;
maxText.y = this.y - 50;
inventoryOverlay.addChild(maxText);
LK.setTimeout(function () {
maxText.destroy();
}, 1500);
return;
}
// Calculate pet bonus based on equipped animal quantities
var petBonus = 0;
// Count each animal type
var dogCount = 0;
var catCount = 0;
var snakeCount = 0;
for (var j = 0; j < equippedAnimals.length; j++) {
if (equippedAnimals[j] === 'dog') {
dogCount++;
} else if (equippedAnimals[j] === 'cat') {
catCount++;
} else if (equippedAnimals[j] === 'snake') {
snakeCount++;
}
}
// Each dog gives +1 bonus per tap
petBonus += dogCount;
// Cats: 1 cat = +2, 2 cats = +4, 3 cats = +6 (total bonus)
if (catCount === 1) {
petBonus += 2;
} else if (catCount === 2) {
petBonus += 4;
} else if (catCount === 3) {
petBonus += 6;
}
// Snakes: 1 snake = +5, 2 snakes = +10, 3 snakes = +15 (total bonus)
if (snakeCount === 1) {
petBonus += 5;
} else if (snakeCount === 2) {
petBonus += 10;
} else if (snakeCount === 3) {
petBonus += 15;
}
// Store as multiplier format (base 1 + bonus)
currentMultiplier = 1 + petBonus;
storage.equippedAnimals = equippedAnimals;
storage.currentMultiplier = currentMultiplier;
// Close and reopen inventory to refresh display
inventoryOverlay.destroy();
inventoryOverlay = null;
isInventoryOpen = false;
// Reopen inventory to show updated counts
inventoryBtn.down();
};
yPos += 200;
}
// Add close inventory button
var closeInvBtn = new Text2('Close', {
size: 80,
fill: 0xFFFFFF
});
closeInvBtn.anchor.set(0.5, 0.5);
closeInvBtn.x = 2048 / 2;
closeInvBtn.y = 2400;
inventoryOverlay.addChild(closeInvBtn);
closeInvBtn.down = function () {
// Reset delete mode when closing inventory
deleteMode = false;
selectedDeleteAnimalType = null;
inventoryOverlay.destroy();
inventoryOverlay = null;
isInventoryOpen = false;
};
}
// Handle Lucky Boost button
luckyBoostBtn.down = function () {
if (!isLuckyBoostShopOpen) {
// Close shop first
if (shopOverlay) {
shopOverlay.destroy();
}
shopOverlay = null;
isShopOpen = false;
// Open Lucky Boost shop
isLuckyBoostShopOpen = true;
luckyBoostOverlay = new Container();
var boostBackground = LK.getAsset('shopBg', {
width: 2048,
height: 2732,
color: 0x000000,
shape: 'box'
});
luckyBoostOverlay.addChild(boostBackground);
// Lucky Boost title
var boostTitle = new Text2('Lucky Boost Shop', {
size: 100,
fill: 0xFFD700
});
boostTitle.anchor.set(0.5, 0);
boostTitle.x = 2048 / 2;
boostTitle.y = 300;
luckyBoostOverlay.addChild(boostTitle);
// Boost option 1: 1 minute
var boost1Btn = new Text2('1 Minute Boost\n10,000 Score', {
size: 60,
fill: 0xFFFFFF
});
boost1Btn.anchor.set(0.5, 0.5);
boost1Btn.x = 2048 / 2;
boost1Btn.y = 800;
luckyBoostOverlay.addChild(boost1Btn);
// Boost option 2: 5 minutes
var boost5Btn = new Text2('5 Minutes Boost\n50,000 Score', {
size: 60,
fill: 0xFFFFFF
});
boost5Btn.anchor.set(0.5, 0.5);
boost5Btn.x = 2048 / 2;
boost5Btn.y = 1200;
luckyBoostOverlay.addChild(boost5Btn);
// Boost option 3: 10 minutes
var boost10Btn = new Text2('10 Minutes Boost\n100,000 Score', {
size: 60,
fill: 0xFFFFFF
});
boost10Btn.anchor.set(0.5, 0.5);
boost10Btn.x = 2048 / 2;
boost10Btn.y = 1600;
luckyBoostOverlay.addChild(boost10Btn);
// Close button
var closeBoostBtn = new Text2('Close', {
size: 80,
fill: 0xFFFFFF
});
closeBoostBtn.anchor.set(0.5, 0.5);
closeBoostBtn.x = 2048 / 2;
closeBoostBtn.y = 2200;
luckyBoostOverlay.addChild(closeBoostBtn);
// Handle boost purchases
boost1Btn.down = function () {
if (LK.getScore() >= 10000) {
LK.setScore(LK.getScore() - 10000);
luckyBoostActive = true;
luckyBoostEndTime = Date.now() + 60000; // 1 minute
scoreTxt.setText(LK.getScore().toString());
luckyBoostOverlay.destroy();
luckyBoostOverlay = null;
isLuckyBoostShopOpen = false;
}
};
boost5Btn.down = function () {
if (LK.getScore() >= 50000) {
LK.setScore(LK.getScore() - 50000);
luckyBoostActive = true;
luckyBoostEndTime = Date.now() + 300000; // 5 minutes
scoreTxt.setText(LK.getScore().toString());
luckyBoostOverlay.destroy();
luckyBoostOverlay = null;
isLuckyBoostShopOpen = false;
}
};
boost10Btn.down = function () {
if (LK.getScore() >= 100000) {
LK.setScore(LK.getScore() - 100000);
luckyBoostActive = true;
luckyBoostEndTime = Date.now() + 600000; // 10 minutes
scoreTxt.setText(LK.getScore().toString());
luckyBoostOverlay.destroy();
luckyBoostOverlay = null;
isLuckyBoostShopOpen = false;
}
};
closeBoostBtn.down = function () {
luckyBoostOverlay.destroy();
luckyBoostOverlay = null;
isLuckyBoostShopOpen = false;
};
game.addChild(luckyBoostOverlay);
}
};
};
// Add shop overlay to main game
game.addChild(shopOverlay);
isShopOpen = true;
} else {
// Close shop - remove overlay
if (shopOverlay) {
shopOverlay.destroy();
shopOverlay = null;
}
isShopOpen = false;
}
};
// Update score display on game start
game.update = function () {
// Keep score text updated (in case it changes from other sources)
scoreTxt.setText(LK.getScore().toString());
// Check if Lucky Boost has expired
if (luckyBoostActive && Date.now() >= luckyBoostEndTime) {
luckyBoostActive = false;
}
};