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
User prompt
Yanana 5 tane yumurta olsun 5 den fazla yumurta olursa altta doğru uzasın yan yana en fazla 5 tane yumurta konulabilir
User prompt
Bütün yumurtaları ayıralım üste normal yumurtalar altta altın yumurtalar olsun
User prompt
Yeni 2 adet yumurta ekle 1. Yumurta fiyat 10000000 ama tabi yumurta 10M yazsın altında fiyat olarak içinde 3 tane pet olsun 1. Pet çıkma orani yüzde 0.5 ismi king tıklama basına 10000 veriyor 2. Pet İsmi knight çıkma orani yüzde 5 tıklama basına 5000 score veriyor 3. Pet ismi Human çıkma oranı 94.5 ihtimalle çıkıyor ve tıklama basına 2500 veriyor 2. Yumurta aynı diyeriylr ama altın hali fiyat 20M yazsın yani 20000000 para ama 20M yazssın içindekiler petler herşey aynı yüzde çıkma olasılığı ayni ama petlerin tıklama basına verdiği score lar 2 katı king tıklama basına 20000 verio 2. Pet altın knight 10000 score veriyor tıklama basına 3. Pet altın human tıklama başına 5000 score veriyor
User prompt
Yeni 2 yumurta ekle 1. Yumurta dış gornuş mor olsun ve dışında kolları olsun Fiyat 1250000 içimdekileri 3 tane pet 1. Pet çıkma oranı yüzde 1 Pet adı Iron man tıklama basına 500 versin 2. Pet çıkma oranı yüzde 14 isimkaptan Amerika tıklama basına 300 veriyor 3. Pet çıkma orani yüzde 85 pet adı spiderman tıklama basına 250 veriyor 2. Fiyat 2500000 Yumurta altın mor yumurta yine ayni petler var ama petler tıklama basına verdiği puanlar 2x katlansın çıkma oranları aynı 1. Pet iron man tıklama basına 1000 puan veriyor 2. Pet kaptan Amerika tıklama basına 600 veriyor 3. Pet spiderman tıklama basına 500 veriyor
User prompt
Yeni 2 yumurtanın ekle 1.yumurta dışı görünüşü kırmızı dinazorumsu olsun Fiyat 50000 içimde yüzde 5 ihtimalle T-rex çıksın bir tanesi tıklama basına 100 score versin 2. Pet velector yüzde 25 ihtimalle çıksın tıklama basına 80 veriyor 3. Pet titana boğa yüzde 70 ihtimalle çıkıyor tıklama basına 50 veriyor 2. Yumurtada yine ayni petler ama altın hali dış gornuş ayni ama altın hali fiyat 100000 yüzde 5 ihtimalle altın T-rex tıklama basına 200 score versin yüzde 25 ihtimalle altın velector tıklama basına 160 score veriyor yüzde 70 ihtimalle altın titana boğa tıklama basına 100 score veriyor
User prompt
Yeni bir yumurta ekle yumurtanın dış gornuşumu yeşil olsun ve içinde cıkan petler dinozor yüzde 5 ihtimalle çıkıyor 1 tane her tıklama basına +30 score veriyor 2 tane olunca 60 score veriyor 3 tane olunca 90 score veriyor 2. Pet yeşil yumurtadan çıkan ayı yüzde 15 ihtimalle çıkar 1 tane +20 puan veriyor 2 tane 40 puan 3 tane 60 puan tıklama basına diyer pet yüzde 80 ihtimalle arı çıkıyor 1 tanesi +10 score veriyor 2 tanesi 20 score 3 tane 30 score veriyor tıklama basına ve bu yumurtanın fiyat 15000 2. Yumurta aynı ama altın hali ve petler 2 katta tıklama basına gelen puanları 2x artsın yüzde cıkma ihtimalleri aynı sadece tıklama basına gelen olanlar 2x artır örn ayı +40 puan veriyor dinozor tıklama basına +60 veriyor 1 tanesi 1 tane arı +20 score veriyor ve yumurta fiyatı 30000
User prompt
Delete tuşuna basınca direk silinmesin Delete tuşuna bastıktan sonra pet üstüne tıklıyalım sonra Settar Delete tuşuna basalım sonrada silinsin
User prompt
Golden egg yerini değiştir normal egg yanına koy
User prompt
Invertory yazısını golden egg altına yerleştir
User prompt
Normal egg yanına golden egg ekle fiyatı 10000 para olsun ve içindekile altın cat yüzde 30 ihtimalle çıkıyor altın yılan yüzde 10 ihtimalle cıkıyor yüzde 60 ihtimalle altın dog cıkıyor altın dog her tıklama basına +3 tıklama borusu veriyor 2 tane altın dog +6 borusu veriyo tıklama basına 3 tane altın dog tıklama basına +9 score veriyor altın cat tıklama basına +6 puan veri altın cat 2 tane +12 score veriyor tıklama basına altım cat 3 tane +18 tıklama basına veriyor 1 tane altın yılan tıklama. Basına +10 score veriyor 2 altın yılan +20 score veriyor 3 altın yılan +30 score veriyor tıklama basına
User prompt
Egg fiyatı 1000 olsun
User prompt
Aynı petten sadece 3 tane takılabilir ve ayni oetş bidaha kullanmak için birdaha o peti çıkarman lazım 1 tane pet cıkarılcan 3 defa equip yapamadın ilakki 3 tane aynı petten cıkarılması lazım
User prompt
Aynı peti bidaha takmak için 1 defada aynı pet cıkarsın zorundasın
User prompt
Bir tane pet cıkarılımca ve onu equip yaptın takılsın ama bidaha equip yapında hicbirşey olmasın eyerki birdah o petten çıkarırsa ve yine equip yaparsan aynı oetten 2 tane takmış olursun
User prompt
Aynı peti bidaha takmak için 1 defada aynı pet cıkarsın zorundasın
User prompt
Shock wawe delete
User prompt
Ekrana dokununca beyaz şok dalgasını oluşsun ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Ekrana tıklayınca şok dalgasını olmasın
User prompt
Ekrana tıklamdında beyaz şok dalgasını oluşsun ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Ekrana her tıkladında şok dalgasını oluşsun ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Aynı petten en fazla 3 tane yapılabilir en gazlada toplam 3 tane pet takılabilir ve takılı olan bütün petler score ları ana score tıklamabasına gelen score eklensin
/****
* 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;
var earthCount = 0;
var moonCount = 0;
var meteorCount = 0;
var sunCount = 0;
var jupiterCount = 0;
var neptuneCount = 0;
var goldenEarthCount = 0;
var goldenMoonCount = 0;
var goldenMeteorCount = 0;
var goldenSunCount = 0;
var goldenJupiterCount = 0;
var goldenNeptuneCount = 0;
for (var j = 0; j < equippedAnimals.length; j++) {
if (equippedAnimals[j] === 'dog') {
dogCount++;
} else if (equippedAnimals[j] === 'cat') {
catCount++;
} else if (equippedAnimals[j] === 'snake') {
snakeCount++;
} else if (equippedAnimals[j] === 'goldenDog') {
goldenDogCount++;
} else if (equippedAnimals[j] === 'goldenCat') {
goldenCatCount++;
} else if (equippedAnimals[j] === 'goldenSnake') {
goldenSnakeCount++;
} else if (equippedAnimals[j] === 'dinosaur') {
dinosaurCount++;
} else if (equippedAnimals[j] === 'bear') {
bearCount++;
} else if (equippedAnimals[j] === 'bee') {
beeCount++;
} else if (equippedAnimals[j] === 'goldenDinosaur') {
goldenDinosaurCount++;
} else if (equippedAnimals[j] === 'goldenBear') {
goldenBearCount++;
} else if (equippedAnimals[j] === 'goldenBee') {
goldenBeeCount++;
} else if (equippedAnimals[j] === 'trex') {
trexCount++;
} else if (equippedAnimals[j] === 'velector') {
velectorCount++;
} else if (equippedAnimals[j] === 'titanaBull') {
titanaBullCount++;
} else if (equippedAnimals[j] === 'goldenTrex') {
goldenTrexCount++;
} else if (equippedAnimals[j] === 'goldenVelector') {
goldenVelectorCount++;
} else if (equippedAnimals[j] === 'goldenTitanaBull') {
goldenTitanaBullCount++;
} else if (equippedAnimals[j] === 'ironMan') {
ironManCount++;
} else if (equippedAnimals[j] === 'captainAmerica') {
captainAmericaCount++;
} else if (equippedAnimals[j] === 'spiderman') {
spidermanCount++;
} else if (equippedAnimals[j] === 'goldenIronMan') {
goldenIronManCount++;
} else if (equippedAnimals[j] === 'goldenCaptainAmerica') {
goldenCaptainAmericaCount++;
} else if (equippedAnimals[j] === 'goldenSpiderman') {
goldenSpidermanCount++;
} else if (equippedAnimals[j] === 'king') {
kingCount++;
} else if (equippedAnimals[j] === 'knight') {
knightCount++;
} else if (equippedAnimals[j] === 'human') {
humanCount++;
} else if (equippedAnimals[j] === 'goldenKing') {
goldenKingCount++;
} else if (equippedAnimals[j] === 'goldenKnight') {
goldenKnightCount++;
} else if (equippedAnimals[j] === 'goldenHuman') {
goldenHumanCount++;
} else if (equippedAnimals[j] === 'earth') {
earthCount++;
} else if (equippedAnimals[j] === 'moon') {
moonCount++;
} else if (equippedAnimals[j] === 'meteor') {
meteorCount++;
} else if (equippedAnimals[j] === 'sun') {
sunCount++;
} else if (equippedAnimals[j] === 'jupiter') {
jupiterCount++;
} else if (equippedAnimals[j] === 'neptune') {
neptuneCount++;
} else if (equippedAnimals[j] === 'goldenEarth') {
goldenEarthCount++;
} else if (equippedAnimals[j] === 'goldenMoon') {
goldenMoonCount++;
} else if (equippedAnimals[j] === 'goldenMeteor') {
goldenMeteorCount++;
} else if (equippedAnimals[j] === 'goldenSun') {
goldenSunCount++;
} else if (equippedAnimals[j] === 'goldenJupiter') {
goldenJupiterCount++;
} else if (equippedAnimals[j] === 'goldenNeptune') {
goldenNeptuneCount++;
}
}
// Each dog gives +1 bonus per tap
petBonus += dogCount;
// Cats: 1 cat = +2, 2 cats = +4, 3 cats = +6 (total bonus)
if (catCount === 1) {
petBonus += 2;
} else if (catCount === 2) {
petBonus += 4;
} else if (catCount === 3) {
petBonus += 6;
}
// Snakes: 1 snake = +5, 2 snakes = +10, 3 snakes = +15 (total bonus)
if (snakeCount === 1) {
petBonus += 5;
} else if (snakeCount === 2) {
petBonus += 10;
} else if (snakeCount === 3) {
petBonus += 15;
}
// Golden pets bonuses
// Golden dogs: 1 = +3, 2 = +6, 3 = +9 per tap
if (goldenDogCount === 1) {
petBonus += 3;
} else if (goldenDogCount === 2) {
petBonus += 6;
} else if (goldenDogCount === 3) {
petBonus += 9;
}
// Golden cats: 1 = +6, 2 = +12, 3 = +18 per tap
if (goldenCatCount === 1) {
petBonus += 6;
} else if (goldenCatCount === 2) {
petBonus += 12;
} else if (goldenCatCount === 3) {
petBonus += 18;
}
// Golden snakes: 1 = +10, 2 = +20, 3 = +30 per tap
if (goldenSnakeCount === 1) {
petBonus += 10;
} else if (goldenSnakeCount === 2) {
petBonus += 20;
} else if (goldenSnakeCount === 3) {
petBonus += 30;
}
// Green egg pets bonuses
// Dinosaurs: 1 = +30, 2 = +60, 3 = +90 per tap
if (dinosaurCount === 1) {
petBonus += 30;
} else if (dinosaurCount === 2) {
petBonus += 60;
} else if (dinosaurCount === 3) {
petBonus += 90;
}
// Bears: 1 = +20, 2 = +40, 3 = +60 per tap
if (bearCount === 1) {
petBonus += 20;
} else if (bearCount === 2) {
petBonus += 40;
} else if (bearCount === 3) {
petBonus += 60;
}
// Bees: 1 = +10, 2 = +20, 3 = +30 per tap
if (beeCount === 1) {
petBonus += 10;
} else if (beeCount === 2) {
petBonus += 20;
} else if (beeCount === 3) {
petBonus += 30;
}
// Golden green egg pets bonuses (2x multiplier)
// Golden dinosaurs: 1 = +60, 2 = +120, 3 = +180 per tap
if (goldenDinosaurCount === 1) {
petBonus += 60;
} else if (goldenDinosaurCount === 2) {
petBonus += 120;
} else if (goldenDinosaurCount === 3) {
petBonus += 180;
}
// Golden bears: 1 = +40, 2 = +80, 3 = +120 per tap
if (goldenBearCount === 1) {
petBonus += 40;
} else if (goldenBearCount === 2) {
petBonus += 80;
} else if (goldenBearCount === 3) {
petBonus += 120;
}
// Golden bees: 1 = +20, 2 = +40, 3 = +60 per tap
if (goldenBeeCount === 1) {
petBonus += 20;
} else if (goldenBeeCount === 2) {
petBonus += 40;
} else if (goldenBeeCount === 3) {
petBonus += 60;
}
// Red egg pets bonuses
// T-rex: 1 = +100, 2 = +200, 3 = +300 per tap
if (trexCount === 1) {
petBonus += 100;
} else if (trexCount === 2) {
petBonus += 200;
} else if (trexCount === 3) {
petBonus += 300;
}
// Velector: 1 = +80, 2 = +160, 3 = +240 per tap
if (velectorCount === 1) {
petBonus += 80;
} else if (velectorCount === 2) {
petBonus += 160;
} else if (velectorCount === 3) {
petBonus += 240;
}
// Titana Bull: 1 = +50, 2 = +100, 3 = +150 per tap
if (titanaBullCount === 1) {
petBonus += 50;
} else if (titanaBullCount === 2) {
petBonus += 100;
} else if (titanaBullCount === 3) {
petBonus += 150;
}
// Golden red egg pets bonuses
// Golden T-rex: 1 = +200, 2 = +400, 3 = +600 per tap
if (goldenTrexCount === 1) {
petBonus += 200;
} else if (goldenTrexCount === 2) {
petBonus += 400;
} else if (goldenTrexCount === 3) {
petBonus += 600;
}
// Golden Velector: 1 = +160, 2 = +320, 3 = +480 per tap
if (goldenVelectorCount === 1) {
petBonus += 160;
} else if (goldenVelectorCount === 2) {
petBonus += 320;
} else if (goldenVelectorCount === 3) {
petBonus += 480;
}
// Golden Titana Bull: 1 = +100, 2 = +200, 3 = +300 per tap
if (goldenTitanaBullCount === 1) {
petBonus += 100;
} else if (goldenTitanaBullCount === 2) {
petBonus += 200;
} else if (goldenTitanaBullCount === 3) {
petBonus += 300;
}
// Purple egg pets bonuses
// Iron Man: 1 = +500, 2 = +1000, 3 = +1500 per tap
if (ironManCount === 1) {
petBonus += 500;
} else if (ironManCount === 2) {
petBonus += 1000;
} else if (ironManCount === 3) {
petBonus += 1500;
}
// Captain America: 1 = +300, 2 = +600, 3 = +900 per tap
if (captainAmericaCount === 1) {
petBonus += 300;
} else if (captainAmericaCount === 2) {
petBonus += 600;
} else if (captainAmericaCount === 3) {
petBonus += 900;
}
// Spiderman: 1 = +250, 2 = +500, 3 = +750 per tap
if (spidermanCount === 1) {
petBonus += 250;
} else if (spidermanCount === 2) {
petBonus += 500;
} else if (spidermanCount === 3) {
petBonus += 750;
}
// Golden purple egg pets bonuses (2x multiplier)
// Golden Iron Man: 1 = +1000, 2 = +2000, 3 = +3000 per tap
if (goldenIronManCount === 1) {
petBonus += 1000;
} else if (goldenIronManCount === 2) {
petBonus += 2000;
} else if (goldenIronManCount === 3) {
petBonus += 3000;
}
// Golden Captain America: 1 = +600, 2 = +1200, 3 = +1800 per tap
if (goldenCaptainAmericaCount === 1) {
petBonus += 600;
} else if (goldenCaptainAmericaCount === 2) {
petBonus += 1200;
} else if (goldenCaptainAmericaCount === 3) {
petBonus += 1800;
}
// Golden Spiderman: 1 = +500, 2 = +1000, 3 = +1500 per tap
if (goldenSpidermanCount === 1) {
petBonus += 500;
} else if (goldenSpidermanCount === 2) {
petBonus += 1000;
} else if (goldenSpidermanCount === 3) {
petBonus += 1500;
}
// White egg pets bonuses
// King: 1 = +10000, 2 = +20000, 3 = +30000 per tap
if (kingCount === 1) {
petBonus += 10000;
} else if (kingCount === 2) {
petBonus += 20000;
} else if (kingCount === 3) {
petBonus += 30000;
}
// Knight: 1 = +5000, 2 = +10000, 3 = +15000 per tap
if (knightCount === 1) {
petBonus += 5000;
} else if (knightCount === 2) {
petBonus += 10000;
} else if (knightCount === 3) {
petBonus += 15000;
}
// Human: 1 = +2500, 2 = +5000, 3 = +7500 per tap
if (humanCount === 1) {
petBonus += 2500;
} else if (humanCount === 2) {
petBonus += 5000;
} else if (humanCount === 3) {
petBonus += 7500;
}
// Golden white egg pets bonuses (2x multiplier)
// Golden King: 1 = +20000, 2 = +40000, 3 = +60000 per tap
if (goldenKingCount === 1) {
petBonus += 20000;
} else if (goldenKingCount === 2) {
petBonus += 40000;
} else if (goldenKingCount === 3) {
petBonus += 60000;
}
// Golden Knight: 1 = +10000, 2 = +20000, 3 = +30000 per tap
if (goldenKnightCount === 1) {
petBonus += 10000;
} else if (goldenKnightCount === 2) {
petBonus += 20000;
} else if (goldenKnightCount === 3) {
petBonus += 30000;
}
// Golden Human: 1 = +5000, 2 = +10000, 3 = +15000 per tap
if (goldenHumanCount === 1) {
petBonus += 5000;
} else if (goldenHumanCount === 2) {
petBonus += 10000;
} else if (goldenHumanCount === 3) {
petBonus += 15000;
}
// Space egg pets bonuses
// Earth: 1 = +100000, 2 = +200000, 3 = +300000 per tap
if (earthCount === 1) {
petBonus += 100000;
} else if (earthCount === 2) {
petBonus += 200000;
} else if (earthCount === 3) {
petBonus += 300000;
}
// Moon: 1 = +50000, 2 = +100000, 3 = +150000 per tap
if (moonCount === 1) {
petBonus += 50000;
} else if (moonCount === 2) {
petBonus += 100000;
} else if (moonCount === 3) {
petBonus += 150000;
}
// Meteor: 1 = +25000, 2 = +50000, 3 = +75000 per tap
if (meteorCount === 1) {
petBonus += 25000;
} else if (meteorCount === 2) {
petBonus += 50000;
} else if (meteorCount === 3) {
petBonus += 75000;
}
// Sun: 1 = +500000, 2 = +1000000, 3 = +1500000 per tap
if (sunCount === 1) {
petBonus += 500000;
} else if (sunCount === 2) {
petBonus += 1000000;
} else if (sunCount === 3) {
petBonus += 1500000;
}
// Jupiter: 1 = +250000, 2 = +500000, 3 = +750000 per tap
if (jupiterCount === 1) {
petBonus += 250000;
} else if (jupiterCount === 2) {
petBonus += 500000;
} else if (jupiterCount === 3) {
petBonus += 750000;
}
// Neptune: 1 = +200000, 2 = +400000, 3 = +600000 per tap
if (neptuneCount === 1) {
petBonus += 200000;
} else if (neptuneCount === 2) {
petBonus += 400000;
} else if (neptuneCount === 3) {
petBonus += 600000;
}
// Golden space egg pets bonuses (2x multiplier)
// Golden Earth: 1 = +200000, 2 = +400000, 3 = +600000 per tap
if (goldenEarthCount === 1) {
petBonus += 200000;
} else if (goldenEarthCount === 2) {
petBonus += 400000;
} else if (goldenEarthCount === 3) {
petBonus += 600000;
}
// Golden Moon: 1 = +100000, 2 = +200000, 3 = +300000 per tap
if (goldenMoonCount === 1) {
petBonus += 100000;
} else if (goldenMoonCount === 2) {
petBonus += 200000;
} else if (goldenMoonCount === 3) {
petBonus += 300000;
}
// Golden Meteor: 1 = +50000, 2 = +100000, 3 = +150000 per tap
if (goldenMeteorCount === 1) {
petBonus += 50000;
} else if (goldenMeteorCount === 2) {
petBonus += 100000;
} else if (goldenMeteorCount === 3) {
petBonus += 150000;
}
// Golden Sun: 1 = +1000000, 2 = +2000000, 3 = +3000000 per tap
if (goldenSunCount === 1) {
petBonus += 1000000;
} else if (goldenSunCount === 2) {
petBonus += 2000000;
} else if (goldenSunCount === 3) {
petBonus += 3000000;
}
// Golden Jupiter: 1 = +500000, 2 = +1000000, 3 = +1500000 per tap
if (goldenJupiterCount === 1) {
petBonus += 500000;
} else if (goldenJupiterCount === 2) {
petBonus += 1000000;
} else if (goldenJupiterCount === 3) {
petBonus += 1500000;
}
// Golden Neptune: 1 = +400000, 2 = +800000, 3 = +1200000 per tap
if (goldenNeptuneCount === 1) {
petBonus += 400000;
} else if (goldenNeptuneCount === 2) {
petBonus += 800000;
} else if (goldenNeptuneCount === 3) {
petBonus += 1200000;
}
// Base tap score is always 1, plus calculated pet bonus
var totalScore = 1 + petBonus;
LK.setScore(LK.getScore() + totalScore);
// Update score display
scoreTxt.setText(LK.getScore().toString());
// Create visual feedback at tap location showing total points gained
var feedbackText = '+' + totalScore.toString();
var tapFeedback = new Text2(feedbackText, {
size: 80,
fill: 0x27AE60
});
tapFeedback.anchor.set(0.5, 0.5);
tapFeedback.x = x;
tapFeedback.y = y;
tapFeedback.alpha = 1;
game.addChild(tapFeedback);
// Animate feedback text
var startY = y;
var animationDuration = 800;
var startTime = Date.now();
var _animateCallback = function animateCallback() {
var elapsed = Date.now() - startTime;
var progress = elapsed / animationDuration;
if (progress >= 1) {
tapFeedback.destroy();
return;
}
// Move text upward and fade out
tapFeedback.y = startY - progress * 100;
tapFeedback.alpha = 1 - progress;
LK.setTimeout(_animateCallback, 16); // ~60fps
};
_animateCallback();
// Hide instruction text after first tap
if (LK.getScore() === 1) {
instructionTxt.alpha = 0;
}
};
// Add Shop button
var shopBtn = new Text2('Shop', {
size: 80,
fill: 0xFFFFFF
});
shopBtn.anchor.set(1, 0);
LK.gui.topRight.addChild(shopBtn);
shopBtn.x = -20; // Small padding from right edge
shopBtn.y = 20; // Small padding from top
// Shop interface state
var isShopOpen = false;
var shopOverlay = null;
// Handle shop button tap
shopBtn.down = function (x, y, obj) {
if (!isShopOpen) {
// Open shop - create black overlay using Container
shopOverlay = new Container();
// Create black background shape for overlay
var shopBackground = LK.getAsset('shopBg', {
width: 2048,
height: 2732,
color: 0x000000,
shape: 'box'
});
shopOverlay.addChild(shopBackground);
shopOverlay.x = 0;
shopOverlay.y = 0;
// NORMAL EGGS SECTION
// Normal eggs data
var normalEggs = [{
asset: 'egg',
price: '1000 Score',
color: 0xFFFFFF
}, {
asset: 'greenEgg',
price: '15000 Score',
color: 0x00ff00
}, {
asset: 'redEgg',
price: '50000 Score',
color: 0xff0000
}, {
asset: 'purpleEgg',
price: '1250000 Score',
color: 0x800080
}, {
asset: 'whiteEgg',
price: '10M',
color: 0xffffff
}, {
asset: 'spaceEgg',
price: '100M',
color: 0x4169e1
}, {
asset: 'space2Egg',
price: '200M',
color: 0x8a2be2
}];
// Golden eggs data
var goldenEggs = [{
asset: 'goldenEgg',
price: '10000 Score',
color: 0xFFD700
}, {
asset: 'goldenGreenEgg',
price: '30000 Score',
color: 0x90ee90
}, {
asset: 'goldenRedEgg',
price: '100000 Score',
color: 0xff6600
}, {
asset: 'goldenPurpleEgg',
price: '2500000 Score',
color: 0xdaa520
}, {
asset: 'goldenWhiteEgg',
price: '20M',
color: 0xffd700
}, {
asset: 'goldenSpaceEgg',
price: '200M',
color: 0xffd700
}, {
asset: 'goldenSpace2Egg',
price: '400M',
color: 0xffd700
}];
// 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];
var spaceEggItem = normalEggItems[5];
var space2EggItem = normalEggItems[6];
var goldenSpaceEggItem = goldenEggItems[5];
var goldenSpace2EggItem = goldenEggItems[6];
// 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 space egg purchase
spaceEggItem.down = function () {
if (LK.getScore() >= 100000000) {
LK.setScore(LK.getScore() - 100000000);
scoreTxt.setText(LK.getScore().toString());
// Close shop
shopOverlay.destroy();
shopOverlay = null;
isShopOpen = false;
// Create falling space egg
fallingEgg = LK.getAsset('spaceEgg', {
anchorX: 0.5,
anchorY: 0.5
});
fallingEgg.x = 2048 / 2;
fallingEgg.y = -200;
eggClickCount = 0;
game.addChild(fallingEgg);
// Animate egg falling
tween(fallingEgg, {
y: 2732 / 2
}, {
duration: 1000
});
// Handle space egg clicking
fallingEgg.down = function () {
eggClickCount++;
if (eggClickCount === 1) {
// First crack
var crackedEgg1 = LK.getAsset('crackedEgg1', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg1.x = fallingEgg.x;
crackedEgg1.y = fallingEgg.y;
game.addChild(crackedEgg1);
fallingEgg.destroy();
fallingEgg = crackedEgg1;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 2) {
// Second crack
var crackedEgg2 = LK.getAsset('crackedEgg2', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg2.x = fallingEgg.x;
crackedEgg2.y = fallingEgg.y;
game.addChild(crackedEgg2);
fallingEgg.destroy();
fallingEgg = crackedEgg2;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 3) {
// Third crack - almost fully cracked
var crackedEgg3 = LK.getAsset('crackedEgg3', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg3.x = fallingEgg.x;
crackedEgg3.y = fallingEgg.y;
game.addChild(crackedEgg3);
fallingEgg.destroy();
fallingEgg = crackedEgg3;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 4) {
// Hatch the space egg with special probabilities
var availableSpaceAnimals = [];
var spaceAnimalTypes = ['earth', 'moon', 'meteor'];
for (var typeIndex = 0; typeIndex < spaceAnimalTypes.length; typeIndex++) {
var animalType = spaceAnimalTypes[typeIndex];
var countInInventory = 0;
for (var invIndex = 0; invIndex < inventory.length; invIndex++) {
if (inventory[invIndex] === animalType) {
countInInventory++;
}
}
if (countInInventory < 3) {
availableSpaceAnimals.push(animalType);
}
}
var animal;
if (availableSpaceAnimals.length > 0) {
// Special probability distribution for space eggs
var random = Math.random();
var selectedAnimal;
if (random < 0.001) {
selectedAnimal = 'earth'; // 0.1% chance
} else if (random < 0.011) {
selectedAnimal = 'moon'; // 1% chance
} else {
selectedAnimal = 'meteor'; // 98.9% chance
}
// Check if selected animal is available
if (availableSpaceAnimals.indexOf(selectedAnimal) !== -1) {
animal = selectedAnimal;
} else {
// If selected animal is not available, choose randomly from available
var randomIndex = Math.floor(Math.random() * availableSpaceAnimals.length);
animal = availableSpaceAnimals[randomIndex];
}
inventory.push(animal);
storage.inventory = inventory;
} else {
// All space animal types have 3 in inventory
animal = null;
var allSpacePetsText = new Text2('All space pets maxed out!', {
size: 60,
fill: 0xff0000
});
allSpacePetsText.anchor.set(0.5, 0.5);
allSpacePetsText.x = 2048 / 2;
allSpacePetsText.y = 1500;
game.addChild(allSpacePetsText);
LK.setTimeout(function () {
allSpacePetsText.destroy();
}, 2000);
}
// Only show hatched animal if we got a new pet
if (animal) {
var animalSprite = LK.getAsset(animal, {
anchorX: 0.5,
anchorY: 0.5
});
animalSprite.x = fallingEgg.x;
animalSprite.y = fallingEgg.y;
game.addChild(animalSprite);
// Remove animal after showing
LK.setTimeout(function () {
animalSprite.destroy();
}, 2000);
}
// Remove egg
fallingEgg.destroy();
fallingEgg = null;
}
};
}
};
// Handle space2 egg purchase
space2EggItem.down = function () {
if (LK.getScore() >= 200000000) {
LK.setScore(LK.getScore() - 200000000);
scoreTxt.setText(LK.getScore().toString());
// Close shop
shopOverlay.destroy();
shopOverlay = null;
isShopOpen = false;
// Create falling space2 egg
fallingEgg = LK.getAsset('space2Egg', {
anchorX: 0.5,
anchorY: 0.5
});
fallingEgg.x = 2048 / 2;
fallingEgg.y = -200;
eggClickCount = 0;
game.addChild(fallingEgg);
// Animate egg falling
tween(fallingEgg, {
y: 2732 / 2
}, {
duration: 1000
});
// Handle space2 egg clicking
fallingEgg.down = function () {
eggClickCount++;
if (eggClickCount === 1) {
// First crack
var crackedEgg1 = LK.getAsset('crackedEgg1', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg1.x = fallingEgg.x;
crackedEgg1.y = fallingEgg.y;
game.addChild(crackedEgg1);
fallingEgg.destroy();
fallingEgg = crackedEgg1;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 2) {
// Second crack
var crackedEgg2 = LK.getAsset('crackedEgg2', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg2.x = fallingEgg.x;
crackedEgg2.y = fallingEgg.y;
game.addChild(crackedEgg2);
fallingEgg.destroy();
fallingEgg = crackedEgg2;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 3) {
// Third crack - almost fully cracked
var crackedEgg3 = LK.getAsset('crackedEgg3', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg3.x = fallingEgg.x;
crackedEgg3.y = fallingEgg.y;
game.addChild(crackedEgg3);
fallingEgg.destroy();
fallingEgg = crackedEgg3;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 4) {
// Hatch the space2 egg with special probabilities
var availableSpace2Animals = [];
var space2AnimalTypes = ['sun', 'jupiter', 'neptune'];
for (var typeIndex = 0; typeIndex < space2AnimalTypes.length; typeIndex++) {
var animalType = space2AnimalTypes[typeIndex];
var countInInventory = 0;
for (var invIndex = 0; invIndex < inventory.length; invIndex++) {
if (inventory[invIndex] === animalType) {
countInInventory++;
}
}
if (countInInventory < 3) {
availableSpace2Animals.push(animalType);
}
}
var animal;
if (availableSpace2Animals.length > 0) {
// Special probability distribution for space2 eggs
var random = Math.random();
var selectedAnimal;
if (random < 0.0001) {
selectedAnimal = 'sun'; // 0.01% chance
} else if (random < 0.0011) {
selectedAnimal = 'jupiter'; // 0.1% chance
} else {
selectedAnimal = 'neptune'; // 99.9% chance
}
// Check if selected animal is available
if (availableSpace2Animals.indexOf(selectedAnimal) !== -1) {
animal = selectedAnimal;
} else {
// If selected animal is not available, choose randomly from available
var randomIndex = Math.floor(Math.random() * availableSpace2Animals.length);
animal = availableSpace2Animals[randomIndex];
}
inventory.push(animal);
storage.inventory = inventory;
} else {
// All space2 animal types have 3 in inventory
animal = null;
var allSpace2PetsText = new Text2('All space2 pets maxed out!', {
size: 60,
fill: 0xff0000
});
allSpace2PetsText.anchor.set(0.5, 0.5);
allSpace2PetsText.x = 2048 / 2;
allSpace2PetsText.y = 1500;
game.addChild(allSpace2PetsText);
LK.setTimeout(function () {
allSpace2PetsText.destroy();
}, 2000);
}
// Only show hatched animal if we got a new pet
if (animal) {
var animalSprite = LK.getAsset(animal, {
anchorX: 0.5,
anchorY: 0.5
});
animalSprite.x = fallingEgg.x;
animalSprite.y = fallingEgg.y;
game.addChild(animalSprite);
// Remove animal after showing
LK.setTimeout(function () {
animalSprite.destroy();
}, 2000);
}
// Remove egg
fallingEgg.destroy();
fallingEgg = null;
}
};
}
};
// Handle golden space egg purchase
goldenSpaceEggItem.down = function () {
if (LK.getScore() >= 200000000) {
LK.setScore(LK.getScore() - 200000000);
scoreTxt.setText(LK.getScore().toString());
// Close shop
shopOverlay.destroy();
shopOverlay = null;
isShopOpen = false;
// Create falling golden space egg
fallingEgg = LK.getAsset('goldenSpaceEgg', {
anchorX: 0.5,
anchorY: 0.5
});
fallingEgg.x = 2048 / 2;
fallingEgg.y = -200;
eggClickCount = 0;
game.addChild(fallingEgg);
// Animate egg falling
tween(fallingEgg, {
y: 2732 / 2
}, {
duration: 1000
});
// Handle golden space egg clicking
fallingEgg.down = function () {
eggClickCount++;
if (eggClickCount === 1) {
// First crack
var crackedEgg1 = LK.getAsset('crackedEgg1', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg1.x = fallingEgg.x;
crackedEgg1.y = fallingEgg.y;
game.addChild(crackedEgg1);
fallingEgg.destroy();
fallingEgg = crackedEgg1;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 2) {
// Second crack
var crackedEgg2 = LK.getAsset('crackedEgg2', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg2.x = fallingEgg.x;
crackedEgg2.y = fallingEgg.y;
game.addChild(crackedEgg2);
fallingEgg.destroy();
fallingEgg = crackedEgg2;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 3) {
// Third crack - almost fully cracked
var crackedEgg3 = LK.getAsset('crackedEgg3', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg3.x = fallingEgg.x;
crackedEgg3.y = fallingEgg.y;
game.addChild(crackedEgg3);
fallingEgg.destroy();
fallingEgg = crackedEgg3;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 4) {
// Hatch the golden space egg with special probabilities
var availableGoldenSpaceAnimals = [];
var goldenSpaceAnimalTypes = ['goldenEarth', 'goldenMoon', 'goldenMeteor'];
for (var typeIndex = 0; typeIndex < goldenSpaceAnimalTypes.length; typeIndex++) {
var animalType = goldenSpaceAnimalTypes[typeIndex];
var countInInventory = 0;
for (var invIndex = 0; invIndex < inventory.length; invIndex++) {
if (inventory[invIndex] === animalType) {
countInInventory++;
}
}
if (countInInventory < 3) {
availableGoldenSpaceAnimals.push(animalType);
}
}
var animal;
if (availableGoldenSpaceAnimals.length > 0) {
// Special probability distribution for golden space eggs (same as space)
var random = Math.random();
var selectedAnimal;
if (random < 0.001) {
selectedAnimal = 'goldenEarth'; // 0.1% chance
} else if (random < 0.011) {
selectedAnimal = 'goldenMoon'; // 1% chance
} else {
selectedAnimal = 'goldenMeteor'; // 98.9% chance
}
// Check if selected animal is available
if (availableGoldenSpaceAnimals.indexOf(selectedAnimal) !== -1) {
animal = selectedAnimal;
} else {
// If selected animal is not available, choose randomly from available
var randomIndex = Math.floor(Math.random() * availableGoldenSpaceAnimals.length);
animal = availableGoldenSpaceAnimals[randomIndex];
}
inventory.push(animal);
storage.inventory = inventory;
} else {
// All golden space animal types have 3 in inventory
animal = null;
var allGoldenSpacePetsText = new Text2('All golden space pets maxed out!', {
size: 60,
fill: 0xff0000
});
allGoldenSpacePetsText.anchor.set(0.5, 0.5);
allGoldenSpacePetsText.x = 2048 / 2;
allGoldenSpacePetsText.y = 1500;
game.addChild(allGoldenSpacePetsText);
LK.setTimeout(function () {
allGoldenSpacePetsText.destroy();
}, 2000);
}
// Only show hatched animal if we got a new pet
if (animal) {
var animalSprite = LK.getAsset(animal, {
anchorX: 0.5,
anchorY: 0.5
});
animalSprite.x = fallingEgg.x;
animalSprite.y = fallingEgg.y;
game.addChild(animalSprite);
// Remove animal after showing
LK.setTimeout(function () {
animalSprite.destroy();
}, 2000);
}
// Remove egg
fallingEgg.destroy();
fallingEgg = null;
}
};
}
};
// Handle golden space2 egg purchase
goldenSpace2EggItem.down = function () {
if (LK.getScore() >= 400000000) {
LK.setScore(LK.getScore() - 400000000);
scoreTxt.setText(LK.getScore().toString());
// Close shop
shopOverlay.destroy();
shopOverlay = null;
isShopOpen = false;
// Create falling golden space2 egg
fallingEgg = LK.getAsset('goldenSpace2Egg', {
anchorX: 0.5,
anchorY: 0.5
});
fallingEgg.x = 2048 / 2;
fallingEgg.y = -200;
eggClickCount = 0;
game.addChild(fallingEgg);
// Animate egg falling
tween(fallingEgg, {
y: 2732 / 2
}, {
duration: 1000
});
// Handle golden space2 egg clicking
fallingEgg.down = function () {
eggClickCount++;
if (eggClickCount === 1) {
// First crack
var crackedEgg1 = LK.getAsset('crackedEgg1', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg1.x = fallingEgg.x;
crackedEgg1.y = fallingEgg.y;
game.addChild(crackedEgg1);
fallingEgg.destroy();
fallingEgg = crackedEgg1;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 2) {
// Second crack
var crackedEgg2 = LK.getAsset('crackedEgg2', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg2.x = fallingEgg.x;
crackedEgg2.y = fallingEgg.y;
game.addChild(crackedEgg2);
fallingEgg.destroy();
fallingEgg = crackedEgg2;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 3) {
// Third crack - almost fully cracked
var crackedEgg3 = LK.getAsset('crackedEgg3', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg3.x = fallingEgg.x;
crackedEgg3.y = fallingEgg.y;
game.addChild(crackedEgg3);
fallingEgg.destroy();
fallingEgg = crackedEgg3;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 4) {
// Hatch the golden space2 egg with special probabilities
var availableGoldenSpace2Animals = [];
var goldenSpace2AnimalTypes = ['goldenSun', 'goldenJupiter', 'goldenNeptune'];
for (var typeIndex = 0; typeIndex < goldenSpace2AnimalTypes.length; typeIndex++) {
var animalType = goldenSpace2AnimalTypes[typeIndex];
var countInInventory = 0;
for (var invIndex = 0; invIndex < inventory.length; invIndex++) {
if (inventory[invIndex] === animalType) {
countInInventory++;
}
}
if (countInInventory < 3) {
availableGoldenSpace2Animals.push(animalType);
}
}
var animal;
if (availableGoldenSpace2Animals.length > 0) {
// Special probability distribution for golden space2 eggs (same as space2)
var random = Math.random();
var selectedAnimal;
if (random < 0.0001) {
selectedAnimal = 'goldenSun'; // 0.01% chance
} else if (random < 0.0011) {
selectedAnimal = 'goldenJupiter'; // 0.1% chance
} else {
selectedAnimal = 'goldenNeptune'; // 99.9% chance
}
// Check if selected animal is available
if (availableGoldenSpace2Animals.indexOf(selectedAnimal) !== -1) {
animal = selectedAnimal;
} else {
// If selected animal is not available, choose randomly from available
var randomIndex = Math.floor(Math.random() * availableGoldenSpace2Animals.length);
animal = availableGoldenSpace2Animals[randomIndex];
}
inventory.push(animal);
storage.inventory = inventory;
} else {
// All golden space2 animal types have 3 in inventory
animal = null;
var allGoldenSpace2PetsText = new Text2('All golden space2 pets maxed out!', {
size: 60,
fill: 0xff0000
});
allGoldenSpace2PetsText.anchor.set(0.5, 0.5);
allGoldenSpace2PetsText.x = 2048 / 2;
allGoldenSpace2PetsText.y = 1500;
game.addChild(allGoldenSpace2PetsText);
LK.setTimeout(function () {
allGoldenSpace2PetsText.destroy();
}, 2000);
}
// Only show hatched animal if we got a new pet
if (animal) {
var animalSprite = LK.getAsset(animal, {
anchorX: 0.5,
anchorY: 0.5
});
animalSprite.x = fallingEgg.x;
animalSprite.y = fallingEgg.y;
game.addChild(animalSprite);
// Remove animal after showing
LK.setTimeout(function () {
animalSprite.destroy();
}, 2000);
}
// Remove egg
fallingEgg.destroy();
fallingEgg = null;
}
};
}
};
// Handle inventory button
inventoryBtn.down = function () {
if (!isInventoryOpen) {
// Close shop first
if (shopOverlay) {
shopOverlay.destroy();
}
shopOverlay = null;
isShopOpen = false;
// Open inventory
isInventoryOpen = true;
inventoryOverlay = new Container();
var invBackground = LK.getAsset('shopBg', {
width: 2048,
height: 2732,
color: 0x000000,
shape: 'box'
});
inventoryOverlay.addChild(invBackground);
game.addChild(inventoryOverlay);
// Display inventory items by unique pet types
var yPos = 300;
var uniqueTypes = [];
var animalTypes = ['dog', 'cat', 'snake', 'goldenDog', 'goldenCat', 'goldenSnake', 'dinosaur', 'bear', 'bee', 'goldenDinosaur', 'goldenBear', 'goldenBee', 'trex', 'velector', 'titanaBull', 'goldenTrex', 'goldenVelector', 'goldenTitanaBull', 'ironMan', 'captainAmerica', 'spiderman', 'goldenIronMan', 'goldenCaptainAmerica', 'goldenSpiderman', 'king', 'knight', 'human', 'goldenKing', 'goldenKnight', 'goldenHuman', 'earth', 'moon', 'meteor', 'sun', 'jupiter', 'neptune', 'goldenEarth', 'goldenMoon', 'goldenMeteor', 'goldenSun', 'goldenJupiter', 'goldenNeptune'];
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());
}; ===================================================================
--- original.js
+++ change.js
@@ -84,8 +84,20 @@
var humanCount = 0;
var goldenKingCount = 0;
var goldenKnightCount = 0;
var goldenHumanCount = 0;
+ var earthCount = 0;
+ var moonCount = 0;
+ var meteorCount = 0;
+ var sunCount = 0;
+ var jupiterCount = 0;
+ var neptuneCount = 0;
+ var goldenEarthCount = 0;
+ var goldenMoonCount = 0;
+ var goldenMeteorCount = 0;
+ var goldenSunCount = 0;
+ var goldenJupiterCount = 0;
+ var goldenNeptuneCount = 0;
for (var j = 0; j < equippedAnimals.length; j++) {
if (equippedAnimals[j] === 'dog') {
dogCount++;
} else if (equippedAnimals[j] === 'cat') {
@@ -145,8 +157,32 @@
} else if (equippedAnimals[j] === 'goldenKnight') {
goldenKnightCount++;
} else if (equippedAnimals[j] === 'goldenHuman') {
goldenHumanCount++;
+ } else if (equippedAnimals[j] === 'earth') {
+ earthCount++;
+ } else if (equippedAnimals[j] === 'moon') {
+ moonCount++;
+ } else if (equippedAnimals[j] === 'meteor') {
+ meteorCount++;
+ } else if (equippedAnimals[j] === 'sun') {
+ sunCount++;
+ } else if (equippedAnimals[j] === 'jupiter') {
+ jupiterCount++;
+ } else if (equippedAnimals[j] === 'neptune') {
+ neptuneCount++;
+ } else if (equippedAnimals[j] === 'goldenEarth') {
+ goldenEarthCount++;
+ } else if (equippedAnimals[j] === 'goldenMoon') {
+ goldenMoonCount++;
+ } else if (equippedAnimals[j] === 'goldenMeteor') {
+ goldenMeteorCount++;
+ } else if (equippedAnimals[j] === 'goldenSun') {
+ goldenSunCount++;
+ } else if (equippedAnimals[j] === 'goldenJupiter') {
+ goldenJupiterCount++;
+ } else if (equippedAnimals[j] === 'goldenNeptune') {
+ goldenNeptuneCount++;
}
}
// Each dog gives +1 bonus per tap
petBonus += dogCount;
@@ -390,8 +426,106 @@
petBonus += 10000;
} else if (goldenHumanCount === 3) {
petBonus += 15000;
}
+ // Space egg pets bonuses
+ // Earth: 1 = +100000, 2 = +200000, 3 = +300000 per tap
+ if (earthCount === 1) {
+ petBonus += 100000;
+ } else if (earthCount === 2) {
+ petBonus += 200000;
+ } else if (earthCount === 3) {
+ petBonus += 300000;
+ }
+ // Moon: 1 = +50000, 2 = +100000, 3 = +150000 per tap
+ if (moonCount === 1) {
+ petBonus += 50000;
+ } else if (moonCount === 2) {
+ petBonus += 100000;
+ } else if (moonCount === 3) {
+ petBonus += 150000;
+ }
+ // Meteor: 1 = +25000, 2 = +50000, 3 = +75000 per tap
+ if (meteorCount === 1) {
+ petBonus += 25000;
+ } else if (meteorCount === 2) {
+ petBonus += 50000;
+ } else if (meteorCount === 3) {
+ petBonus += 75000;
+ }
+ // Sun: 1 = +500000, 2 = +1000000, 3 = +1500000 per tap
+ if (sunCount === 1) {
+ petBonus += 500000;
+ } else if (sunCount === 2) {
+ petBonus += 1000000;
+ } else if (sunCount === 3) {
+ petBonus += 1500000;
+ }
+ // Jupiter: 1 = +250000, 2 = +500000, 3 = +750000 per tap
+ if (jupiterCount === 1) {
+ petBonus += 250000;
+ } else if (jupiterCount === 2) {
+ petBonus += 500000;
+ } else if (jupiterCount === 3) {
+ petBonus += 750000;
+ }
+ // Neptune: 1 = +200000, 2 = +400000, 3 = +600000 per tap
+ if (neptuneCount === 1) {
+ petBonus += 200000;
+ } else if (neptuneCount === 2) {
+ petBonus += 400000;
+ } else if (neptuneCount === 3) {
+ petBonus += 600000;
+ }
+ // Golden space egg pets bonuses (2x multiplier)
+ // Golden Earth: 1 = +200000, 2 = +400000, 3 = +600000 per tap
+ if (goldenEarthCount === 1) {
+ petBonus += 200000;
+ } else if (goldenEarthCount === 2) {
+ petBonus += 400000;
+ } else if (goldenEarthCount === 3) {
+ petBonus += 600000;
+ }
+ // Golden Moon: 1 = +100000, 2 = +200000, 3 = +300000 per tap
+ if (goldenMoonCount === 1) {
+ petBonus += 100000;
+ } else if (goldenMoonCount === 2) {
+ petBonus += 200000;
+ } else if (goldenMoonCount === 3) {
+ petBonus += 300000;
+ }
+ // Golden Meteor: 1 = +50000, 2 = +100000, 3 = +150000 per tap
+ if (goldenMeteorCount === 1) {
+ petBonus += 50000;
+ } else if (goldenMeteorCount === 2) {
+ petBonus += 100000;
+ } else if (goldenMeteorCount === 3) {
+ petBonus += 150000;
+ }
+ // Golden Sun: 1 = +1000000, 2 = +2000000, 3 = +3000000 per tap
+ if (goldenSunCount === 1) {
+ petBonus += 1000000;
+ } else if (goldenSunCount === 2) {
+ petBonus += 2000000;
+ } else if (goldenSunCount === 3) {
+ petBonus += 3000000;
+ }
+ // Golden Jupiter: 1 = +500000, 2 = +1000000, 3 = +1500000 per tap
+ if (goldenJupiterCount === 1) {
+ petBonus += 500000;
+ } else if (goldenJupiterCount === 2) {
+ petBonus += 1000000;
+ } else if (goldenJupiterCount === 3) {
+ petBonus += 1500000;
+ }
+ // Golden Neptune: 1 = +400000, 2 = +800000, 3 = +1200000 per tap
+ if (goldenNeptuneCount === 1) {
+ petBonus += 400000;
+ } else if (goldenNeptuneCount === 2) {
+ petBonus += 800000;
+ } else if (goldenNeptuneCount === 3) {
+ petBonus += 1200000;
+ }
// Base tap score is always 1, plus calculated pet bonus
var totalScore = 1 + petBonus;
LK.setScore(LK.getScore() + totalScore);
// Update score display
@@ -477,8 +611,16 @@
}, {
asset: 'whiteEgg',
price: '10M',
color: 0xffffff
+ }, {
+ asset: 'spaceEgg',
+ price: '100M',
+ color: 0x4169e1
+ }, {
+ asset: 'space2Egg',
+ price: '200M',
+ color: 0x8a2be2
}];
// Golden eggs data
var goldenEggs = [{
asset: 'goldenEgg',
@@ -499,8 +641,16 @@
}, {
asset: 'goldenWhiteEgg',
price: '20M',
color: 0xffd700
+ }, {
+ asset: 'goldenSpaceEgg',
+ price: '200M',
+ color: 0xffd700
+ }, {
+ asset: 'goldenSpace2Egg',
+ price: '400M',
+ color: 0xffd700
}];
// Display normal eggs section
var normalEggItems = [];
var startY = 600;
@@ -576,8 +726,12 @@
var goldenGreenEggItem = goldenEggItems[1];
var goldenRedEggItem = goldenEggItems[2];
var goldenPurpleEggItem = goldenEggItems[3];
var goldenWhiteEggItem = goldenEggItems[4];
+ var spaceEggItem = normalEggItems[5];
+ var space2EggItem = normalEggItems[6];
+ var goldenSpaceEggItem = goldenEggItems[5];
+ var goldenSpace2EggItem = goldenEggItems[6];
// Handle egg purchase
eggItem.down = function () {
if (LK.getScore() >= 1000) {
LK.setScore(LK.getScore() - 1000);
@@ -1933,8 +2087,556 @@
}
};
}
};
+ // Handle space egg purchase
+ spaceEggItem.down = function () {
+ if (LK.getScore() >= 100000000) {
+ LK.setScore(LK.getScore() - 100000000);
+ scoreTxt.setText(LK.getScore().toString());
+ // Close shop
+ shopOverlay.destroy();
+ shopOverlay = null;
+ isShopOpen = false;
+ // Create falling space egg
+ fallingEgg = LK.getAsset('spaceEgg', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ fallingEgg.x = 2048 / 2;
+ fallingEgg.y = -200;
+ eggClickCount = 0;
+ game.addChild(fallingEgg);
+ // Animate egg falling
+ tween(fallingEgg, {
+ y: 2732 / 2
+ }, {
+ duration: 1000
+ });
+ // Handle space egg clicking
+ fallingEgg.down = function () {
+ eggClickCount++;
+ if (eggClickCount === 1) {
+ // First crack
+ var crackedEgg1 = LK.getAsset('crackedEgg1', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ crackedEgg1.x = fallingEgg.x;
+ crackedEgg1.y = fallingEgg.y;
+ game.addChild(crackedEgg1);
+ fallingEgg.destroy();
+ fallingEgg = crackedEgg1;
+ fallingEgg.down = arguments.callee;
+ } else if (eggClickCount === 2) {
+ // Second crack
+ var crackedEgg2 = LK.getAsset('crackedEgg2', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ crackedEgg2.x = fallingEgg.x;
+ crackedEgg2.y = fallingEgg.y;
+ game.addChild(crackedEgg2);
+ fallingEgg.destroy();
+ fallingEgg = crackedEgg2;
+ fallingEgg.down = arguments.callee;
+ } else if (eggClickCount === 3) {
+ // Third crack - almost fully cracked
+ var crackedEgg3 = LK.getAsset('crackedEgg3', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ crackedEgg3.x = fallingEgg.x;
+ crackedEgg3.y = fallingEgg.y;
+ game.addChild(crackedEgg3);
+ fallingEgg.destroy();
+ fallingEgg = crackedEgg3;
+ fallingEgg.down = arguments.callee;
+ } else if (eggClickCount === 4) {
+ // Hatch the space egg with special probabilities
+ var availableSpaceAnimals = [];
+ var spaceAnimalTypes = ['earth', 'moon', 'meteor'];
+ for (var typeIndex = 0; typeIndex < spaceAnimalTypes.length; typeIndex++) {
+ var animalType = spaceAnimalTypes[typeIndex];
+ var countInInventory = 0;
+ for (var invIndex = 0; invIndex < inventory.length; invIndex++) {
+ if (inventory[invIndex] === animalType) {
+ countInInventory++;
+ }
+ }
+ if (countInInventory < 3) {
+ availableSpaceAnimals.push(animalType);
+ }
+ }
+ var animal;
+ if (availableSpaceAnimals.length > 0) {
+ // Special probability distribution for space eggs
+ var random = Math.random();
+ var selectedAnimal;
+ if (random < 0.001) {
+ selectedAnimal = 'earth'; // 0.1% chance
+ } else if (random < 0.011) {
+ selectedAnimal = 'moon'; // 1% chance
+ } else {
+ selectedAnimal = 'meteor'; // 98.9% chance
+ }
+ // Check if selected animal is available
+ if (availableSpaceAnimals.indexOf(selectedAnimal) !== -1) {
+ animal = selectedAnimal;
+ } else {
+ // If selected animal is not available, choose randomly from available
+ var randomIndex = Math.floor(Math.random() * availableSpaceAnimals.length);
+ animal = availableSpaceAnimals[randomIndex];
+ }
+ inventory.push(animal);
+ storage.inventory = inventory;
+ } else {
+ // All space animal types have 3 in inventory
+ animal = null;
+ var allSpacePetsText = new Text2('All space pets maxed out!', {
+ size: 60,
+ fill: 0xff0000
+ });
+ allSpacePetsText.anchor.set(0.5, 0.5);
+ allSpacePetsText.x = 2048 / 2;
+ allSpacePetsText.y = 1500;
+ game.addChild(allSpacePetsText);
+ LK.setTimeout(function () {
+ allSpacePetsText.destroy();
+ }, 2000);
+ }
+ // Only show hatched animal if we got a new pet
+ if (animal) {
+ var animalSprite = LK.getAsset(animal, {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ animalSprite.x = fallingEgg.x;
+ animalSprite.y = fallingEgg.y;
+ game.addChild(animalSprite);
+ // Remove animal after showing
+ LK.setTimeout(function () {
+ animalSprite.destroy();
+ }, 2000);
+ }
+ // Remove egg
+ fallingEgg.destroy();
+ fallingEgg = null;
+ }
+ };
+ }
+ };
+ // Handle space2 egg purchase
+ space2EggItem.down = function () {
+ if (LK.getScore() >= 200000000) {
+ LK.setScore(LK.getScore() - 200000000);
+ scoreTxt.setText(LK.getScore().toString());
+ // Close shop
+ shopOverlay.destroy();
+ shopOverlay = null;
+ isShopOpen = false;
+ // Create falling space2 egg
+ fallingEgg = LK.getAsset('space2Egg', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ fallingEgg.x = 2048 / 2;
+ fallingEgg.y = -200;
+ eggClickCount = 0;
+ game.addChild(fallingEgg);
+ // Animate egg falling
+ tween(fallingEgg, {
+ y: 2732 / 2
+ }, {
+ duration: 1000
+ });
+ // Handle space2 egg clicking
+ fallingEgg.down = function () {
+ eggClickCount++;
+ if (eggClickCount === 1) {
+ // First crack
+ var crackedEgg1 = LK.getAsset('crackedEgg1', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ crackedEgg1.x = fallingEgg.x;
+ crackedEgg1.y = fallingEgg.y;
+ game.addChild(crackedEgg1);
+ fallingEgg.destroy();
+ fallingEgg = crackedEgg1;
+ fallingEgg.down = arguments.callee;
+ } else if (eggClickCount === 2) {
+ // Second crack
+ var crackedEgg2 = LK.getAsset('crackedEgg2', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ crackedEgg2.x = fallingEgg.x;
+ crackedEgg2.y = fallingEgg.y;
+ game.addChild(crackedEgg2);
+ fallingEgg.destroy();
+ fallingEgg = crackedEgg2;
+ fallingEgg.down = arguments.callee;
+ } else if (eggClickCount === 3) {
+ // Third crack - almost fully cracked
+ var crackedEgg3 = LK.getAsset('crackedEgg3', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ crackedEgg3.x = fallingEgg.x;
+ crackedEgg3.y = fallingEgg.y;
+ game.addChild(crackedEgg3);
+ fallingEgg.destroy();
+ fallingEgg = crackedEgg3;
+ fallingEgg.down = arguments.callee;
+ } else if (eggClickCount === 4) {
+ // Hatch the space2 egg with special probabilities
+ var availableSpace2Animals = [];
+ var space2AnimalTypes = ['sun', 'jupiter', 'neptune'];
+ for (var typeIndex = 0; typeIndex < space2AnimalTypes.length; typeIndex++) {
+ var animalType = space2AnimalTypes[typeIndex];
+ var countInInventory = 0;
+ for (var invIndex = 0; invIndex < inventory.length; invIndex++) {
+ if (inventory[invIndex] === animalType) {
+ countInInventory++;
+ }
+ }
+ if (countInInventory < 3) {
+ availableSpace2Animals.push(animalType);
+ }
+ }
+ var animal;
+ if (availableSpace2Animals.length > 0) {
+ // Special probability distribution for space2 eggs
+ var random = Math.random();
+ var selectedAnimal;
+ if (random < 0.0001) {
+ selectedAnimal = 'sun'; // 0.01% chance
+ } else if (random < 0.0011) {
+ selectedAnimal = 'jupiter'; // 0.1% chance
+ } else {
+ selectedAnimal = 'neptune'; // 99.9% chance
+ }
+ // Check if selected animal is available
+ if (availableSpace2Animals.indexOf(selectedAnimal) !== -1) {
+ animal = selectedAnimal;
+ } else {
+ // If selected animal is not available, choose randomly from available
+ var randomIndex = Math.floor(Math.random() * availableSpace2Animals.length);
+ animal = availableSpace2Animals[randomIndex];
+ }
+ inventory.push(animal);
+ storage.inventory = inventory;
+ } else {
+ // All space2 animal types have 3 in inventory
+ animal = null;
+ var allSpace2PetsText = new Text2('All space2 pets maxed out!', {
+ size: 60,
+ fill: 0xff0000
+ });
+ allSpace2PetsText.anchor.set(0.5, 0.5);
+ allSpace2PetsText.x = 2048 / 2;
+ allSpace2PetsText.y = 1500;
+ game.addChild(allSpace2PetsText);
+ LK.setTimeout(function () {
+ allSpace2PetsText.destroy();
+ }, 2000);
+ }
+ // Only show hatched animal if we got a new pet
+ if (animal) {
+ var animalSprite = LK.getAsset(animal, {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ animalSprite.x = fallingEgg.x;
+ animalSprite.y = fallingEgg.y;
+ game.addChild(animalSprite);
+ // Remove animal after showing
+ LK.setTimeout(function () {
+ animalSprite.destroy();
+ }, 2000);
+ }
+ // Remove egg
+ fallingEgg.destroy();
+ fallingEgg = null;
+ }
+ };
+ }
+ };
+ // Handle golden space egg purchase
+ goldenSpaceEggItem.down = function () {
+ if (LK.getScore() >= 200000000) {
+ LK.setScore(LK.getScore() - 200000000);
+ scoreTxt.setText(LK.getScore().toString());
+ // Close shop
+ shopOverlay.destroy();
+ shopOverlay = null;
+ isShopOpen = false;
+ // Create falling golden space egg
+ fallingEgg = LK.getAsset('goldenSpaceEgg', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ fallingEgg.x = 2048 / 2;
+ fallingEgg.y = -200;
+ eggClickCount = 0;
+ game.addChild(fallingEgg);
+ // Animate egg falling
+ tween(fallingEgg, {
+ y: 2732 / 2
+ }, {
+ duration: 1000
+ });
+ // Handle golden space egg clicking
+ fallingEgg.down = function () {
+ eggClickCount++;
+ if (eggClickCount === 1) {
+ // First crack
+ var crackedEgg1 = LK.getAsset('crackedEgg1', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ crackedEgg1.x = fallingEgg.x;
+ crackedEgg1.y = fallingEgg.y;
+ game.addChild(crackedEgg1);
+ fallingEgg.destroy();
+ fallingEgg = crackedEgg1;
+ fallingEgg.down = arguments.callee;
+ } else if (eggClickCount === 2) {
+ // Second crack
+ var crackedEgg2 = LK.getAsset('crackedEgg2', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ crackedEgg2.x = fallingEgg.x;
+ crackedEgg2.y = fallingEgg.y;
+ game.addChild(crackedEgg2);
+ fallingEgg.destroy();
+ fallingEgg = crackedEgg2;
+ fallingEgg.down = arguments.callee;
+ } else if (eggClickCount === 3) {
+ // Third crack - almost fully cracked
+ var crackedEgg3 = LK.getAsset('crackedEgg3', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ crackedEgg3.x = fallingEgg.x;
+ crackedEgg3.y = fallingEgg.y;
+ game.addChild(crackedEgg3);
+ fallingEgg.destroy();
+ fallingEgg = crackedEgg3;
+ fallingEgg.down = arguments.callee;
+ } else if (eggClickCount === 4) {
+ // Hatch the golden space egg with special probabilities
+ var availableGoldenSpaceAnimals = [];
+ var goldenSpaceAnimalTypes = ['goldenEarth', 'goldenMoon', 'goldenMeteor'];
+ for (var typeIndex = 0; typeIndex < goldenSpaceAnimalTypes.length; typeIndex++) {
+ var animalType = goldenSpaceAnimalTypes[typeIndex];
+ var countInInventory = 0;
+ for (var invIndex = 0; invIndex < inventory.length; invIndex++) {
+ if (inventory[invIndex] === animalType) {
+ countInInventory++;
+ }
+ }
+ if (countInInventory < 3) {
+ availableGoldenSpaceAnimals.push(animalType);
+ }
+ }
+ var animal;
+ if (availableGoldenSpaceAnimals.length > 0) {
+ // Special probability distribution for golden space eggs (same as space)
+ var random = Math.random();
+ var selectedAnimal;
+ if (random < 0.001) {
+ selectedAnimal = 'goldenEarth'; // 0.1% chance
+ } else if (random < 0.011) {
+ selectedAnimal = 'goldenMoon'; // 1% chance
+ } else {
+ selectedAnimal = 'goldenMeteor'; // 98.9% chance
+ }
+ // Check if selected animal is available
+ if (availableGoldenSpaceAnimals.indexOf(selectedAnimal) !== -1) {
+ animal = selectedAnimal;
+ } else {
+ // If selected animal is not available, choose randomly from available
+ var randomIndex = Math.floor(Math.random() * availableGoldenSpaceAnimals.length);
+ animal = availableGoldenSpaceAnimals[randomIndex];
+ }
+ inventory.push(animal);
+ storage.inventory = inventory;
+ } else {
+ // All golden space animal types have 3 in inventory
+ animal = null;
+ var allGoldenSpacePetsText = new Text2('All golden space pets maxed out!', {
+ size: 60,
+ fill: 0xff0000
+ });
+ allGoldenSpacePetsText.anchor.set(0.5, 0.5);
+ allGoldenSpacePetsText.x = 2048 / 2;
+ allGoldenSpacePetsText.y = 1500;
+ game.addChild(allGoldenSpacePetsText);
+ LK.setTimeout(function () {
+ allGoldenSpacePetsText.destroy();
+ }, 2000);
+ }
+ // Only show hatched animal if we got a new pet
+ if (animal) {
+ var animalSprite = LK.getAsset(animal, {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ animalSprite.x = fallingEgg.x;
+ animalSprite.y = fallingEgg.y;
+ game.addChild(animalSprite);
+ // Remove animal after showing
+ LK.setTimeout(function () {
+ animalSprite.destroy();
+ }, 2000);
+ }
+ // Remove egg
+ fallingEgg.destroy();
+ fallingEgg = null;
+ }
+ };
+ }
+ };
+ // Handle golden space2 egg purchase
+ goldenSpace2EggItem.down = function () {
+ if (LK.getScore() >= 400000000) {
+ LK.setScore(LK.getScore() - 400000000);
+ scoreTxt.setText(LK.getScore().toString());
+ // Close shop
+ shopOverlay.destroy();
+ shopOverlay = null;
+ isShopOpen = false;
+ // Create falling golden space2 egg
+ fallingEgg = LK.getAsset('goldenSpace2Egg', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ fallingEgg.x = 2048 / 2;
+ fallingEgg.y = -200;
+ eggClickCount = 0;
+ game.addChild(fallingEgg);
+ // Animate egg falling
+ tween(fallingEgg, {
+ y: 2732 / 2
+ }, {
+ duration: 1000
+ });
+ // Handle golden space2 egg clicking
+ fallingEgg.down = function () {
+ eggClickCount++;
+ if (eggClickCount === 1) {
+ // First crack
+ var crackedEgg1 = LK.getAsset('crackedEgg1', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ crackedEgg1.x = fallingEgg.x;
+ crackedEgg1.y = fallingEgg.y;
+ game.addChild(crackedEgg1);
+ fallingEgg.destroy();
+ fallingEgg = crackedEgg1;
+ fallingEgg.down = arguments.callee;
+ } else if (eggClickCount === 2) {
+ // Second crack
+ var crackedEgg2 = LK.getAsset('crackedEgg2', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ crackedEgg2.x = fallingEgg.x;
+ crackedEgg2.y = fallingEgg.y;
+ game.addChild(crackedEgg2);
+ fallingEgg.destroy();
+ fallingEgg = crackedEgg2;
+ fallingEgg.down = arguments.callee;
+ } else if (eggClickCount === 3) {
+ // Third crack - almost fully cracked
+ var crackedEgg3 = LK.getAsset('crackedEgg3', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ crackedEgg3.x = fallingEgg.x;
+ crackedEgg3.y = fallingEgg.y;
+ game.addChild(crackedEgg3);
+ fallingEgg.destroy();
+ fallingEgg = crackedEgg3;
+ fallingEgg.down = arguments.callee;
+ } else if (eggClickCount === 4) {
+ // Hatch the golden space2 egg with special probabilities
+ var availableGoldenSpace2Animals = [];
+ var goldenSpace2AnimalTypes = ['goldenSun', 'goldenJupiter', 'goldenNeptune'];
+ for (var typeIndex = 0; typeIndex < goldenSpace2AnimalTypes.length; typeIndex++) {
+ var animalType = goldenSpace2AnimalTypes[typeIndex];
+ var countInInventory = 0;
+ for (var invIndex = 0; invIndex < inventory.length; invIndex++) {
+ if (inventory[invIndex] === animalType) {
+ countInInventory++;
+ }
+ }
+ if (countInInventory < 3) {
+ availableGoldenSpace2Animals.push(animalType);
+ }
+ }
+ var animal;
+ if (availableGoldenSpace2Animals.length > 0) {
+ // Special probability distribution for golden space2 eggs (same as space2)
+ var random = Math.random();
+ var selectedAnimal;
+ if (random < 0.0001) {
+ selectedAnimal = 'goldenSun'; // 0.01% chance
+ } else if (random < 0.0011) {
+ selectedAnimal = 'goldenJupiter'; // 0.1% chance
+ } else {
+ selectedAnimal = 'goldenNeptune'; // 99.9% chance
+ }
+ // Check if selected animal is available
+ if (availableGoldenSpace2Animals.indexOf(selectedAnimal) !== -1) {
+ animal = selectedAnimal;
+ } else {
+ // If selected animal is not available, choose randomly from available
+ var randomIndex = Math.floor(Math.random() * availableGoldenSpace2Animals.length);
+ animal = availableGoldenSpace2Animals[randomIndex];
+ }
+ inventory.push(animal);
+ storage.inventory = inventory;
+ } else {
+ // All golden space2 animal types have 3 in inventory
+ animal = null;
+ var allGoldenSpace2PetsText = new Text2('All golden space2 pets maxed out!', {
+ size: 60,
+ fill: 0xff0000
+ });
+ allGoldenSpace2PetsText.anchor.set(0.5, 0.5);
+ allGoldenSpace2PetsText.x = 2048 / 2;
+ allGoldenSpace2PetsText.y = 1500;
+ game.addChild(allGoldenSpace2PetsText);
+ LK.setTimeout(function () {
+ allGoldenSpace2PetsText.destroy();
+ }, 2000);
+ }
+ // Only show hatched animal if we got a new pet
+ if (animal) {
+ var animalSprite = LK.getAsset(animal, {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ animalSprite.x = fallingEgg.x;
+ animalSprite.y = fallingEgg.y;
+ game.addChild(animalSprite);
+ // Remove animal after showing
+ LK.setTimeout(function () {
+ animalSprite.destroy();
+ }, 2000);
+ }
+ // Remove egg
+ fallingEgg.destroy();
+ fallingEgg = null;
+ }
+ };
+ }
+ };
// Handle inventory button
inventoryBtn.down = function () {
if (!isInventoryOpen) {
// Close shop first
@@ -1956,9 +2658,9 @@
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'];
+ var animalTypes = ['dog', 'cat', 'snake', 'goldenDog', 'goldenCat', 'goldenSnake', 'dinosaur', 'bear', 'bee', 'goldenDinosaur', 'goldenBear', 'goldenBee', 'trex', 'velector', 'titanaBull', 'goldenTrex', 'goldenVelector', 'goldenTitanaBull', 'ironMan', 'captainAmerica', 'spiderman', 'goldenIronMan', 'goldenCaptainAmerica', 'goldenSpiderman', 'king', 'knight', 'human', 'goldenKing', 'goldenKnight', 'goldenHuman', 'earth', 'moon', 'meteor', 'sun', 'jupiter', 'neptune', 'goldenEarth', 'goldenMoon', 'goldenMeteor', 'goldenSun', 'goldenJupiter', 'goldenNeptune'];
for (var typeIndex = 0; typeIndex < animalTypes.length; typeIndex++) {
var animalType = animalTypes[typeIndex];
var countInInventory = 0;
for (var invIndex = 0; invIndex < inventory.length; invIndex++) {