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
User prompt
Oyuna Shop Lucky boost ekle 10x fiyat dakakya değişiyor 1 dakika var 5 dakak var 10 dakika var 1 dakika 10000 pata 5 dakika 50000 10dakka 100000 para 10x boost 2 ve 3 petlerin şansını 10x artırıyor 1 Pet çıkma olasılığı 10x azaltıyor ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Yeni 2 adet yumurta 1. Yumurta fiyat 500M yumurtası içindekiler sadece 3 tane yumurta var 80.0 ihtimalle andoramde galaksinin 0.1 ihtimalle normal saman yolu galaksi 3. Pet 19.9 ihtimalle normal galaksi yüzde 80.9 ihtimalle çıkan andoramde galaksi tıklama basına 5 M para veriyor normal galaksi 10M 0çq ihtimalle saman yolu galaksizi 20M para yani 200000000 para versin ama tabi 20M yazsın 2. Altın yumurta 1B para yani 1 milyar para içindekiler 1. Dedim normal yumurtayla içindeki petler aynı sadece altın halleri ve 2 katta daha çok score veriyor
User prompt
Yeni 2 yumurt ekle normal 2 tane altın halleri ilk 2 yumurta normal 1. Normal yumurta fiyat 10000000 olsun ama tavi 100M yazssın içindekiler 3 adet 1. Pet dünya 0.1 ihtimalle çıkar tıklama basına 100000 score gelsin 2. Ay çıkma oranı yüzde 1 ihtimalle lle çıkıyor tıklama basına 50000 score geliyor 3. Yüzde 98.9 ihtimalle göktaşı çıkıyor tıklama başına 25 bin score tıklama başına veriyor 2. Yumurta normal yumurta fiyat 200M yani 200000000 0.01 ihtimalle isim güneş tıklama basına 500000 score geliyor 2. Yumurta Jüpiter çıkma orani 0.1 tıklama basına 250000 score gelsin 3. Pet Neptün çıkma orani 99.9 tıklama basına 200000 score gelsin diyer altı. Yumurtaları 1. Altın yumurta ay dunya göktaşı bu yumurtanın fiyatı 200M yani 200000000 bunlar petler aynı sadece dış gorujulı altım şeklini alıyor yumurtaları ve tıklama basına gelen scorerler 2x artsın yani petler altın olduğu için normal petlerden 2x daha çok score versin güneş 1milyon versin ama 1M yazsın 2. Pet Jüpiter tıklama basına 250000 score versin 3. Neptün tıklama basına 200000 score versin 2. Altım yumurta içindekiler Yumurtayla aynı dünya ay gök taşı sadece altın halleri ve 2 katta daha çok score veriolar 2. Altın yumurta içindekiler Jüpiter güneş Neptün bu yumurtanın fiyatı ise 400M yani 400000000
User prompt
Altın yumurtaları ile normal yumurtaların arasında w yumurta boşluk olsun
/**** * 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; // 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; 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++; } } // 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; } // 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 }]; // 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 }]; // 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 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; 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]; // 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 var random = Math.random(); var selectedAnimal; if (random < 0.05) { selectedAnimal = 'dinosaur'; // 5% chance } else if (random < 0.2) { selectedAnimal = 'bear'; // 15% chance } else { selectedAnimal = 'bee'; // 80% chance } // 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 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']; 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; }; } }; // 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()); };
/****
* 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;
// 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;
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++;
}
}
// 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;
}
// 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
}];
// 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
}];
// 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 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;
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];
// 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
var random = Math.random();
var selectedAnimal;
if (random < 0.05) {
selectedAnimal = 'dinosaur'; // 5% chance
} else if (random < 0.2) {
selectedAnimal = 'bear'; // 15% chance
} else {
selectedAnimal = 'bee'; // 80% chance
}
// 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 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'];
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;
};
}
};
// 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());
};