User prompt
120 fps seçildinde her tokladında gelen score yazısı +1 ekranda ve 0 sayısın üstünde +1 veya o score çıksın ve score eklensin ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
120 fps seçtinde gelen +1 yazsın ekranda gelsin ve +1 yasını score üstünde çıksın +1 yazısı çıksın ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
120 fps semtinde güneş detayını sil güneş ve ay olmasın
User prompt
Güneş sarı olsun ve etrafa ışık ile aydınlatsın 120 fps te ve etrafta sabah ken aydınlık olsun sarı olsun böyle saydam güneşte ışık gelsin ve rainy system de olsun yağmur da yağsın ↪💡 Consider importing and using the following plugins: @upit/tween.v1
Code edit (1 edits merged)
Please save this source code
User prompt
120 fps seçildinde ekranda yağmur yağsın yağmur her 5 dakak sürüsün her 10 dakka bir yağmur yağsın ve su damlası yere damlasında aynı su gibi shock wawe olsunşun yağmur shock wawe ve üsttede saat ya,sın gerçek hayattan 20x hızlı geçsin saat dakka yazsın ve ekranda güneş olsun saat ilerledikçe batsın battı zaman ay ortaya çıksın ve etraf gece olsun ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Ekranda ağaç detaylarını sil
User prompt
120 fps te ekrana helen agaç detaylarını sil
User prompt
Oyundaki 120 fps seçildinde ekrana kelen normal ağaç ve çam ağacının detaylarını kaldırın
User prompt
120 fps teli taş yollar Araçlar kamp ateşi odun bu eşyaları kaldır
User prompt
Menü deki 120 fps seçildinde etrafa ultra gerçekçi ekrana gerçekçi ağaçlar dalları olan çam ağacı sonra normal ağaç ikisine birisi sağda birisi solda ortada yuvarlak gerçekçi ultra gerçekçi detaylı bir uzun odun etrafta taş yollar ve en ortada bir bir kam ateşi gerçekçi alev animasyonu ve yukarı doğru animasyon çıksın etrafında 2 tane odun olsun odunlar ultra gerçekçi çok fazla gerçekçi odun üstünde çizgiler detaylar cam ayaklar ultra mega gerçekçi ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Menü deki 120 fps tıklama animasyon ve yazılar daha detaylı daha gerçekçi olsun ve yumurtalar dış görünüş daha detaylı ve gerçekçi olsun ve yumurtaları açılma animasyon her tıkaldında çatlasın ve sağ sola haraket etsin 3 defa çatlasın 4 defa tıkaldımızda çatlatan bir sarı ışık çıksın saydam fener gibi bir sarı ışık çıksın ve oradaki bir pet ekrana doğru gelsin ve yumurta altta doğru duşun yok olsun çıktık tam sonra ekrana doğru yaklaştın ve ekrana geldikten sonra ekranda 2 3 saniye dursun ve altta özellikleri tıklama başına kac score geldiği kaç şans ile çıktı nadirlik yüzde kaç oranla çıktığı yazsın ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Menüdeki 90 fps seçildin +1 tıkalmama basın gelen +1 puan yazısı veya yazılar daha detaylı ve gerçekçi olsun ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
120 fps çıkan shock wawe yuvarlak olsun ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Menü deki 120 fps Secildinde 120 fps score yazısı aşağa doğru gitmesin oldu yerde dursun sadece helen puan ona doğru ilelrisin carptında score yazısı artsın ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Menü deki 120 fps seçildinde tıklama animasyonu ayrietten shock wawe oluşsun beyaz tıkladın yerde ve +1 yazsın ve score yazsın doğru gitsin ve score yazısının üstüne +1 yazsın ve 0 yazısının aşağına doğru insin ve 0 deydi anda 1 dönüşsün ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
120 fps seçiminde aynı şekilde yumurtaların dış görünüşüne güzelleşsin ve detaylarını artır ve aynı şekilde açılış animasyonu daha kaliteli kırılma animasyonu çatlama animasyonu ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Menü button birazdan sağa doğru çek
User prompt
Sol üste add menü buton 2 tane alt altta 3 tane düz kalım çizgi olsun açmak için üstüne tıklıyalım kapatmak için bşdaha üstüne tıklıyaoım menü açıldında en üste grapichs olsun 3 tane birisi 30fps için ekran bilan animasyon kötü w. 60 fps yani normal herşey 90fos yüksek bütün animasyonlar kaliteli aha çok yumurtalar daha detaylı olsun en yüksek 90 fps yanında 120 fps ve ultra gerçekçi yumurtalar çok detaylı olsun tıklayınca gelen animasyon detayı gelen score animasyonlu şekilde üste doğru gitsin ve +1 yazarak eklensin ve ultra gerçekçi grafikler görüntüler olsun ama çok fazla örneği yumurta açılış animasyonu sağ sola haraket etsin ve ensende çatlasın ve aralıkla ışık çıksın ve ondan pet çıksın ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Lucky boost class delete
User prompt
Lucky boost Shop add 1 mimitues 10000 score 5 mimitues 50000 scoe 10 minitues 100000 score Lucky boost yumurtaları etkili her zaman en düşük ihtimalle çıkan 2 peti şansını 10x artırrır ama en çok ihtimalle çıkan pet 10x duyurur yani 1 peti duyurur diyr en duşun ve en çok score olan me çok düşük ihtimalle çıkan 2 peti 10x arttır şansını ama diğeri en çok ihtimalle çıkanın en güçsüz peti 10x şansını düşürür
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var Pet = Container.expand(function (petType, rarity, bonusPerTap, dropChance) {
var self = Container.call(this);
self.petType = petType;
self.rarity = rarity;
self.bonusPerTap = bonusPerTap;
self.dropChance = dropChance;
// Create pet sprite
var petSprite = self.attachAsset(petType, {
anchorX: 0.5,
anchorY: 0.5
});
// Scale for enhanced mode
if (ultraRealisticMode) {
petSprite.scaleX = 1.2;
petSprite.scaleY = 1.2;
}
// Animate pet entrance
self.animateEntrance = function () {
if (ultraRealisticMode) {
// Start from small and grow
petSprite.scaleX = 0.1;
petSprite.scaleY = 0.1;
petSprite.alpha = 0;
// Animate growth and fade in
tween(petSprite, {
scaleX: 1.2,
scaleY: 1.2,
alpha: 1
}, {
duration: 1000,
easing: tween.bounceOut
});
// Add spinning effect
tween(petSprite, {
rotation: Math.PI * 2
}, {
duration: 1500,
easing: tween.easeOut
});
}
};
// Show pet info
self.showInfo = function () {
var infoBg = LK.getAsset('petInfoBg', {
anchorX: 0.5,
anchorY: 0.5
});
infoBg.x = 2048 / 2;
infoBg.y = 2732 / 2;
game.addChild(infoBg);
// Pet name
var nameText = new Text2(self.petType.toUpperCase(), {
size: 80,
fill: 0xFFD700
});
nameText.anchor.set(0.5, 0.5);
nameText.x = 2048 / 2;
nameText.y = 2732 / 2 - 150;
game.addChild(nameText);
// Bonus info
var bonusText = new Text2('Score per tap: +' + self.bonusPerTap, {
size: 60,
fill: 0xFFFFFF
});
bonusText.anchor.set(0.5, 0.5);
bonusText.x = 2048 / 2;
bonusText.y = 2732 / 2 - 50;
game.addChild(bonusText);
// Rarity info
var rarityText = new Text2('Rarity: ' + self.rarity, {
size: 60,
fill: 0x00FF00
});
rarityText.anchor.set(0.5, 0.5);
rarityText.x = 2048 / 2;
rarityText.y = 2732 / 2 + 50;
game.addChild(rarityText);
// Drop chance info
var chanceText = new Text2('Drop chance: ' + (self.dropChance * 100).toFixed(2) + '%', {
size: 60,
fill: 0xFF6B6B
});
chanceText.anchor.set(0.5, 0.5);
chanceText.x = 2048 / 2;
chanceText.y = 2732 / 2 + 150;
game.addChild(chanceText);
// Auto-hide after 3 seconds
LK.setTimeout(function () {
infoBg.destroy();
nameText.destroy();
bonusText.destroy();
rarityText.destroy();
chanceText.destroy();
}, 3000);
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x2c3e50 // Dark blue-gray background
});
/****
* Game Code
****/
// Reset all storage on game start
// Enhanced egg assets for 120 fps ultra-realistic mode
// Enhanced cracked egg assets for 120 fps mode
// Ultra-realistic environment assets for 120 fps mode
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;
// Graphics settings variables
var graphicsMode = 60; // 30, 60, 90, 120 fps
var isMenuOpen = false;
var menuOverlay = null;
var ultraRealisticMode = false;
// Rain system variables
var rainDrops = [];
var isRaining = false;
var rainTimer = 0;
var rainDuration = 300000; // 5 minutes in milliseconds
var rainInterval = 600000; // 10 minutes in milliseconds
var nextRainTime = 0;
// Clock system variables (20x faster than real time)
var gameTime = 0; // Game time in milliseconds
var clockDisplay = null;
var sunElement = null;
var moonElement = null;
var isDayTime = true;
var skyTint = 0xffffff;
// Function to get enhanced egg asset based on graphics mode
function getEnhancedEggAsset(baseAssetName, anchorSettings) {
var assetName = baseAssetName;
if (ultraRealisticMode && graphicsMode === 120) {
assetName = baseAssetName + 'Ultra';
}
return LK.getAsset(assetName, {});
}
// 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;
// Create menu button in top-left (avoiding the platform menu icon area)
var menuBtn = new Container();
var menuBg = LK.getAsset('menuButton', {
anchorX: 0.5,
anchorY: 0.5
});
menuBtn.addChild(menuBg);
// Add hamburger lines
var line1 = LK.getAsset('menuLine', {
anchorX: 0.5,
anchorY: 0.5
});
line1.y = -15;
menuBtn.addChild(line1);
var line2 = LK.getAsset('menuLine', {
anchorX: 0.5,
anchorY: 0.5
});
menuBtn.addChild(line2);
var line3 = LK.getAsset('menuLine', {
anchorX: 0.5,
anchorY: 0.5
});
line3.y = 15;
menuBtn.addChild(line3);
// Position menu button at top-right with safe padding
menuBtn.x = 2048 - 150;
menuBtn.y = 150;
game.addChild(menuBtn);
// Add ultra-realistic environment for 120 fps mode
var environmentElements = [];
function createUltraRealisticEnvironment() {
if (ultraRealisticMode && graphicsMode === 120) {
// Animation functions removed with campfire
// Pine tree creation removed
// Normal tree creation removed
// Center log removed for cleaner environment
// Stone paths removed for cleaner environment
// Campfire removed for cleaner environment
// Create clock display
clockDisplay = new Text2('12:00', {
size: 60,
fill: 0xffffff
});
clockDisplay.anchor.set(0.5, 0);
clockDisplay.x = 2048 / 2;
clockDisplay.y = 50;
game.addChild(clockDisplay);
// Sun and moon elements removed for 120 fps mode
sunElement = null;
moonElement = null;
// Initialize rain system
nextRainTime = Date.now() + rainInterval;
}
}
// Rain creation function
function createRainDrop() {
if (!ultraRealisticMode || graphicsMode !== 120) {
return;
}
var rainDrop = LK.getAsset('rainDrop', {
anchorX: 0.5,
anchorY: 0.5
});
rainDrop.x = Math.random() * 2048;
rainDrop.y = -50;
rainDrop.speed = 8 + Math.random() * 4;
rainDrop.lastY = rainDrop.y;
game.addChild(rainDrop);
rainDrops.push(rainDrop);
}
// Rain splash effect function
function createRainSplash(x, y) {
if (!ultraRealisticMode || graphicsMode !== 120) {
return;
}
var splash = LK.getAsset('rainSplash', {
anchorX: 0.5,
anchorY: 0.5
});
splash.x = x;
splash.y = y;
splash.alpha = 0.8;
splash.scaleX = 0.5;
splash.scaleY = 0.5;
game.addChild(splash);
// Animate splash with shock wave effect
tween(splash, {
scaleX: 3,
scaleY: 3,
alpha: 0
}, {
duration: 400,
easing: tween.easeOut,
onFinish: function onFinish() {
splash.destroy();
}
});
}
// Update clock display
function updateClock() {
if (!ultraRealisticMode || graphicsMode !== 120 || !clockDisplay) {
return;
}
// Game time runs 20x faster than real time
var currentTime = Date.now();
gameTime += (currentTime - (gameTime > 0 ? gameTime : currentTime)) * 20;
// Calculate hours and minutes (12-hour format)
var totalMinutes = Math.floor(gameTime / 60000) % (24 * 60);
var hours = Math.floor(totalMinutes / 60) % 24;
var minutes = totalMinutes % 60;
var displayHours = hours % 12;
if (displayHours === 0) {
displayHours = 12;
}
var timeString = displayHours.toString().padStart(2, '0') + ':' + minutes.toString().padStart(2, '0');
clockDisplay.setText(timeString);
// Day/night cycle removed for 120 fps mode
isDayTime = hours >= 6 && hours < 18;
}
// 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);
// Initialize ultra-realistic environment
createUltraRealisticEnvironment();
// Handle tap events on the game area
game.down = function (x, y, obj) {
// Calculate pet bonus based on equipped animal quantities
var petBonus = 0;
// Count each animal type
var dogCount = 0;
var catCount = 0;
var snakeCount = 0;
var goldenDogCount = 0;
var goldenCatCount = 0;
var goldenSnakeCount = 0;
var dinosaurCount = 0;
var bearCount = 0;
var beeCount = 0;
var goldenDinosaurCount = 0;
var goldenBearCount = 0;
var goldenBeeCount = 0;
var trexCount = 0;
var velectorCount = 0;
var titanaBullCount = 0;
var goldenTrexCount = 0;
var goldenVelectorCount = 0;
var goldenTitanaBullCount = 0;
var ironManCount = 0;
var captainAmericaCount = 0;
var spidermanCount = 0;
var goldenIronManCount = 0;
var goldenCaptainAmericaCount = 0;
var goldenSpidermanCount = 0;
var kingCount = 0;
var knightCount = 0;
var humanCount = 0;
var goldenKingCount = 0;
var goldenKnightCount = 0;
var goldenHumanCount = 0;
var earthCount = 0;
var moonCount = 0;
var meteorCount = 0;
var sunCount = 0;
var jupiterCount = 0;
var neptuneCount = 0;
var goldenEarthCount = 0;
var goldenMoonCount = 0;
var goldenMeteorCount = 0;
var goldenSunCount = 0;
var goldenJupiterCount = 0;
var goldenNeptuneCount = 0;
var andromedaGalaxyCount = 0;
var normalGalaxyCount = 0;
var milkyWayGalaxyCount = 0;
var goldenAndromedaGalaxyCount = 0;
var goldenNormalGalaxyCount = 0;
var goldenMilkyWayGalaxyCount = 0;
for (var j = 0; j < equippedAnimals.length; j++) {
if (equippedAnimals[j] === 'dog') {
dogCount++;
} else if (equippedAnimals[j] === 'cat') {
catCount++;
} else if (equippedAnimals[j] === 'snake') {
snakeCount++;
} else if (equippedAnimals[j] === 'goldenDog') {
goldenDogCount++;
} else if (equippedAnimals[j] === 'goldenCat') {
goldenCatCount++;
} else if (equippedAnimals[j] === 'goldenSnake') {
goldenSnakeCount++;
} else if (equippedAnimals[j] === 'dinosaur') {
dinosaurCount++;
} else if (equippedAnimals[j] === 'bear') {
bearCount++;
} else if (equippedAnimals[j] === 'bee') {
beeCount++;
} else if (equippedAnimals[j] === 'goldenDinosaur') {
goldenDinosaurCount++;
} else if (equippedAnimals[j] === 'goldenBear') {
goldenBearCount++;
} else if (equippedAnimals[j] === 'goldenBee') {
goldenBeeCount++;
} else if (equippedAnimals[j] === 'trex') {
trexCount++;
} else if (equippedAnimals[j] === 'velector') {
velectorCount++;
} else if (equippedAnimals[j] === 'titanaBull') {
titanaBullCount++;
} else if (equippedAnimals[j] === 'goldenTrex') {
goldenTrexCount++;
} else if (equippedAnimals[j] === 'goldenVelector') {
goldenVelectorCount++;
} else if (equippedAnimals[j] === 'goldenTitanaBull') {
goldenTitanaBullCount++;
} else if (equippedAnimals[j] === 'ironMan') {
ironManCount++;
} else if (equippedAnimals[j] === 'captainAmerica') {
captainAmericaCount++;
} else if (equippedAnimals[j] === 'spiderman') {
spidermanCount++;
} else if (equippedAnimals[j] === 'goldenIronMan') {
goldenIronManCount++;
} else if (equippedAnimals[j] === 'goldenCaptainAmerica') {
goldenCaptainAmericaCount++;
} else if (equippedAnimals[j] === 'goldenSpiderman') {
goldenSpidermanCount++;
} else if (equippedAnimals[j] === 'king') {
kingCount++;
} else if (equippedAnimals[j] === 'knight') {
knightCount++;
} else if (equippedAnimals[j] === 'human') {
humanCount++;
} else if (equippedAnimals[j] === 'goldenKing') {
goldenKingCount++;
} else if (equippedAnimals[j] === 'goldenKnight') {
goldenKnightCount++;
} else if (equippedAnimals[j] === 'goldenHuman') {
goldenHumanCount++;
} else if (equippedAnimals[j] === 'earth') {
earthCount++;
} else if (equippedAnimals[j] === 'moon') {
moonCount++;
} else if (equippedAnimals[j] === 'meteor') {
meteorCount++;
} else if (equippedAnimals[j] === 'sun') {
sunCount++;
} else if (equippedAnimals[j] === 'jupiter') {
jupiterCount++;
} else if (equippedAnimals[j] === 'neptune') {
neptuneCount++;
} else if (equippedAnimals[j] === 'goldenEarth') {
goldenEarthCount++;
} else if (equippedAnimals[j] === 'goldenMoon') {
goldenMoonCount++;
} else if (equippedAnimals[j] === 'goldenMeteor') {
goldenMeteorCount++;
} else if (equippedAnimals[j] === 'goldenSun') {
goldenSunCount++;
} else if (equippedAnimals[j] === 'goldenJupiter') {
goldenJupiterCount++;
} else if (equippedAnimals[j] === 'goldenNeptune') {
goldenNeptuneCount++;
} else if (equippedAnimals[j] === 'andromedaGalaxy') {
andromedaGalaxyCount++;
} else if (equippedAnimals[j] === 'normalGalaxy') {
normalGalaxyCount++;
} else if (equippedAnimals[j] === 'milkyWayGalaxy') {
milkyWayGalaxyCount++;
} else if (equippedAnimals[j] === 'goldenAndromedaGalaxy') {
goldenAndromedaGalaxyCount++;
} else if (equippedAnimals[j] === 'goldenNormalGalaxy') {
goldenNormalGalaxyCount++;
} else if (equippedAnimals[j] === 'goldenMilkyWayGalaxy') {
goldenMilkyWayGalaxyCount++;
}
}
// Each dog gives +1 bonus per tap
petBonus += dogCount;
// Cats: 1 cat = +2, 2 cats = +4, 3 cats = +6 (total bonus)
if (catCount === 1) {
petBonus += 2;
} else if (catCount === 2) {
petBonus += 4;
} else if (catCount === 3) {
petBonus += 6;
}
// Snakes: 1 snake = +5, 2 snakes = +10, 3 snakes = +15 (total bonus)
if (snakeCount === 1) {
petBonus += 5;
} else if (snakeCount === 2) {
petBonus += 10;
} else if (snakeCount === 3) {
petBonus += 15;
}
// Golden pets bonuses
// Golden dogs: 1 = +3, 2 = +6, 3 = +9 per tap
if (goldenDogCount === 1) {
petBonus += 3;
} else if (goldenDogCount === 2) {
petBonus += 6;
} else if (goldenDogCount === 3) {
petBonus += 9;
}
// Golden cats: 1 = +6, 2 = +12, 3 = +18 per tap
if (goldenCatCount === 1) {
petBonus += 6;
} else if (goldenCatCount === 2) {
petBonus += 12;
} else if (goldenCatCount === 3) {
petBonus += 18;
}
// Golden snakes: 1 = +10, 2 = +20, 3 = +30 per tap
if (goldenSnakeCount === 1) {
petBonus += 10;
} else if (goldenSnakeCount === 2) {
petBonus += 20;
} else if (goldenSnakeCount === 3) {
petBonus += 30;
}
// Green egg pets bonuses
// Dinosaurs: 1 = +30, 2 = +60, 3 = +90 per tap
if (dinosaurCount === 1) {
petBonus += 30;
} else if (dinosaurCount === 2) {
petBonus += 60;
} else if (dinosaurCount === 3) {
petBonus += 90;
}
// Bears: 1 = +20, 2 = +40, 3 = +60 per tap
if (bearCount === 1) {
petBonus += 20;
} else if (bearCount === 2) {
petBonus += 40;
} else if (bearCount === 3) {
petBonus += 60;
}
// Bees: 1 = +10, 2 = +20, 3 = +30 per tap
if (beeCount === 1) {
petBonus += 10;
} else if (beeCount === 2) {
petBonus += 20;
} else if (beeCount === 3) {
petBonus += 30;
}
// Golden green egg pets bonuses (2x multiplier)
// Golden dinosaurs: 1 = +60, 2 = +120, 3 = +180 per tap
if (goldenDinosaurCount === 1) {
petBonus += 60;
} else if (goldenDinosaurCount === 2) {
petBonus += 120;
} else if (goldenDinosaurCount === 3) {
petBonus += 180;
}
// Golden bears: 1 = +40, 2 = +80, 3 = +120 per tap
if (goldenBearCount === 1) {
petBonus += 40;
} else if (goldenBearCount === 2) {
petBonus += 80;
} else if (goldenBearCount === 3) {
petBonus += 120;
}
// Golden bees: 1 = +20, 2 = +40, 3 = +60 per tap
if (goldenBeeCount === 1) {
petBonus += 20;
} else if (goldenBeeCount === 2) {
petBonus += 40;
} else if (goldenBeeCount === 3) {
petBonus += 60;
}
// Red egg pets bonuses
// T-rex: 1 = +100, 2 = +200, 3 = +300 per tap
if (trexCount === 1) {
petBonus += 100;
} else if (trexCount === 2) {
petBonus += 200;
} else if (trexCount === 3) {
petBonus += 300;
}
// Velector: 1 = +80, 2 = +160, 3 = +240 per tap
if (velectorCount === 1) {
petBonus += 80;
} else if (velectorCount === 2) {
petBonus += 160;
} else if (velectorCount === 3) {
petBonus += 240;
}
// Titana Bull: 1 = +50, 2 = +100, 3 = +150 per tap
if (titanaBullCount === 1) {
petBonus += 50;
} else if (titanaBullCount === 2) {
petBonus += 100;
} else if (titanaBullCount === 3) {
petBonus += 150;
}
// Golden red egg pets bonuses
// Golden T-rex: 1 = +200, 2 = +400, 3 = +600 per tap
if (goldenTrexCount === 1) {
petBonus += 200;
} else if (goldenTrexCount === 2) {
petBonus += 400;
} else if (goldenTrexCount === 3) {
petBonus += 600;
}
// Golden Velector: 1 = +160, 2 = +320, 3 = +480 per tap
if (goldenVelectorCount === 1) {
petBonus += 160;
} else if (goldenVelectorCount === 2) {
petBonus += 320;
} else if (goldenVelectorCount === 3) {
petBonus += 480;
}
// Golden Titana Bull: 1 = +100, 2 = +200, 3 = +300 per tap
if (goldenTitanaBullCount === 1) {
petBonus += 100;
} else if (goldenTitanaBullCount === 2) {
petBonus += 200;
} else if (goldenTitanaBullCount === 3) {
petBonus += 300;
}
// Purple egg pets bonuses
// Iron Man: 1 = +500, 2 = +1000, 3 = +1500 per tap
if (ironManCount === 1) {
petBonus += 500;
} else if (ironManCount === 2) {
petBonus += 1000;
} else if (ironManCount === 3) {
petBonus += 1500;
}
// Captain America: 1 = +300, 2 = +600, 3 = +900 per tap
if (captainAmericaCount === 1) {
petBonus += 300;
} else if (captainAmericaCount === 2) {
petBonus += 600;
} else if (captainAmericaCount === 3) {
petBonus += 900;
}
// Spiderman: 1 = +250, 2 = +500, 3 = +750 per tap
if (spidermanCount === 1) {
petBonus += 250;
} else if (spidermanCount === 2) {
petBonus += 500;
} else if (spidermanCount === 3) {
petBonus += 750;
}
// Golden purple egg pets bonuses (2x multiplier)
// Golden Iron Man: 1 = +1000, 2 = +2000, 3 = +3000 per tap
if (goldenIronManCount === 1) {
petBonus += 1000;
} else if (goldenIronManCount === 2) {
petBonus += 2000;
} else if (goldenIronManCount === 3) {
petBonus += 3000;
}
// Golden Captain America: 1 = +600, 2 = +1200, 3 = +1800 per tap
if (goldenCaptainAmericaCount === 1) {
petBonus += 600;
} else if (goldenCaptainAmericaCount === 2) {
petBonus += 1200;
} else if (goldenCaptainAmericaCount === 3) {
petBonus += 1800;
}
// Golden Spiderman: 1 = +500, 2 = +1000, 3 = +1500 per tap
if (goldenSpidermanCount === 1) {
petBonus += 500;
} else if (goldenSpidermanCount === 2) {
petBonus += 1000;
} else if (goldenSpidermanCount === 3) {
petBonus += 1500;
}
// White egg pets bonuses
// King: 1 = +10000, 2 = +20000, 3 = +30000 per tap
if (kingCount === 1) {
petBonus += 10000;
} else if (kingCount === 2) {
petBonus += 20000;
} else if (kingCount === 3) {
petBonus += 30000;
}
// Knight: 1 = +5000, 2 = +10000, 3 = +15000 per tap
if (knightCount === 1) {
petBonus += 5000;
} else if (knightCount === 2) {
petBonus += 10000;
} else if (knightCount === 3) {
petBonus += 15000;
}
// Human: 1 = +2500, 2 = +5000, 3 = +7500 per tap
if (humanCount === 1) {
petBonus += 2500;
} else if (humanCount === 2) {
petBonus += 5000;
} else if (humanCount === 3) {
petBonus += 7500;
}
// Golden white egg pets bonuses (2x multiplier)
// Golden King: 1 = +20000, 2 = +40000, 3 = +60000 per tap
if (goldenKingCount === 1) {
petBonus += 20000;
} else if (goldenKingCount === 2) {
petBonus += 40000;
} else if (goldenKingCount === 3) {
petBonus += 60000;
}
// Golden Knight: 1 = +10000, 2 = +20000, 3 = +30000 per tap
if (goldenKnightCount === 1) {
petBonus += 10000;
} else if (goldenKnightCount === 2) {
petBonus += 20000;
} else if (goldenKnightCount === 3) {
petBonus += 30000;
}
// Golden Human: 1 = +5000, 2 = +10000, 3 = +15000 per tap
if (goldenHumanCount === 1) {
petBonus += 5000;
} else if (goldenHumanCount === 2) {
petBonus += 10000;
} else if (goldenHumanCount === 3) {
petBonus += 15000;
}
// Space egg pets bonuses
// Earth: 1 = +100000, 2 = +200000, 3 = +300000 per tap
if (earthCount === 1) {
petBonus += 100000;
} else if (earthCount === 2) {
petBonus += 200000;
} else if (earthCount === 3) {
petBonus += 300000;
}
// Moon: 1 = +50000, 2 = +100000, 3 = +150000 per tap
if (moonCount === 1) {
petBonus += 50000;
} else if (moonCount === 2) {
petBonus += 100000;
} else if (moonCount === 3) {
petBonus += 150000;
}
// Meteor: 1 = +25000, 2 = +50000, 3 = +75000 per tap
if (meteorCount === 1) {
petBonus += 25000;
} else if (meteorCount === 2) {
petBonus += 50000;
} else if (meteorCount === 3) {
petBonus += 75000;
}
// Sun: 1 = +500000, 2 = +1000000, 3 = +1500000 per tap
if (sunCount === 1) {
petBonus += 500000;
} else if (sunCount === 2) {
petBonus += 1000000;
} else if (sunCount === 3) {
petBonus += 1500000;
}
// Jupiter: 1 = +250000, 2 = +500000, 3 = +750000 per tap
if (jupiterCount === 1) {
petBonus += 250000;
} else if (jupiterCount === 2) {
petBonus += 500000;
} else if (jupiterCount === 3) {
petBonus += 750000;
}
// Neptune: 1 = +200000, 2 = +400000, 3 = +600000 per tap
if (neptuneCount === 1) {
petBonus += 200000;
} else if (neptuneCount === 2) {
petBonus += 400000;
} else if (neptuneCount === 3) {
petBonus += 600000;
}
// Golden space egg pets bonuses (2x multiplier)
// Golden Earth: 1 = +200000, 2 = +400000, 3 = +600000 per tap
if (goldenEarthCount === 1) {
petBonus += 200000;
} else if (goldenEarthCount === 2) {
petBonus += 400000;
} else if (goldenEarthCount === 3) {
petBonus += 600000;
}
// Golden Moon: 1 = +100000, 2 = +200000, 3 = +300000 per tap
if (goldenMoonCount === 1) {
petBonus += 100000;
} else if (goldenMoonCount === 2) {
petBonus += 200000;
} else if (goldenMoonCount === 3) {
petBonus += 300000;
}
// Golden Meteor: 1 = +50000, 2 = +100000, 3 = +150000 per tap
if (goldenMeteorCount === 1) {
petBonus += 50000;
} else if (goldenMeteorCount === 2) {
petBonus += 100000;
} else if (goldenMeteorCount === 3) {
petBonus += 150000;
}
// Golden Sun: 1 = +1000000, 2 = +2000000, 3 = +3000000 per tap
if (goldenSunCount === 1) {
petBonus += 1000000;
} else if (goldenSunCount === 2) {
petBonus += 2000000;
} else if (goldenSunCount === 3) {
petBonus += 3000000;
}
// Golden Jupiter: 1 = +500000, 2 = +1000000, 3 = +1500000 per tap
if (goldenJupiterCount === 1) {
petBonus += 500000;
} else if (goldenJupiterCount === 2) {
petBonus += 1000000;
} else if (goldenJupiterCount === 3) {
petBonus += 1500000;
}
// Golden Neptune: 1 = +400000, 2 = +800000, 3 = +1200000 per tap
if (goldenNeptuneCount === 1) {
petBonus += 400000;
} else if (goldenNeptuneCount === 2) {
petBonus += 800000;
} else if (goldenNeptuneCount === 3) {
petBonus += 1200000;
}
// Galaxy egg pets bonuses
// Andromeda Galaxy: 1 = +5000000, 2 = +10000000, 3 = +15000000 per tap
if (andromedaGalaxyCount === 1) {
petBonus += 5000000;
} else if (andromedaGalaxyCount === 2) {
petBonus += 10000000;
} else if (andromedaGalaxyCount === 3) {
petBonus += 15000000;
}
// Normal Galaxy: 1 = +10000000, 2 = +20000000, 3 = +30000000 per tap
if (normalGalaxyCount === 1) {
petBonus += 10000000;
} else if (normalGalaxyCount === 2) {
petBonus += 20000000;
} else if (normalGalaxyCount === 3) {
petBonus += 30000000;
}
// Milky Way Galaxy: 1 = +20000000, 2 = +40000000, 3 = +60000000 per tap
if (milkyWayGalaxyCount === 1) {
petBonus += 20000000;
} else if (milkyWayGalaxyCount === 2) {
petBonus += 40000000;
} else if (milkyWayGalaxyCount === 3) {
petBonus += 60000000;
}
// Golden galaxy egg pets bonuses (2x multiplier)
// Golden Andromeda Galaxy: 1 = +10000000, 2 = +20000000, 3 = +30000000 per tap
if (goldenAndromedaGalaxyCount === 1) {
petBonus += 10000000;
} else if (goldenAndromedaGalaxyCount === 2) {
petBonus += 20000000;
} else if (goldenAndromedaGalaxyCount === 3) {
petBonus += 30000000;
}
// Golden Normal Galaxy: 1 = +20000000, 2 = +40000000, 3 = +60000000 per tap
if (goldenNormalGalaxyCount === 1) {
petBonus += 20000000;
} else if (goldenNormalGalaxyCount === 2) {
petBonus += 40000000;
} else if (goldenNormalGalaxyCount === 3) {
petBonus += 60000000;
}
// Golden Milky Way Galaxy: 1 = +40000000, 2 = +80000000, 3 = +120000000 per tap
if (goldenMilkyWayGalaxyCount === 1) {
petBonus += 40000000;
} else if (goldenMilkyWayGalaxyCount === 2) {
petBonus += 80000000;
} else if (goldenMilkyWayGalaxyCount === 3) {
petBonus += 120000000;
}
// Base tap score is always 1, plus calculated pet bonus
var totalScore = 1 + petBonus;
LK.setScore(LK.getScore() + totalScore);
// Update score display
scoreTxt.setText(LK.getScore().toString());
// Create visual feedback at tap location showing total points gained
var feedbackText = '+' + totalScore.toString();
var tapFeedback = new Text2(feedbackText, {
size: ultraRealisticMode ? 120 : 80,
fill: ultraRealisticMode ? 0xFFD700 : 0x27AE60
});
tapFeedback.anchor.set(0.5, 0.5);
tapFeedback.x = x;
tapFeedback.y = y;
tapFeedback.alpha = 1;
game.addChild(tapFeedback);
// Enhanced animation for ultra-realistic mode
if (ultraRealisticMode) {
// Create enhanced circular shock wave with multiple layers
var shockWave = LK.getAsset('shockWave', {
anchorX: 0.5,
anchorY: 0.5
});
shockWave.x = x;
shockWave.y = y;
shockWave.alpha = 0.9;
shockWave.scaleX = 0.5;
shockWave.scaleY = 0.5;
game.addChild(shockWave);
// Create secondary shock wave for depth
var shockWave2 = LK.getAsset('shockWave', {
anchorX: 0.5,
anchorY: 0.5
});
shockWave2.x = x;
shockWave2.y = y;
shockWave2.alpha = 0.6;
shockWave2.scaleX = 0.3;
shockWave2.scaleY = 0.3;
shockWave2.tint = 0xFFD700;
game.addChild(shockWave2);
// Animate primary shock wave
tween(shockWave, {
scaleX: 12,
scaleY: 12,
alpha: 0
}, {
duration: 1200,
easing: tween.easeOut
});
// Animate secondary shock wave with delay
tween(shockWave2, {
scaleX: 15,
scaleY: 15,
alpha: 0
}, {
duration: 1500,
easing: tween.easeOut,
onFinish: function onFinish() {
shockWave.destroy();
shockWave2.destroy();
}
});
// Create enhanced "+1" text that appears on screen
var plusOneScreenText = new Text2('+1', {
size: 150,
fill: 0xFFD700
});
plusOneScreenText.anchor.set(0.5, 0.5);
plusOneScreenText.x = x;
plusOneScreenText.y = y - 100;
plusOneScreenText.alpha = 0;
game.addChild(plusOneScreenText);
// Animate "+1" text with scale and float effect
tween(plusOneScreenText, {
alpha: 1,
scaleX: 2.0,
scaleY: 2.0
}, {
duration: 200,
easing: tween.bounceOut
});
// Float "+1" text upward and fade out
tween(plusOneScreenText, {
y: y - 300,
alpha: 0,
scaleX: 1.5,
scaleY: 1.5
}, {
duration: 1200,
easing: tween.easeOut,
onFinish: function onFinish() {
plusOneScreenText.destroy();
}
});
// Create enhanced score text with glow above score that shows the full score gained
var plusOneText = new Text2('+' + totalScore, {
size: 120,
fill: 0xFFD700
});
plusOneText.anchor.set(0.5, 0.5);
plusOneText.x = scoreTxt.x;
plusOneText.y = scoreTxt.y + 80;
plusOneText.alpha = 0;
LK.gui.top.addChild(plusOneText);
// Animate score text with bounce and glow
tween(plusOneText, {
alpha: 1,
scaleX: 1.5,
scaleY: 1.5
}, {
duration: 300,
easing: tween.bounceOut
});
// Move score text toward main score
tween(plusOneText, {
y: scoreTxt.y - 80,
alpha: 0,
scaleX: 0.8,
scaleY: 0.8
}, {
duration: 1800,
easing: tween.easeOut,
onFinish: function onFinish() {
plusOneText.destroy();
}
});
// Enhanced tap feedback with particle effect
tween(tapFeedback, {
scaleX: 2.5,
scaleY: 2.5,
alpha: 0.8
}, {
duration: 250,
easing: tween.bounceOut
});
// Create particle burst effect
for (var particleIndex = 0; particleIndex < 8; particleIndex++) {
var particle = new Text2('★', {
size: 40,
fill: 0xFFD700
});
particle.anchor.set(0.5, 0.5);
particle.x = x;
particle.y = y;
particle.alpha = 0.8;
game.addChild(particle);
var angle = particleIndex / 8 * Math.PI * 2;
var distance = 200 + Math.random() * 100;
tween(particle, {
x: x + Math.cos(angle) * distance,
y: y + Math.sin(angle) * distance,
alpha: 0,
scaleX: 0.3,
scaleY: 0.3,
rotation: Math.PI
}, {
duration: 1000 + Math.random() * 500,
easing: tween.easeOut,
onFinish: function onFinish() {
particle.destroy();
}
});
}
// Enhanced floating animation with complex path
tween(tapFeedback, {
y: y - 300,
x: x + (Math.random() - 0.5) * 150,
rotation: Math.PI / 3,
alpha: 0
}, {
duration: 2000,
easing: tween.easeOut,
onFinish: function onFinish() {
tapFeedback.destroy();
}
});
} else if (graphicsMode === 90) {
// Enhanced 90 fps mode animation with detailed and realistic effects
// Create enhanced glow effect with multiple phases
tween(tapFeedback, {
scaleX: 2.0,
scaleY: 2.0,
alpha: 0.9
}, {
duration: 150,
easing: tween.easeOut
});
// Create floating animation with enhanced rotation and movement
tween(tapFeedback, {
y: y - 250,
x: x + (Math.random() - 0.5) * 100,
rotation: Math.PI / 3,
alpha: 0,
scaleX: 0.5,
scaleY: 0.5
}, {
duration: 1800,
easing: tween.easeOut,
onFinish: function onFinish() {
tapFeedback.destroy();
}
});
// Create realistic bounce effect with shadow simulation
LK.setTimeout(function () {
tween(tapFeedback, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 200,
easing: tween.bounceOut
});
}, 150);
// Add realistic color transition for enhanced visual appeal
LK.setTimeout(function () {
tween(tapFeedback, {
tint: 0xFFD700
}, {
duration: 300,
easing: tween.easeInOut
});
}, 300);
// Create secondary glow burst effect
var secondaryGlow = new Text2('+' + totalScore.toString(), {
size: 100,
fill: 0xFFFFFF,
alpha: 0.6
});
secondaryGlow.anchor.set(0.5, 0.5);
secondaryGlow.x = x;
secondaryGlow.y = y;
game.addChild(secondaryGlow);
// Animate secondary glow with different trajectory
tween(secondaryGlow, {
y: y - 180,
x: x + (Math.random() - 0.5) * 80,
scaleX: 1.8,
scaleY: 1.8,
alpha: 0,
rotation: -Math.PI / 4
}, {
duration: 1600,
easing: tween.easeOut,
onFinish: function onFinish() {
secondaryGlow.destroy();
}
});
} else {
// Standard animation for 30 and 60 fps
var startY = y;
var animationDuration = graphicsMode === 30 ? 1200 : 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;
var frameDelay = graphicsMode === 30 ? 33 : 16;
LK.setTimeout(_animateCallback, frameDelay);
};
_animateCallback();
}
// Hide instruction text after first tap
if (LK.getScore() === 1) {
instructionTxt.alpha = 0;
}
};
// Add Shop button
var shopBtn = new Text2('Shop', {
size: 80,
fill: 0xFFFFFF
});
shopBtn.anchor.set(1, 0);
LK.gui.topRight.addChild(shopBtn);
shopBtn.x = -20; // Small padding from right edge
shopBtn.y = 20; // Small padding from top
// Shop interface state
var isShopOpen = false;
var shopOverlay = null;
// Handle shop button tap
shopBtn.down = function (x, y, obj) {
if (!isShopOpen) {
// Open shop - create black overlay using Container
shopOverlay = new Container();
// Create black background shape for overlay
var shopBackground = LK.getAsset('shopBg', {
width: 2048,
height: 2732,
color: 0x000000,
shape: 'box'
});
shopOverlay.addChild(shopBackground);
shopOverlay.x = 0;
shopOverlay.y = 0;
// NORMAL EGGS SECTION
// Normal eggs data
var normalEggs = [{
asset: 'egg',
price: '1000 Score',
color: 0xFFFFFF
}, {
asset: 'greenEgg',
price: '15000 Score',
color: 0x00ff00
}, {
asset: 'redEgg',
price: '50000 Score',
color: 0xff0000
}, {
asset: 'purpleEgg',
price: '1250000 Score',
color: 0x800080
}, {
asset: 'whiteEgg',
price: '10M',
color: 0xffffff
}, {
asset: 'spaceEgg',
price: '100M',
color: 0x4169e1
}, {
asset: 'space2Egg',
price: '200M',
color: 0x8a2be2
}, {
asset: 'galaxyEgg',
price: '500M',
color: 0x800080
}];
// Golden eggs data
var goldenEggs = [{
asset: 'goldenEgg',
price: '10000 Score',
color: 0xFFD700
}, {
asset: 'goldenGreenEgg',
price: '30000 Score',
color: 0x90ee90
}, {
asset: 'goldenRedEgg',
price: '100000 Score',
color: 0xff6600
}, {
asset: 'goldenPurpleEgg',
price: '2500000 Score',
color: 0xdaa520
}, {
asset: 'goldenWhiteEgg',
price: '20M',
color: 0xffd700
}, {
asset: 'goldenSpaceEgg',
price: '200M',
color: 0xffd700
}, {
asset: 'goldenSpace2Egg',
price: '400M',
color: 0xffd700
}, {
asset: 'goldenGalaxyEgg',
price: '1B',
color: 0xffd700
}];
// Display normal eggs section
var normalEggItems = [];
var startY = 600;
var eggSpacing = 300;
var rowSpacing = 300;
var maxEggsPerRow = 5;
for (var i = 0; i < normalEggs.length; i++) {
var row = Math.floor(i / maxEggsPerRow);
var col = i % maxEggsPerRow;
var startX = (2048 - (Math.min(normalEggs.length - row * maxEggsPerRow, maxEggsPerRow) - 1) * eggSpacing) / 2;
var eggX = startX + col * eggSpacing;
var eggY = startY + row * rowSpacing;
var eggItem = LK.getAsset(normalEggs[i].asset, {
anchorX: 0.5,
anchorY: 0.5
});
eggItem.x = eggX;
eggItem.y = eggY;
shopOverlay.addChild(eggItem);
normalEggItems.push(eggItem);
var eggPriceText = new Text2(normalEggs[i].price, {
size: 50,
fill: normalEggs[i].color
});
eggPriceText.anchor.set(0.5, 0);
eggPriceText.x = eggX;
eggPriceText.y = eggY + 120;
shopOverlay.addChild(eggPriceText);
}
// Display golden eggs section
var goldenEggItems = [];
var goldenStartY = startY + Math.ceil(normalEggs.length / maxEggsPerRow) * rowSpacing + 300;
for (var i = 0; i < goldenEggs.length; i++) {
var row = Math.floor(i / maxEggsPerRow);
var col = i % maxEggsPerRow;
var startX = (2048 - (Math.min(goldenEggs.length - row * maxEggsPerRow, maxEggsPerRow) - 1) * eggSpacing) / 2;
var eggX = startX + col * eggSpacing;
var eggY = goldenStartY + row * rowSpacing;
var goldenEggItem = LK.getAsset(goldenEggs[i].asset, {
anchorX: 0.5,
anchorY: 0.5
});
goldenEggItem.x = eggX;
goldenEggItem.y = eggY;
shopOverlay.addChild(goldenEggItem);
goldenEggItems.push(goldenEggItem);
var goldenEggPriceText = new Text2(goldenEggs[i].price, {
size: 50,
fill: goldenEggs[i].color
});
goldenEggPriceText.anchor.set(0.5, 0);
goldenEggPriceText.x = eggX;
goldenEggPriceText.y = eggY + 120;
shopOverlay.addChild(goldenEggPriceText);
}
// Add inventory button
var inventoryBtnY = goldenStartY + Math.ceil(goldenEggs.length / maxEggsPerRow) * rowSpacing + 100;
var inventoryBtn = new Text2('Inventory', {
size: 80,
fill: 0xFFFFFF
});
inventoryBtn.anchor.set(0.5, 0);
inventoryBtn.x = 2048 * 2 / 3;
inventoryBtn.y = inventoryBtnY;
shopOverlay.addChild(inventoryBtn);
// Store references for purchase handlers
var eggItem = normalEggItems[0];
var greenEggItem = normalEggItems[1];
var redEggItem = normalEggItems[2];
var purpleEggItem = normalEggItems[3];
var whiteEggItem = normalEggItems[4];
var goldenEggItem = goldenEggItems[0];
var goldenGreenEggItem = goldenEggItems[1];
var goldenRedEggItem = goldenEggItems[2];
var goldenPurpleEggItem = goldenEggItems[3];
var goldenWhiteEggItem = goldenEggItems[4];
var spaceEggItem = normalEggItems[5];
var space2EggItem = normalEggItems[6];
var goldenSpaceEggItem = goldenEggItems[5];
var goldenSpace2EggItem = goldenEggItems[6];
var galaxyEggItem = normalEggItems[7];
var goldenGalaxyEggItem = goldenEggItems[7];
// Handle egg purchase
eggItem.down = function () {
if (LK.getScore() >= 1000) {
LK.setScore(LK.getScore() - 1000);
scoreTxt.setText(LK.getScore().toString());
// Close shop
shopOverlay.destroy();
shopOverlay = null;
isShopOpen = false;
// Create falling egg
fallingEgg = getEnhancedEggAsset('egg', {
anchorX: 0.5,
anchorY: 0.5
});
fallingEgg.x = 2048 / 2;
fallingEgg.y = -200;
eggClickCount = 0;
game.addChild(fallingEgg);
// Animate egg falling with enhanced graphics
if (ultraRealisticMode) {
// Ultra-realistic falling with enhanced wobble and scaling effects
tween(fallingEgg, {
y: 2732 / 2,
rotation: Math.PI / 6,
scaleX: 1.1,
scaleY: 1.1
}, {
duration: 1400,
easing: tween.bounceOut
});
// Enhanced side-to-side wobble with rotation
tween(fallingEgg, {
x: 2048 / 2 + 80
}, {
duration: 700,
easing: tween.easeInOut
});
LK.setTimeout(function () {
tween(fallingEgg, {
x: 2048 / 2 - 80,
rotation: -Math.PI / 6
}, {
duration: 700,
easing: tween.easeInOut
});
}, 700);
// Add pulsing effect
tween(fallingEgg, {
alpha: 0.8
}, {
duration: 350,
easing: tween.easeInOut
});
LK.setTimeout(function () {
tween(fallingEgg, {
alpha: 1
}, {
duration: 350,
easing: tween.easeInOut
});
}, 350);
} else {
var fallDuration = graphicsMode === 30 ? 1500 : graphicsMode === 60 ? 1000 : 800;
tween(fallingEgg, {
y: 2732 / 2
}, {
duration: fallDuration
});
}
// Handle egg clicking
fallingEgg.down = function () {
eggClickCount++;
if (eggClickCount === 1) {
// First crack
var crackedEgg1 = getEnhancedEggAsset('crackedEgg1', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg1.x = fallingEgg.x;
crackedEgg1.y = fallingEgg.y;
game.addChild(crackedEgg1);
// Enhanced cracking animation for 120 fps
if (ultraRealisticMode) {
// Add intense shake effect with multiple phases
tween(crackedEgg1, {
rotation: Math.PI / 12,
scaleX: 1.05,
scaleY: 1.05
}, {
duration: 80,
easing: tween.easeInOut
});
LK.setTimeout(function () {
tween(crackedEgg1, {
rotation: -Math.PI / 12,
scaleX: 0.95,
scaleY: 0.95
}, {
duration: 80,
easing: tween.easeInOut
});
}, 80);
LK.setTimeout(function () {
tween(crackedEgg1, {
rotation: Math.PI / 20,
scaleX: 1.02,
scaleY: 1.02
}, {
duration: 80,
easing: tween.easeInOut
});
}, 160);
LK.setTimeout(function () {
tween(crackedEgg1, {
rotation: 0,
scaleX: 1,
scaleY: 1
}, {
duration: 120,
easing: tween.easeInOut
});
}, 240);
}
fallingEgg.destroy();
fallingEgg = crackedEgg1;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 2) {
// Second crack
var crackedEgg2 = getEnhancedEggAsset('crackedEgg2', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg2.x = fallingEgg.x;
crackedEgg2.y = fallingEgg.y;
game.addChild(crackedEgg2);
// Enhanced cracking animation for 120 fps
if (ultraRealisticMode) {
// Add more intense shake and scaling
tween(crackedEgg2, {
rotation: Math.PI / 12,
scaleX: 1.05,
scaleY: 1.05
}, {
duration: 150,
easing: tween.easeInOut
});
LK.setTimeout(function () {
tween(crackedEgg2, {
rotation: -Math.PI / 12,
scaleX: 0.95,
scaleY: 0.95
}, {
duration: 150,
easing: tween.easeInOut
});
}, 150);
LK.setTimeout(function () {
tween(crackedEgg2, {
rotation: 0,
scaleX: 1,
scaleY: 1
}, {
duration: 150,
easing: tween.easeInOut
});
}, 300);
}
fallingEgg.destroy();
fallingEgg = crackedEgg2;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 3) {
// Third crack - almost fully cracked
var crackedEgg3 = getEnhancedEggAsset('crackedEgg3', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg3.x = fallingEgg.x;
crackedEgg3.y = fallingEgg.y;
game.addChild(crackedEgg3);
// Enhanced final crack animation for 120 fps
if (ultraRealisticMode) {
// Add violent shake and pulsing
tween(crackedEgg3, {
rotation: Math.PI / 8,
scaleX: 1.1,
scaleY: 1.1,
alpha: 0.7
}, {
duration: 200,
easing: tween.easeInOut
});
LK.setTimeout(function () {
tween(crackedEgg3, {
rotation: -Math.PI / 8,
scaleX: 0.9,
scaleY: 0.9,
alpha: 1
}, {
duration: 200,
easing: tween.easeInOut
});
}, 200);
LK.setTimeout(function () {
tween(crackedEgg3, {
rotation: 0,
scaleX: 1,
scaleY: 1
}, {
duration: 200,
easing: tween.easeInOut
});
}, 400);
}
fallingEgg.destroy();
fallingEgg = crackedEgg3;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 4) {
// Enhanced hatching animation for ultra-realistic mode
if (ultraRealisticMode) {
// Create spectacular light burst effect
var lightBurst = new Container();
for (var lightIndex = 0; lightIndex < 16; lightIndex++) {
var lightRay = LK.getAsset('lightRay', {
anchorX: 0.5,
anchorY: 0.5
});
lightRay.rotation = lightIndex * Math.PI / 8;
lightRay.alpha = 0.8;
lightBurst.addChild(lightRay);
}
// Add golden secondary rays
for (var lightIndex = 0; lightIndex < 12; lightIndex++) {
var coloredRay = LK.getAsset('goldenLightRay', {
anchorX: 0.5,
anchorY: 0.5
});
coloredRay.rotation = lightIndex * Math.PI / 6 + Math.PI / 12;
coloredRay.alpha = 0.9;
lightBurst.addChild(coloredRay);
}
lightBurst.x = fallingEgg.x;
lightBurst.y = fallingEgg.y;
lightBurst.alpha = 0;
lightBurst.scaleX = 0.5;
lightBurst.scaleY = 0.5;
game.addChild(lightBurst);
// Multi-phase light burst animation
tween(lightBurst, {
alpha: 1,
scaleX: 5,
scaleY: 5,
rotation: Math.PI / 3
}, {
duration: 500,
easing: tween.easeOut
});
// Secondary expansion phase
LK.setTimeout(function () {
tween(lightBurst, {
alpha: 0.3,
scaleX: 8,
scaleY: 8,
rotation: Math.PI
}, {
duration: 800,
easing: tween.easeOut
});
}, 500);
// Final fade phase
LK.setTimeout(function () {
tween(lightBurst, {
alpha: 0,
scaleX: 12,
scaleY: 12,
rotation: Math.PI * 1.5
}, {
duration: 700,
easing: tween.easeIn,
onFinish: function onFinish() {
lightBurst.destroy();
}
});
}, 1300);
}
// 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) {
// Create enhanced pet with detailed info
var petData = {
'dog': {
rarity: 'Common',
bonus: 1,
dropChance: 0.6
},
'cat': {
rarity: 'Common',
bonus: 2,
dropChance: 0.3
},
'snake': {
rarity: 'Uncommon',
bonus: 5,
dropChance: 0.1
},
'goldenDog': {
rarity: 'Rare',
bonus: 3,
dropChance: 0.6
},
'goldenCat': {
rarity: 'Rare',
bonus: 6,
dropChance: 0.3
},
'goldenSnake': {
rarity: 'Epic',
bonus: 10,
dropChance: 0.1
}
};
var currentPetData = petData[animal] || {
rarity: 'Unknown',
bonus: 1,
dropChance: 0.01
};
var newPet = new Pet(animal, currentPetData.rarity, currentPetData.bonus, currentPetData.dropChance);
newPet.x = fallingEgg.x;
newPet.y = fallingEgg.y;
game.addChild(newPet);
// Enhanced pet entrance animation
newPet.animateEntrance();
// Move pet towards screen center
tween(newPet, {
x: 2048 / 2,
y: 2732 / 2 - 200,
scaleX: 1.8,
scaleY: 1.8
}, {
duration: 1500,
easing: tween.easeOut
});
// Show pet information after arrival
LK.setTimeout(function () {
newPet.showInfo();
}, 1800);
// Remove pet after showing info
LK.setTimeout(function () {
newPet.destroy();
}, 5000);
}
// Remove egg
fallingEgg.destroy();
fallingEgg = null;
}
};
}
};
// Handle green egg purchase
greenEggItem.down = function () {
if (LK.getScore() >= 15000) {
LK.setScore(LK.getScore() - 15000);
scoreTxt.setText(LK.getScore().toString());
// Close shop
shopOverlay.destroy();
shopOverlay = null;
isShopOpen = false;
// Create falling green egg
fallingEgg = LK.getAsset('greenEgg', {
anchorX: 0.5,
anchorY: 0.5
});
fallingEgg.x = 2048 / 2;
fallingEgg.y = -200;
eggClickCount = 0;
game.addChild(fallingEgg);
// Animate egg falling
tween(fallingEgg, {
y: 2732 / 2
}, {
duration: 1000
});
// Handle green egg clicking
fallingEgg.down = function () {
eggClickCount++;
if (eggClickCount === 1) {
// First crack
var crackedEgg1 = LK.getAsset('crackedEgg1', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg1.x = fallingEgg.x;
crackedEgg1.y = fallingEgg.y;
game.addChild(crackedEgg1);
fallingEgg.destroy();
fallingEgg = crackedEgg1;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 2) {
// Second crack
var crackedEgg2 = LK.getAsset('crackedEgg2', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg2.x = fallingEgg.x;
crackedEgg2.y = fallingEgg.y;
game.addChild(crackedEgg2);
fallingEgg.destroy();
fallingEgg = crackedEgg2;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 3) {
// Third crack - almost fully cracked
var crackedEgg3 = LK.getAsset('crackedEgg3', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg3.x = fallingEgg.x;
crackedEgg3.y = fallingEgg.y;
game.addChild(crackedEgg3);
fallingEgg.destroy();
fallingEgg = crackedEgg3;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 4) {
// Hatch the green egg with special probabilities
var availableGreenAnimals = [];
var greenAnimalTypes = ['dinosaur', 'bear', 'bee'];
for (var typeIndex = 0; typeIndex < greenAnimalTypes.length; typeIndex++) {
var animalType = greenAnimalTypes[typeIndex];
var countInInventory = 0;
for (var invIndex = 0; invIndex < inventory.length; invIndex++) {
if (inventory[invIndex] === animalType) {
countInInventory++;
}
}
if (countInInventory < 3) {
availableGreenAnimals.push(animalType);
}
}
var animal;
if (availableGreenAnimals.length > 0) {
// Special probability distribution for green eggs with Lucky Boost effect
var random = Math.random();
var selectedAnimal;
var dinosaurChance = 0.05;
var bearChance = 0.2;
var beeChance = 1.0;
if (random < dinosaurChance) {
selectedAnimal = 'dinosaur';
} else if (random < bearChance) {
selectedAnimal = 'bear';
} else {
selectedAnimal = 'bee';
}
// Check if selected animal is available
if (availableGreenAnimals.indexOf(selectedAnimal) !== -1) {
animal = selectedAnimal;
} else {
// If selected animal is not available, choose randomly from available
var randomIndex = Math.floor(Math.random() * availableGreenAnimals.length);
animal = availableGreenAnimals[randomIndex];
}
inventory.push(animal);
storage.inventory = inventory;
} else {
// All green animal types have 3 in inventory
animal = null;
var allGreenPetsText = new Text2('All green pets maxed out!', {
size: 60,
fill: 0xff0000
});
allGreenPetsText.anchor.set(0.5, 0.5);
allGreenPetsText.x = 2048 / 2;
allGreenPetsText.y = 1500;
game.addChild(allGreenPetsText);
LK.setTimeout(function () {
allGreenPetsText.destroy();
}, 2000);
}
// Only show hatched animal if we got a new pet
if (animal) {
var animalSprite = LK.getAsset(animal, {
anchorX: 0.5,
anchorY: 0.5
});
animalSprite.x = fallingEgg.x;
animalSprite.y = fallingEgg.y;
game.addChild(animalSprite);
// Remove animal after showing
LK.setTimeout(function () {
animalSprite.destroy();
}, 2000);
}
// Remove egg
fallingEgg.destroy();
fallingEgg = null;
}
};
}
};
// Handle golden green egg purchase
goldenGreenEggItem.down = function () {
if (LK.getScore() >= 30000) {
LK.setScore(LK.getScore() - 30000);
scoreTxt.setText(LK.getScore().toString());
// Close shop
shopOverlay.destroy();
shopOverlay = null;
isShopOpen = false;
// Create falling golden green egg
fallingEgg = LK.getAsset('goldenGreenEgg', {
anchorX: 0.5,
anchorY: 0.5
});
fallingEgg.x = 2048 / 2;
fallingEgg.y = -200;
eggClickCount = 0;
game.addChild(fallingEgg);
// Animate egg falling
tween(fallingEgg, {
y: 2732 / 2
}, {
duration: 1000
});
// Handle golden green egg clicking
fallingEgg.down = function () {
eggClickCount++;
if (eggClickCount === 1) {
// First crack
var crackedEgg1 = LK.getAsset('crackedEgg1', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg1.x = fallingEgg.x;
crackedEgg1.y = fallingEgg.y;
game.addChild(crackedEgg1);
fallingEgg.destroy();
fallingEgg = crackedEgg1;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 2) {
// Second crack
var crackedEgg2 = LK.getAsset('crackedEgg2', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg2.x = fallingEgg.x;
crackedEgg2.y = fallingEgg.y;
game.addChild(crackedEgg2);
fallingEgg.destroy();
fallingEgg = crackedEgg2;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 3) {
// Third crack - almost fully cracked
var crackedEgg3 = LK.getAsset('crackedEgg3', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg3.x = fallingEgg.x;
crackedEgg3.y = fallingEgg.y;
game.addChild(crackedEgg3);
fallingEgg.destroy();
fallingEgg = crackedEgg3;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 4) {
// Hatch the golden green egg with special probabilities
var availableGoldenGreenAnimals = [];
var goldenGreenAnimalTypes = ['goldenDinosaur', 'goldenBear', 'goldenBee'];
for (var typeIndex = 0; typeIndex < goldenGreenAnimalTypes.length; typeIndex++) {
var animalType = goldenGreenAnimalTypes[typeIndex];
var countInInventory = 0;
for (var invIndex = 0; invIndex < inventory.length; invIndex++) {
if (inventory[invIndex] === animalType) {
countInInventory++;
}
}
if (countInInventory < 3) {
availableGoldenGreenAnimals.push(animalType);
}
}
var animal;
if (availableGoldenGreenAnimals.length > 0) {
// Special probability distribution for golden green eggs (same as green)
var random = Math.random();
var selectedAnimal;
if (random < 0.05) {
selectedAnimal = 'goldenDinosaur'; // 5% chance
} else if (random < 0.2) {
selectedAnimal = 'goldenBear'; // 15% chance
} else {
selectedAnimal = 'goldenBee'; // 80% chance
}
// Check if selected animal is available
if (availableGoldenGreenAnimals.indexOf(selectedAnimal) !== -1) {
animal = selectedAnimal;
} else {
// If selected animal is not available, choose randomly from available
var randomIndex = Math.floor(Math.random() * availableGoldenGreenAnimals.length);
animal = availableGoldenGreenAnimals[randomIndex];
}
inventory.push(animal);
storage.inventory = inventory;
} else {
// All golden green animal types have 3 in inventory
animal = null;
var allGoldenGreenPetsText = new Text2('All golden green pets maxed out!', {
size: 60,
fill: 0xff0000
});
allGoldenGreenPetsText.anchor.set(0.5, 0.5);
allGoldenGreenPetsText.x = 2048 / 2;
allGoldenGreenPetsText.y = 1500;
game.addChild(allGoldenGreenPetsText);
LK.setTimeout(function () {
allGoldenGreenPetsText.destroy();
}, 2000);
}
// Only show hatched animal if we got a new pet
if (animal) {
var animalSprite = LK.getAsset(animal, {
anchorX: 0.5,
anchorY: 0.5
});
animalSprite.x = fallingEgg.x;
animalSprite.y = fallingEgg.y;
game.addChild(animalSprite);
// Remove animal after showing
LK.setTimeout(function () {
animalSprite.destroy();
}, 2000);
}
// Remove egg
fallingEgg.destroy();
fallingEgg = null;
}
};
}
};
// Handle red egg purchase
redEggItem.down = function () {
if (LK.getScore() >= 50000) {
LK.setScore(LK.getScore() - 50000);
scoreTxt.setText(LK.getScore().toString());
// Close shop
shopOverlay.destroy();
shopOverlay = null;
isShopOpen = false;
// Create falling red egg
fallingEgg = LK.getAsset('redEgg', {
anchorX: 0.5,
anchorY: 0.5
});
fallingEgg.x = 2048 / 2;
fallingEgg.y = -200;
eggClickCount = 0;
game.addChild(fallingEgg);
// Animate egg falling
tween(fallingEgg, {
y: 2732 / 2
}, {
duration: 1000
});
// Handle red egg clicking
fallingEgg.down = function () {
eggClickCount++;
if (eggClickCount === 1) {
// First crack
var crackedEgg1 = LK.getAsset('crackedEgg1', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg1.x = fallingEgg.x;
crackedEgg1.y = fallingEgg.y;
game.addChild(crackedEgg1);
fallingEgg.destroy();
fallingEgg = crackedEgg1;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 2) {
// Second crack
var crackedEgg2 = LK.getAsset('crackedEgg2', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg2.x = fallingEgg.x;
crackedEgg2.y = fallingEgg.y;
game.addChild(crackedEgg2);
fallingEgg.destroy();
fallingEgg = crackedEgg2;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 3) {
// Third crack - almost fully cracked
var crackedEgg3 = LK.getAsset('crackedEgg3', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg3.x = fallingEgg.x;
crackedEgg3.y = fallingEgg.y;
game.addChild(crackedEgg3);
fallingEgg.destroy();
fallingEgg = crackedEgg3;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 4) {
// Hatch the red egg with special probabilities
var availableRedAnimals = [];
var redAnimalTypes = ['trex', 'velector', 'titanaBull'];
for (var typeIndex = 0; typeIndex < redAnimalTypes.length; typeIndex++) {
var animalType = redAnimalTypes[typeIndex];
var countInInventory = 0;
for (var invIndex = 0; invIndex < inventory.length; invIndex++) {
if (inventory[invIndex] === animalType) {
countInInventory++;
}
}
if (countInInventory < 3) {
availableRedAnimals.push(animalType);
}
}
var animal;
if (availableRedAnimals.length > 0) {
// Special probability distribution for red eggs
var random = Math.random();
var selectedAnimal;
if (random < 0.05) {
selectedAnimal = 'trex'; // 5% chance
} else if (random < 0.3) {
selectedAnimal = 'velector'; // 25% chance
} else {
selectedAnimal = 'titanaBull'; // 70% chance
}
// Check if selected animal is available
if (availableRedAnimals.indexOf(selectedAnimal) !== -1) {
animal = selectedAnimal;
} else {
// If selected animal is not available, choose randomly from available
var randomIndex = Math.floor(Math.random() * availableRedAnimals.length);
animal = availableRedAnimals[randomIndex];
}
inventory.push(animal);
storage.inventory = inventory;
} else {
// All red animal types have 3 in inventory
animal = null;
var allRedPetsText = new Text2('All red pets maxed out!', {
size: 60,
fill: 0xff0000
});
allRedPetsText.anchor.set(0.5, 0.5);
allRedPetsText.x = 2048 / 2;
allRedPetsText.y = 1500;
game.addChild(allRedPetsText);
LK.setTimeout(function () {
allRedPetsText.destroy();
}, 2000);
}
// Only show hatched animal if we got a new pet
if (animal) {
var animalSprite = LK.getAsset(animal, {
anchorX: 0.5,
anchorY: 0.5
});
animalSprite.x = fallingEgg.x;
animalSprite.y = fallingEgg.y;
game.addChild(animalSprite);
// Remove animal after showing
LK.setTimeout(function () {
animalSprite.destroy();
}, 2000);
}
// Remove egg
fallingEgg.destroy();
fallingEgg = null;
}
};
}
};
// Handle golden red egg purchase
goldenRedEggItem.down = function () {
if (LK.getScore() >= 100000) {
LK.setScore(LK.getScore() - 100000);
scoreTxt.setText(LK.getScore().toString());
// Close shop
shopOverlay.destroy();
shopOverlay = null;
isShopOpen = false;
// Create falling golden red egg
fallingEgg = LK.getAsset('goldenRedEgg', {
anchorX: 0.5,
anchorY: 0.5
});
fallingEgg.x = 2048 / 2;
fallingEgg.y = -200;
eggClickCount = 0;
game.addChild(fallingEgg);
// Animate egg falling
tween(fallingEgg, {
y: 2732 / 2
}, {
duration: 1000
});
// Handle golden red egg clicking
fallingEgg.down = function () {
eggClickCount++;
if (eggClickCount === 1) {
// First crack
var crackedEgg1 = LK.getAsset('crackedEgg1', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg1.x = fallingEgg.x;
crackedEgg1.y = fallingEgg.y;
game.addChild(crackedEgg1);
fallingEgg.destroy();
fallingEgg = crackedEgg1;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 2) {
// Second crack
var crackedEgg2 = LK.getAsset('crackedEgg2', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg2.x = fallingEgg.x;
crackedEgg2.y = fallingEgg.y;
game.addChild(crackedEgg2);
fallingEgg.destroy();
fallingEgg = crackedEgg2;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 3) {
// Third crack - almost fully cracked
var crackedEgg3 = LK.getAsset('crackedEgg3', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg3.x = fallingEgg.x;
crackedEgg3.y = fallingEgg.y;
game.addChild(crackedEgg3);
fallingEgg.destroy();
fallingEgg = crackedEgg3;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 4) {
// Hatch the golden red egg with special probabilities
var availableGoldenRedAnimals = [];
var goldenRedAnimalTypes = ['goldenTrex', 'goldenVelector', 'goldenTitanaBull'];
for (var typeIndex = 0; typeIndex < goldenRedAnimalTypes.length; typeIndex++) {
var animalType = goldenRedAnimalTypes[typeIndex];
var countInInventory = 0;
for (var invIndex = 0; invIndex < inventory.length; invIndex++) {
if (inventory[invIndex] === animalType) {
countInInventory++;
}
}
if (countInInventory < 3) {
availableGoldenRedAnimals.push(animalType);
}
}
var animal;
if (availableGoldenRedAnimals.length > 0) {
// Special probability distribution for golden red eggs (same as red)
var random = Math.random();
var selectedAnimal;
if (random < 0.05) {
selectedAnimal = 'goldenTrex'; // 5% chance
} else if (random < 0.3) {
selectedAnimal = 'goldenVelector'; // 25% chance
} else {
selectedAnimal = 'goldenTitanaBull'; // 70% chance
}
// Check if selected animal is available
if (availableGoldenRedAnimals.indexOf(selectedAnimal) !== -1) {
animal = selectedAnimal;
} else {
// If selected animal is not available, choose randomly from available
var randomIndex = Math.floor(Math.random() * availableGoldenRedAnimals.length);
animal = availableGoldenRedAnimals[randomIndex];
}
inventory.push(animal);
storage.inventory = inventory;
} else {
// All golden red animal types have 3 in inventory
animal = null;
var allGoldenRedPetsText = new Text2('All golden red pets maxed out!', {
size: 60,
fill: 0xff0000
});
allGoldenRedPetsText.anchor.set(0.5, 0.5);
allGoldenRedPetsText.x = 2048 / 2;
allGoldenRedPetsText.y = 1500;
game.addChild(allGoldenRedPetsText);
LK.setTimeout(function () {
allGoldenRedPetsText.destroy();
}, 2000);
}
// Only show hatched animal if we got a new pet
if (animal) {
var animalSprite = LK.getAsset(animal, {
anchorX: 0.5,
anchorY: 0.5
});
animalSprite.x = fallingEgg.x;
animalSprite.y = fallingEgg.y;
game.addChild(animalSprite);
// Remove animal after showing
LK.setTimeout(function () {
animalSprite.destroy();
}, 2000);
}
// Remove egg
fallingEgg.destroy();
fallingEgg = null;
}
};
}
};
// Handle purple egg purchase
purpleEggItem.down = function () {
if (LK.getScore() >= 1250000) {
LK.setScore(LK.getScore() - 1250000);
scoreTxt.setText(LK.getScore().toString());
// Close shop
shopOverlay.destroy();
shopOverlay = null;
isShopOpen = false;
// Create falling purple egg
fallingEgg = LK.getAsset('purpleEgg', {
anchorX: 0.5,
anchorY: 0.5
});
fallingEgg.x = 2048 / 2;
fallingEgg.y = -200;
eggClickCount = 0;
game.addChild(fallingEgg);
// Animate egg falling
tween(fallingEgg, {
y: 2732 / 2
}, {
duration: 1000
});
// Handle purple egg clicking
fallingEgg.down = function () {
eggClickCount++;
if (eggClickCount === 1) {
// First crack
var crackedEgg1 = LK.getAsset('crackedEgg1', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg1.x = fallingEgg.x;
crackedEgg1.y = fallingEgg.y;
game.addChild(crackedEgg1);
fallingEgg.destroy();
fallingEgg = crackedEgg1;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 2) {
// Second crack
var crackedEgg2 = LK.getAsset('crackedEgg2', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg2.x = fallingEgg.x;
crackedEgg2.y = fallingEgg.y;
game.addChild(crackedEgg2);
fallingEgg.destroy();
fallingEgg = crackedEgg2;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 3) {
// Third crack - almost fully cracked
var crackedEgg3 = LK.getAsset('crackedEgg3', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg3.x = fallingEgg.x;
crackedEgg3.y = fallingEgg.y;
game.addChild(crackedEgg3);
fallingEgg.destroy();
fallingEgg = crackedEgg3;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 4) {
// Hatch the purple egg with special probabilities
var availablePurpleAnimals = [];
var purpleAnimalTypes = ['ironMan', 'captainAmerica', 'spiderman'];
for (var typeIndex = 0; typeIndex < purpleAnimalTypes.length; typeIndex++) {
var animalType = purpleAnimalTypes[typeIndex];
var countInInventory = 0;
for (var invIndex = 0; invIndex < inventory.length; invIndex++) {
if (inventory[invIndex] === animalType) {
countInInventory++;
}
}
if (countInInventory < 3) {
availablePurpleAnimals.push(animalType);
}
}
var animal;
if (availablePurpleAnimals.length > 0) {
// Special probability distribution for purple eggs
var random = Math.random();
var selectedAnimal;
if (random < 0.01) {
selectedAnimal = 'ironMan'; // 1% chance
} else if (random < 0.15) {
selectedAnimal = 'captainAmerica'; // 14% chance
} else {
selectedAnimal = 'spiderman'; // 85% chance
}
// Check if selected animal is available
if (availablePurpleAnimals.indexOf(selectedAnimal) !== -1) {
animal = selectedAnimal;
} else {
// If selected animal is not available, choose randomly from available
var randomIndex = Math.floor(Math.random() * availablePurpleAnimals.length);
animal = availablePurpleAnimals[randomIndex];
}
inventory.push(animal);
storage.inventory = inventory;
} else {
// All purple animal types have 3 in inventory
animal = null;
var allPurplePetsText = new Text2('All purple pets maxed out!', {
size: 60,
fill: 0xff0000
});
allPurplePetsText.anchor.set(0.5, 0.5);
allPurplePetsText.x = 2048 / 2;
allPurplePetsText.y = 1500;
game.addChild(allPurplePetsText);
LK.setTimeout(function () {
allPurplePetsText.destroy();
}, 2000);
}
// Only show hatched animal if we got a new pet
if (animal) {
var animalSprite = LK.getAsset(animal, {
anchorX: 0.5,
anchorY: 0.5
});
animalSprite.x = fallingEgg.x;
animalSprite.y = fallingEgg.y;
game.addChild(animalSprite);
// Remove animal after showing
LK.setTimeout(function () {
animalSprite.destroy();
}, 2000);
}
// Remove egg
fallingEgg.destroy();
fallingEgg = null;
}
};
}
};
// Handle golden purple egg purchase
goldenPurpleEggItem.down = function () {
if (LK.getScore() >= 2500000) {
LK.setScore(LK.getScore() - 2500000);
scoreTxt.setText(LK.getScore().toString());
// Close shop
shopOverlay.destroy();
shopOverlay = null;
isShopOpen = false;
// Create falling golden purple egg
fallingEgg = LK.getAsset('goldenPurpleEgg', {
anchorX: 0.5,
anchorY: 0.5
});
fallingEgg.x = 2048 / 2;
fallingEgg.y = -200;
eggClickCount = 0;
game.addChild(fallingEgg);
// Animate egg falling
tween(fallingEgg, {
y: 2732 / 2
}, {
duration: 1000
});
// Handle golden purple egg clicking
fallingEgg.down = function () {
eggClickCount++;
if (eggClickCount === 1) {
// First crack
var crackedEgg1 = LK.getAsset('crackedEgg1', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg1.x = fallingEgg.x;
crackedEgg1.y = fallingEgg.y;
game.addChild(crackedEgg1);
fallingEgg.destroy();
fallingEgg = crackedEgg1;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 2) {
// Second crack
var crackedEgg2 = LK.getAsset('crackedEgg2', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg2.x = fallingEgg.x;
crackedEgg2.y = fallingEgg.y;
game.addChild(crackedEgg2);
fallingEgg.destroy();
fallingEgg = crackedEgg2;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 3) {
// Third crack - almost fully cracked
var crackedEgg3 = LK.getAsset('crackedEgg3', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg3.x = fallingEgg.x;
crackedEgg3.y = fallingEgg.y;
game.addChild(crackedEgg3);
fallingEgg.destroy();
fallingEgg = crackedEgg3;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 4) {
// Hatch the golden purple egg with special probabilities
var availableGoldenPurpleAnimals = [];
var goldenPurpleAnimalTypes = ['goldenIronMan', 'goldenCaptainAmerica', 'goldenSpiderman'];
for (var typeIndex = 0; typeIndex < goldenPurpleAnimalTypes.length; typeIndex++) {
var animalType = goldenPurpleAnimalTypes[typeIndex];
var countInInventory = 0;
for (var invIndex = 0; invIndex < inventory.length; invIndex++) {
if (inventory[invIndex] === animalType) {
countInInventory++;
}
}
if (countInInventory < 3) {
availableGoldenPurpleAnimals.push(animalType);
}
}
var animal;
if (availableGoldenPurpleAnimals.length > 0) {
// Special probability distribution for golden purple eggs (same as purple)
var random = Math.random();
var selectedAnimal;
if (random < 0.01) {
selectedAnimal = 'goldenIronMan'; // 1% chance
} else if (random < 0.15) {
selectedAnimal = 'goldenCaptainAmerica'; // 14% chance
} else {
selectedAnimal = 'goldenSpiderman'; // 85% chance
}
// Check if selected animal is available
if (availableGoldenPurpleAnimals.indexOf(selectedAnimal) !== -1) {
animal = selectedAnimal;
} else {
// If selected animal is not available, choose randomly from available
var randomIndex = Math.floor(Math.random() * availableGoldenPurpleAnimals.length);
animal = availableGoldenPurpleAnimals[randomIndex];
}
inventory.push(animal);
storage.inventory = inventory;
} else {
// All golden purple animal types have 3 in inventory
animal = null;
var allGoldenPurplePetsText = new Text2('All golden purple pets maxed out!', {
size: 60,
fill: 0xff0000
});
allGoldenPurplePetsText.anchor.set(0.5, 0.5);
allGoldenPurplePetsText.x = 2048 / 2;
allGoldenPurplePetsText.y = 1500;
game.addChild(allGoldenPurplePetsText);
LK.setTimeout(function () {
allGoldenPurplePetsText.destroy();
}, 2000);
}
// Only show hatched animal if we got a new pet
if (animal) {
var animalSprite = LK.getAsset(animal, {
anchorX: 0.5,
anchorY: 0.5
});
animalSprite.x = fallingEgg.x;
animalSprite.y = fallingEgg.y;
game.addChild(animalSprite);
// Remove animal after showing
LK.setTimeout(function () {
animalSprite.destroy();
}, 2000);
}
// Remove egg
fallingEgg.destroy();
fallingEgg = null;
}
};
}
};
// Handle white egg purchase
whiteEggItem.down = function () {
if (LK.getScore() >= 10000000) {
LK.setScore(LK.getScore() - 10000000);
scoreTxt.setText(LK.getScore().toString());
// Close shop
shopOverlay.destroy();
shopOverlay = null;
isShopOpen = false;
// Create falling white egg
fallingEgg = LK.getAsset('whiteEgg', {
anchorX: 0.5,
anchorY: 0.5
});
fallingEgg.x = 2048 / 2;
fallingEgg.y = -200;
eggClickCount = 0;
game.addChild(fallingEgg);
// Animate egg falling
tween(fallingEgg, {
y: 2732 / 2
}, {
duration: 1000
});
// Handle white egg clicking
fallingEgg.down = function () {
eggClickCount++;
if (eggClickCount === 1) {
// First crack
var crackedEgg1 = LK.getAsset('crackedEgg1', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg1.x = fallingEgg.x;
crackedEgg1.y = fallingEgg.y;
game.addChild(crackedEgg1);
fallingEgg.destroy();
fallingEgg = crackedEgg1;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 2) {
// Second crack
var crackedEgg2 = LK.getAsset('crackedEgg2', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg2.x = fallingEgg.x;
crackedEgg2.y = fallingEgg.y;
game.addChild(crackedEgg2);
fallingEgg.destroy();
fallingEgg = crackedEgg2;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 3) {
// Third crack - almost fully cracked
var crackedEgg3 = LK.getAsset('crackedEgg3', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg3.x = fallingEgg.x;
crackedEgg3.y = fallingEgg.y;
game.addChild(crackedEgg3);
fallingEgg.destroy();
fallingEgg = crackedEgg3;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 4) {
// Hatch the white egg with special probabilities
var availableWhiteAnimals = [];
var whiteAnimalTypes = ['king', 'knight', 'human'];
for (var typeIndex = 0; typeIndex < whiteAnimalTypes.length; typeIndex++) {
var animalType = whiteAnimalTypes[typeIndex];
var countInInventory = 0;
for (var invIndex = 0; invIndex < inventory.length; invIndex++) {
if (inventory[invIndex] === animalType) {
countInInventory++;
}
}
if (countInInventory < 3) {
availableWhiteAnimals.push(animalType);
}
}
var animal;
if (availableWhiteAnimals.length > 0) {
// Special probability distribution for white eggs
var random = Math.random();
var selectedAnimal;
if (random < 0.005) {
selectedAnimal = 'king'; // 0.5% chance
} else if (random < 0.055) {
selectedAnimal = 'knight'; // 5% chance
} else {
selectedAnimal = 'human'; // 94.5% chance
}
// Check if selected animal is available
if (availableWhiteAnimals.indexOf(selectedAnimal) !== -1) {
animal = selectedAnimal;
} else {
// If selected animal is not available, choose randomly from available
var randomIndex = Math.floor(Math.random() * availableWhiteAnimals.length);
animal = availableWhiteAnimals[randomIndex];
}
inventory.push(animal);
storage.inventory = inventory;
} else {
// All white animal types have 3 in inventory
animal = null;
var allWhitePetsText = new Text2('All white pets maxed out!', {
size: 60,
fill: 0xff0000
});
allWhitePetsText.anchor.set(0.5, 0.5);
allWhitePetsText.x = 2048 / 2;
allWhitePetsText.y = 1500;
game.addChild(allWhitePetsText);
LK.setTimeout(function () {
allWhitePetsText.destroy();
}, 2000);
}
// Only show hatched animal if we got a new pet
if (animal) {
var animalSprite = LK.getAsset(animal, {
anchorX: 0.5,
anchorY: 0.5
});
animalSprite.x = fallingEgg.x;
animalSprite.y = fallingEgg.y;
game.addChild(animalSprite);
// Remove animal after showing
LK.setTimeout(function () {
animalSprite.destroy();
}, 2000);
}
// Remove egg
fallingEgg.destroy();
fallingEgg = null;
}
};
}
};
// Handle golden white egg purchase
goldenWhiteEggItem.down = function () {
if (LK.getScore() >= 20000000) {
LK.setScore(LK.getScore() - 20000000);
scoreTxt.setText(LK.getScore().toString());
// Close shop
shopOverlay.destroy();
shopOverlay = null;
isShopOpen = false;
// Create falling golden white egg
fallingEgg = LK.getAsset('goldenWhiteEgg', {
anchorX: 0.5,
anchorY: 0.5
});
fallingEgg.x = 2048 / 2;
fallingEgg.y = -200;
eggClickCount = 0;
game.addChild(fallingEgg);
// Animate egg falling
tween(fallingEgg, {
y: 2732 / 2
}, {
duration: 1000
});
// Handle golden white egg clicking
fallingEgg.down = function () {
eggClickCount++;
if (eggClickCount === 1) {
// First crack
var crackedEgg1 = LK.getAsset('crackedEgg1', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg1.x = fallingEgg.x;
crackedEgg1.y = fallingEgg.y;
game.addChild(crackedEgg1);
fallingEgg.destroy();
fallingEgg = crackedEgg1;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 2) {
// Second crack
var crackedEgg2 = LK.getAsset('crackedEgg2', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg2.x = fallingEgg.x;
crackedEgg2.y = fallingEgg.y;
game.addChild(crackedEgg2);
fallingEgg.destroy();
fallingEgg = crackedEgg2;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 3) {
// Third crack - almost fully cracked
var crackedEgg3 = LK.getAsset('crackedEgg3', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg3.x = fallingEgg.x;
crackedEgg3.y = fallingEgg.y;
game.addChild(crackedEgg3);
fallingEgg.destroy();
fallingEgg = crackedEgg3;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 4) {
// Hatch the golden white egg with special probabilities
var availableGoldenWhiteAnimals = [];
var goldenWhiteAnimalTypes = ['goldenKing', 'goldenKnight', 'goldenHuman'];
for (var typeIndex = 0; typeIndex < goldenWhiteAnimalTypes.length; typeIndex++) {
var animalType = goldenWhiteAnimalTypes[typeIndex];
var countInInventory = 0;
for (var invIndex = 0; invIndex < inventory.length; invIndex++) {
if (inventory[invIndex] === animalType) {
countInInventory++;
}
}
if (countInInventory < 3) {
availableGoldenWhiteAnimals.push(animalType);
}
}
var animal;
if (availableGoldenWhiteAnimals.length > 0) {
// Special probability distribution for golden white eggs (same as white)
var random = Math.random();
var selectedAnimal;
if (random < 0.005) {
selectedAnimal = 'goldenKing'; // 0.5% chance
} else if (random < 0.055) {
selectedAnimal = 'goldenKnight'; // 5% chance
} else {
selectedAnimal = 'goldenHuman'; // 94.5% chance
}
// Check if selected animal is available
if (availableGoldenWhiteAnimals.indexOf(selectedAnimal) !== -1) {
animal = selectedAnimal;
} else {
// If selected animal is not available, choose randomly from available
var randomIndex = Math.floor(Math.random() * availableGoldenWhiteAnimals.length);
animal = availableGoldenWhiteAnimals[randomIndex];
}
inventory.push(animal);
storage.inventory = inventory;
} else {
// All golden white animal types have 3 in inventory
animal = null;
var allGoldenWhitePetsText = new Text2('All golden white pets maxed out!', {
size: 60,
fill: 0xff0000
});
allGoldenWhitePetsText.anchor.set(0.5, 0.5);
allGoldenWhitePetsText.x = 2048 / 2;
allGoldenWhitePetsText.y = 1500;
game.addChild(allGoldenWhitePetsText);
LK.setTimeout(function () {
allGoldenWhitePetsText.destroy();
}, 2000);
}
// Only show hatched animal if we got a new pet
if (animal) {
var animalSprite = LK.getAsset(animal, {
anchorX: 0.5,
anchorY: 0.5
});
animalSprite.x = fallingEgg.x;
animalSprite.y = fallingEgg.y;
game.addChild(animalSprite);
// Remove animal after showing
LK.setTimeout(function () {
animalSprite.destroy();
}, 2000);
}
// Remove egg
fallingEgg.destroy();
fallingEgg = null;
}
};
}
};
// Handle golden egg purchase
goldenEggItem.down = function () {
if (LK.getScore() >= 10000) {
LK.setScore(LK.getScore() - 10000);
scoreTxt.setText(LK.getScore().toString());
// Close shop
shopOverlay.destroy();
shopOverlay = null;
isShopOpen = false;
// Create falling golden egg
fallingEgg = LK.getAsset('goldenEgg', {
anchorX: 0.5,
anchorY: 0.5
});
fallingEgg.x = 2048 / 2;
fallingEgg.y = -200;
eggClickCount = 0;
game.addChild(fallingEgg);
// Animate egg falling
tween(fallingEgg, {
y: 2732 / 2
}, {
duration: 1000
});
// Handle golden egg clicking
fallingEgg.down = function () {
eggClickCount++;
if (eggClickCount === 1) {
// First crack
var crackedEgg1 = LK.getAsset('crackedEgg1', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg1.x = fallingEgg.x;
crackedEgg1.y = fallingEgg.y;
game.addChild(crackedEgg1);
fallingEgg.destroy();
fallingEgg = crackedEgg1;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 2) {
// Second crack
var crackedEgg2 = LK.getAsset('crackedEgg2', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg2.x = fallingEgg.x;
crackedEgg2.y = fallingEgg.y;
game.addChild(crackedEgg2);
fallingEgg.destroy();
fallingEgg = crackedEgg2;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 3) {
// Third crack - almost fully cracked
var crackedEgg3 = LK.getAsset('crackedEgg3', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg3.x = fallingEgg.x;
crackedEgg3.y = fallingEgg.y;
game.addChild(crackedEgg3);
fallingEgg.destroy();
fallingEgg = crackedEgg3;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 4) {
// Hatch the golden egg with special probabilities
var availableGoldenAnimals = [];
var goldenAnimalTypes = ['goldenDog', 'goldenCat', 'goldenSnake'];
for (var typeIndex = 0; typeIndex < goldenAnimalTypes.length; typeIndex++) {
var animalType = goldenAnimalTypes[typeIndex];
var countInInventory = 0;
for (var invIndex = 0; invIndex < inventory.length; invIndex++) {
if (inventory[invIndex] === animalType) {
countInInventory++;
}
}
if (countInInventory < 3) {
availableGoldenAnimals.push(animalType);
}
}
var animal;
if (availableGoldenAnimals.length > 0) {
// Special probability distribution for golden eggs
var random = Math.random();
var selectedAnimal;
if (random < 0.6) {
selectedAnimal = 'goldenDog'; // 60% chance
} else if (random < 0.9) {
selectedAnimal = 'goldenCat'; // 30% chance
} else {
selectedAnimal = 'goldenSnake'; // 10% chance
}
// Check if selected animal is available
if (availableGoldenAnimals.indexOf(selectedAnimal) !== -1) {
animal = selectedAnimal;
} else {
// If selected animal is not available, choose randomly from available
var randomIndex = Math.floor(Math.random() * availableGoldenAnimals.length);
animal = availableGoldenAnimals[randomIndex];
}
inventory.push(animal);
storage.inventory = inventory;
} else {
// All golden animal types have 3 in inventory
animal = null;
var allGoldenPetsText = new Text2('All golden pets maxed out!', {
size: 60,
fill: 0xff0000
});
allGoldenPetsText.anchor.set(0.5, 0.5);
allGoldenPetsText.x = 2048 / 2;
allGoldenPetsText.y = 1500;
game.addChild(allGoldenPetsText);
LK.setTimeout(function () {
allGoldenPetsText.destroy();
}, 2000);
}
// Only show hatched animal if we got a new pet
if (animal) {
var animalSprite = LK.getAsset(animal, {
anchorX: 0.5,
anchorY: 0.5
});
animalSprite.x = fallingEgg.x;
animalSprite.y = fallingEgg.y;
game.addChild(animalSprite);
// Remove animal after showing
LK.setTimeout(function () {
animalSprite.destroy();
}, 2000);
}
// Remove egg
fallingEgg.destroy();
fallingEgg = null;
}
};
}
};
// Handle space egg purchase
spaceEggItem.down = function () {
if (LK.getScore() >= 100000000) {
LK.setScore(LK.getScore() - 100000000);
scoreTxt.setText(LK.getScore().toString());
// Close shop
shopOverlay.destroy();
shopOverlay = null;
isShopOpen = false;
// Create falling space egg
fallingEgg = LK.getAsset('spaceEgg', {
anchorX: 0.5,
anchorY: 0.5
});
fallingEgg.x = 2048 / 2;
fallingEgg.y = -200;
eggClickCount = 0;
game.addChild(fallingEgg);
// Animate egg falling
tween(fallingEgg, {
y: 2732 / 2
}, {
duration: 1000
});
// Handle space egg clicking
fallingEgg.down = function () {
eggClickCount++;
if (eggClickCount === 1) {
// First crack
var crackedEgg1 = LK.getAsset('crackedEgg1', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg1.x = fallingEgg.x;
crackedEgg1.y = fallingEgg.y;
game.addChild(crackedEgg1);
fallingEgg.destroy();
fallingEgg = crackedEgg1;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 2) {
// Second crack
var crackedEgg2 = LK.getAsset('crackedEgg2', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg2.x = fallingEgg.x;
crackedEgg2.y = fallingEgg.y;
game.addChild(crackedEgg2);
fallingEgg.destroy();
fallingEgg = crackedEgg2;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 3) {
// Third crack - almost fully cracked
var crackedEgg3 = LK.getAsset('crackedEgg3', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg3.x = fallingEgg.x;
crackedEgg3.y = fallingEgg.y;
game.addChild(crackedEgg3);
fallingEgg.destroy();
fallingEgg = crackedEgg3;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 4) {
// Hatch the space egg with special probabilities
var availableSpaceAnimals = [];
var spaceAnimalTypes = ['earth', 'moon', 'meteor'];
for (var typeIndex = 0; typeIndex < spaceAnimalTypes.length; typeIndex++) {
var animalType = spaceAnimalTypes[typeIndex];
var countInInventory = 0;
for (var invIndex = 0; invIndex < inventory.length; invIndex++) {
if (inventory[invIndex] === animalType) {
countInInventory++;
}
}
if (countInInventory < 3) {
availableSpaceAnimals.push(animalType);
}
}
var animal;
if (availableSpaceAnimals.length > 0) {
// Special probability distribution for space eggs
var random = Math.random();
var selectedAnimal;
if (random < 0.001) {
selectedAnimal = 'earth'; // 0.1% chance
} else if (random < 0.011) {
selectedAnimal = 'moon'; // 1% chance
} else {
selectedAnimal = 'meteor'; // 98.9% chance
}
// Check if selected animal is available
if (availableSpaceAnimals.indexOf(selectedAnimal) !== -1) {
animal = selectedAnimal;
} else {
// If selected animal is not available, choose randomly from available
var randomIndex = Math.floor(Math.random() * availableSpaceAnimals.length);
animal = availableSpaceAnimals[randomIndex];
}
inventory.push(animal);
storage.inventory = inventory;
} else {
// All space animal types have 3 in inventory
animal = null;
var allSpacePetsText = new Text2('All space pets maxed out!', {
size: 60,
fill: 0xff0000
});
allSpacePetsText.anchor.set(0.5, 0.5);
allSpacePetsText.x = 2048 / 2;
allSpacePetsText.y = 1500;
game.addChild(allSpacePetsText);
LK.setTimeout(function () {
allSpacePetsText.destroy();
}, 2000);
}
// Only show hatched animal if we got a new pet
if (animal) {
var animalSprite = LK.getAsset(animal, {
anchorX: 0.5,
anchorY: 0.5
});
animalSprite.x = fallingEgg.x;
animalSprite.y = fallingEgg.y;
game.addChild(animalSprite);
// Remove animal after showing
LK.setTimeout(function () {
animalSprite.destroy();
}, 2000);
}
// Remove egg
fallingEgg.destroy();
fallingEgg = null;
}
};
}
};
// Handle space2 egg purchase
space2EggItem.down = function () {
if (LK.getScore() >= 200000000) {
LK.setScore(LK.getScore() - 200000000);
scoreTxt.setText(LK.getScore().toString());
// Close shop
shopOverlay.destroy();
shopOverlay = null;
isShopOpen = false;
// Create falling space2 egg
fallingEgg = LK.getAsset('space2Egg', {
anchorX: 0.5,
anchorY: 0.5
});
fallingEgg.x = 2048 / 2;
fallingEgg.y = -200;
eggClickCount = 0;
game.addChild(fallingEgg);
// Animate egg falling
tween(fallingEgg, {
y: 2732 / 2
}, {
duration: 1000
});
// Handle space2 egg clicking
fallingEgg.down = function () {
eggClickCount++;
if (eggClickCount === 1) {
// First crack
var crackedEgg1 = LK.getAsset('crackedEgg1', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg1.x = fallingEgg.x;
crackedEgg1.y = fallingEgg.y;
game.addChild(crackedEgg1);
fallingEgg.destroy();
fallingEgg = crackedEgg1;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 2) {
// Second crack
var crackedEgg2 = LK.getAsset('crackedEgg2', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg2.x = fallingEgg.x;
crackedEgg2.y = fallingEgg.y;
game.addChild(crackedEgg2);
fallingEgg.destroy();
fallingEgg = crackedEgg2;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 3) {
// Third crack - almost fully cracked
var crackedEgg3 = LK.getAsset('crackedEgg3', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg3.x = fallingEgg.x;
crackedEgg3.y = fallingEgg.y;
game.addChild(crackedEgg3);
fallingEgg.destroy();
fallingEgg = crackedEgg3;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 4) {
// Hatch the space2 egg with special probabilities
var availableSpace2Animals = [];
var space2AnimalTypes = ['sun', 'jupiter', 'neptune'];
for (var typeIndex = 0; typeIndex < space2AnimalTypes.length; typeIndex++) {
var animalType = space2AnimalTypes[typeIndex];
var countInInventory = 0;
for (var invIndex = 0; invIndex < inventory.length; invIndex++) {
if (inventory[invIndex] === animalType) {
countInInventory++;
}
}
if (countInInventory < 3) {
availableSpace2Animals.push(animalType);
}
}
var animal;
if (availableSpace2Animals.length > 0) {
// Special probability distribution for space2 eggs
var random = Math.random();
var selectedAnimal;
if (random < 0.0001) {
selectedAnimal = 'sun'; // 0.01% chance
} else if (random < 0.0011) {
selectedAnimal = 'jupiter'; // 0.1% chance
} else {
selectedAnimal = 'neptune'; // 99.9% chance
}
// Check if selected animal is available
if (availableSpace2Animals.indexOf(selectedAnimal) !== -1) {
animal = selectedAnimal;
} else {
// If selected animal is not available, choose randomly from available
var randomIndex = Math.floor(Math.random() * availableSpace2Animals.length);
animal = availableSpace2Animals[randomIndex];
}
inventory.push(animal);
storage.inventory = inventory;
} else {
// All space2 animal types have 3 in inventory
animal = null;
var allSpace2PetsText = new Text2('All space2 pets maxed out!', {
size: 60,
fill: 0xff0000
});
allSpace2PetsText.anchor.set(0.5, 0.5);
allSpace2PetsText.x = 2048 / 2;
allSpace2PetsText.y = 1500;
game.addChild(allSpace2PetsText);
LK.setTimeout(function () {
allSpace2PetsText.destroy();
}, 2000);
}
// Only show hatched animal if we got a new pet
if (animal) {
var animalSprite = LK.getAsset(animal, {
anchorX: 0.5,
anchorY: 0.5
});
animalSprite.x = fallingEgg.x;
animalSprite.y = fallingEgg.y;
game.addChild(animalSprite);
// Remove animal after showing
LK.setTimeout(function () {
animalSprite.destroy();
}, 2000);
}
// Remove egg
fallingEgg.destroy();
fallingEgg = null;
}
};
}
};
// Handle golden space egg purchase
goldenSpaceEggItem.down = function () {
if (LK.getScore() >= 200000000) {
LK.setScore(LK.getScore() - 200000000);
scoreTxt.setText(LK.getScore().toString());
// Close shop
shopOverlay.destroy();
shopOverlay = null;
isShopOpen = false;
// Create falling golden space egg
fallingEgg = LK.getAsset('goldenSpaceEgg', {
anchorX: 0.5,
anchorY: 0.5
});
fallingEgg.x = 2048 / 2;
fallingEgg.y = -200;
eggClickCount = 0;
game.addChild(fallingEgg);
// Animate egg falling
tween(fallingEgg, {
y: 2732 / 2
}, {
duration: 1000
});
// Handle golden space egg clicking
fallingEgg.down = function () {
eggClickCount++;
if (eggClickCount === 1) {
// First crack
var crackedEgg1 = LK.getAsset('crackedEgg1', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg1.x = fallingEgg.x;
crackedEgg1.y = fallingEgg.y;
game.addChild(crackedEgg1);
fallingEgg.destroy();
fallingEgg = crackedEgg1;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 2) {
// Second crack
var crackedEgg2 = LK.getAsset('crackedEgg2', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg2.x = fallingEgg.x;
crackedEgg2.y = fallingEgg.y;
game.addChild(crackedEgg2);
fallingEgg.destroy();
fallingEgg = crackedEgg2;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 3) {
// Third crack - almost fully cracked
var crackedEgg3 = LK.getAsset('crackedEgg3', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg3.x = fallingEgg.x;
crackedEgg3.y = fallingEgg.y;
game.addChild(crackedEgg3);
fallingEgg.destroy();
fallingEgg = crackedEgg3;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 4) {
// Hatch the golden space egg with special probabilities
var availableGoldenSpaceAnimals = [];
var goldenSpaceAnimalTypes = ['goldenEarth', 'goldenMoon', 'goldenMeteor'];
for (var typeIndex = 0; typeIndex < goldenSpaceAnimalTypes.length; typeIndex++) {
var animalType = goldenSpaceAnimalTypes[typeIndex];
var countInInventory = 0;
for (var invIndex = 0; invIndex < inventory.length; invIndex++) {
if (inventory[invIndex] === animalType) {
countInInventory++;
}
}
if (countInInventory < 3) {
availableGoldenSpaceAnimals.push(animalType);
}
}
var animal;
if (availableGoldenSpaceAnimals.length > 0) {
// Special probability distribution for golden space eggs (same as space)
var random = Math.random();
var selectedAnimal;
if (random < 0.001) {
selectedAnimal = 'goldenEarth'; // 0.1% chance
} else if (random < 0.011) {
selectedAnimal = 'goldenMoon'; // 1% chance
} else {
selectedAnimal = 'goldenMeteor'; // 98.9% chance
}
// Check if selected animal is available
if (availableGoldenSpaceAnimals.indexOf(selectedAnimal) !== -1) {
animal = selectedAnimal;
} else {
// If selected animal is not available, choose randomly from available
var randomIndex = Math.floor(Math.random() * availableGoldenSpaceAnimals.length);
animal = availableGoldenSpaceAnimals[randomIndex];
}
inventory.push(animal);
storage.inventory = inventory;
} else {
// All golden space animal types have 3 in inventory
animal = null;
var allGoldenSpacePetsText = new Text2('All golden space pets maxed out!', {
size: 60,
fill: 0xff0000
});
allGoldenSpacePetsText.anchor.set(0.5, 0.5);
allGoldenSpacePetsText.x = 2048 / 2;
allGoldenSpacePetsText.y = 1500;
game.addChild(allGoldenSpacePetsText);
LK.setTimeout(function () {
allGoldenSpacePetsText.destroy();
}, 2000);
}
// Only show hatched animal if we got a new pet
if (animal) {
var animalSprite = LK.getAsset(animal, {
anchorX: 0.5,
anchorY: 0.5
});
animalSprite.x = fallingEgg.x;
animalSprite.y = fallingEgg.y;
game.addChild(animalSprite);
// Remove animal after showing
LK.setTimeout(function () {
animalSprite.destroy();
}, 2000);
}
// Remove egg
fallingEgg.destroy();
fallingEgg = null;
}
};
}
};
// Handle golden space2 egg purchase
goldenSpace2EggItem.down = function () {
if (LK.getScore() >= 400000000) {
LK.setScore(LK.getScore() - 400000000);
scoreTxt.setText(LK.getScore().toString());
// Close shop
shopOverlay.destroy();
shopOverlay = null;
isShopOpen = false;
// Create falling golden space2 egg
fallingEgg = LK.getAsset('goldenSpace2Egg', {
anchorX: 0.5,
anchorY: 0.5
});
fallingEgg.x = 2048 / 2;
fallingEgg.y = -200;
eggClickCount = 0;
game.addChild(fallingEgg);
// Animate egg falling
tween(fallingEgg, {
y: 2732 / 2
}, {
duration: 1000
});
// Handle golden space2 egg clicking
fallingEgg.down = function () {
eggClickCount++;
if (eggClickCount === 1) {
// First crack
var crackedEgg1 = LK.getAsset('crackedEgg1', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg1.x = fallingEgg.x;
crackedEgg1.y = fallingEgg.y;
game.addChild(crackedEgg1);
fallingEgg.destroy();
fallingEgg = crackedEgg1;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 2) {
// Second crack
var crackedEgg2 = LK.getAsset('crackedEgg2', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg2.x = fallingEgg.x;
crackedEgg2.y = fallingEgg.y;
game.addChild(crackedEgg2);
fallingEgg.destroy();
fallingEgg = crackedEgg2;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 3) {
// Third crack - almost fully cracked
var crackedEgg3 = LK.getAsset('crackedEgg3', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg3.x = fallingEgg.x;
crackedEgg3.y = fallingEgg.y;
game.addChild(crackedEgg3);
fallingEgg.destroy();
fallingEgg = crackedEgg3;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 4) {
// Hatch the golden space2 egg with special probabilities
var availableGoldenSpace2Animals = [];
var goldenSpace2AnimalTypes = ['goldenSun', 'goldenJupiter', 'goldenNeptune'];
for (var typeIndex = 0; typeIndex < goldenSpace2AnimalTypes.length; typeIndex++) {
var animalType = goldenSpace2AnimalTypes[typeIndex];
var countInInventory = 0;
for (var invIndex = 0; invIndex < inventory.length; invIndex++) {
if (inventory[invIndex] === animalType) {
countInInventory++;
}
}
if (countInInventory < 3) {
availableGoldenSpace2Animals.push(animalType);
}
}
var animal;
if (availableGoldenSpace2Animals.length > 0) {
// Special probability distribution for golden space2 eggs (same as space2)
var random = Math.random();
var selectedAnimal;
if (random < 0.0001) {
selectedAnimal = 'goldenSun'; // 0.01% chance
} else if (random < 0.0011) {
selectedAnimal = 'goldenJupiter'; // 0.1% chance
} else {
selectedAnimal = 'goldenNeptune'; // 99.9% chance
}
// Check if selected animal is available
if (availableGoldenSpace2Animals.indexOf(selectedAnimal) !== -1) {
animal = selectedAnimal;
} else {
// If selected animal is not available, choose randomly from available
var randomIndex = Math.floor(Math.random() * availableGoldenSpace2Animals.length);
animal = availableGoldenSpace2Animals[randomIndex];
}
inventory.push(animal);
storage.inventory = inventory;
} else {
// All golden space2 animal types have 3 in inventory
animal = null;
var allGoldenSpace2PetsText = new Text2('All golden space2 pets maxed out!', {
size: 60,
fill: 0xff0000
});
allGoldenSpace2PetsText.anchor.set(0.5, 0.5);
allGoldenSpace2PetsText.x = 2048 / 2;
allGoldenSpace2PetsText.y = 1500;
game.addChild(allGoldenSpace2PetsText);
LK.setTimeout(function () {
allGoldenSpace2PetsText.destroy();
}, 2000);
}
// Only show hatched animal if we got a new pet
if (animal) {
var animalSprite = LK.getAsset(animal, {
anchorX: 0.5,
anchorY: 0.5
});
animalSprite.x = fallingEgg.x;
animalSprite.y = fallingEgg.y;
game.addChild(animalSprite);
// Remove animal after showing
LK.setTimeout(function () {
animalSprite.destroy();
}, 2000);
}
// Remove egg
fallingEgg.destroy();
fallingEgg = null;
}
};
}
};
// Handle galaxy egg purchase
galaxyEggItem.down = function () {
if (LK.getScore() >= 500000000) {
LK.setScore(LK.getScore() - 500000000);
scoreTxt.setText(LK.getScore().toString());
// Close shop
shopOverlay.destroy();
shopOverlay = null;
isShopOpen = false;
// Create falling galaxy egg
fallingEgg = LK.getAsset('galaxyEgg', {
anchorX: 0.5,
anchorY: 0.5
});
fallingEgg.x = 2048 / 2;
fallingEgg.y = -200;
eggClickCount = 0;
game.addChild(fallingEgg);
// Animate egg falling
tween(fallingEgg, {
y: 2732 / 2
}, {
duration: 1000
});
// Handle galaxy egg clicking
fallingEgg.down = function () {
eggClickCount++;
if (eggClickCount === 1) {
// First crack
var crackedEgg1 = LK.getAsset('crackedEgg1', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg1.x = fallingEgg.x;
crackedEgg1.y = fallingEgg.y;
game.addChild(crackedEgg1);
fallingEgg.destroy();
fallingEgg = crackedEgg1;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 2) {
// Second crack
var crackedEgg2 = LK.getAsset('crackedEgg2', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg2.x = fallingEgg.x;
crackedEgg2.y = fallingEgg.y;
game.addChild(crackedEgg2);
fallingEgg.destroy();
fallingEgg = crackedEgg2;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 3) {
// Third crack - almost fully cracked
var crackedEgg3 = LK.getAsset('crackedEgg3', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg3.x = fallingEgg.x;
crackedEgg3.y = fallingEgg.y;
game.addChild(crackedEgg3);
fallingEgg.destroy();
fallingEgg = crackedEgg3;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 4) {
// Hatch the galaxy egg with special probabilities
var availableGalaxyAnimals = [];
var galaxyAnimalTypes = ['andromedaGalaxy', 'normalGalaxy', 'milkyWayGalaxy'];
for (var typeIndex = 0; typeIndex < galaxyAnimalTypes.length; typeIndex++) {
var animalType = galaxyAnimalTypes[typeIndex];
var countInInventory = 0;
for (var invIndex = 0; invIndex < inventory.length; invIndex++) {
if (inventory[invIndex] === animalType) {
countInInventory++;
}
}
if (countInInventory < 3) {
availableGalaxyAnimals.push(animalType);
}
}
var animal;
if (availableGalaxyAnimals.length > 0) {
// Special probability distribution for galaxy eggs
var random = Math.random();
var selectedAnimal;
if (random < 0.009) {
selectedAnimal = 'milkyWayGalaxy'; // 0.9% chance
} else if (random < 0.199) {
selectedAnimal = 'normalGalaxy'; // 19% chance
} else {
selectedAnimal = 'andromedaGalaxy'; // 80.1% chance
}
// Check if selected animal is available
if (availableGalaxyAnimals.indexOf(selectedAnimal) !== -1) {
animal = selectedAnimal;
} else {
// If selected animal is not available, choose randomly from available
var randomIndex = Math.floor(Math.random() * availableGalaxyAnimals.length);
animal = availableGalaxyAnimals[randomIndex];
}
inventory.push(animal);
storage.inventory = inventory;
} else {
// All galaxy animal types have 3 in inventory
animal = null;
var allGalaxyPetsText = new Text2('All galaxy pets maxed out!', {
size: 60,
fill: 0xff0000
});
allGalaxyPetsText.anchor.set(0.5, 0.5);
allGalaxyPetsText.x = 2048 / 2;
allGalaxyPetsText.y = 1500;
game.addChild(allGalaxyPetsText);
LK.setTimeout(function () {
allGalaxyPetsText.destroy();
}, 2000);
}
// Only show hatched animal if we got a new pet
if (animal) {
var animalSprite = LK.getAsset(animal, {
anchorX: 0.5,
anchorY: 0.5
});
animalSprite.x = fallingEgg.x;
animalSprite.y = fallingEgg.y;
game.addChild(animalSprite);
// Remove animal after showing
LK.setTimeout(function () {
animalSprite.destroy();
}, 2000);
}
// Remove egg
fallingEgg.destroy();
fallingEgg = null;
}
};
}
};
// Handle golden galaxy egg purchase
goldenGalaxyEggItem.down = function () {
if (LK.getScore() >= 1000000000) {
LK.setScore(LK.getScore() - 1000000000);
scoreTxt.setText(LK.getScore().toString());
// Close shop
shopOverlay.destroy();
shopOverlay = null;
isShopOpen = false;
// Create falling golden galaxy egg
fallingEgg = LK.getAsset('goldenGalaxyEgg', {
anchorX: 0.5,
anchorY: 0.5
});
fallingEgg.x = 2048 / 2;
fallingEgg.y = -200;
eggClickCount = 0;
game.addChild(fallingEgg);
// Animate egg falling
tween(fallingEgg, {
y: 2732 / 2
}, {
duration: 1000
});
// Handle golden galaxy egg clicking
fallingEgg.down = function () {
eggClickCount++;
if (eggClickCount === 1) {
// First crack
var crackedEgg1 = LK.getAsset('crackedEgg1', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg1.x = fallingEgg.x;
crackedEgg1.y = fallingEgg.y;
game.addChild(crackedEgg1);
fallingEgg.destroy();
fallingEgg = crackedEgg1;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 2) {
// Second crack
var crackedEgg2 = LK.getAsset('crackedEgg2', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg2.x = fallingEgg.x;
crackedEgg2.y = fallingEgg.y;
game.addChild(crackedEgg2);
fallingEgg.destroy();
fallingEgg = crackedEgg2;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 3) {
// Third crack - almost fully cracked
var crackedEgg3 = LK.getAsset('crackedEgg3', {
anchorX: 0.5,
anchorY: 0.5
});
crackedEgg3.x = fallingEgg.x;
crackedEgg3.y = fallingEgg.y;
game.addChild(crackedEgg3);
fallingEgg.destroy();
fallingEgg = crackedEgg3;
fallingEgg.down = arguments.callee;
} else if (eggClickCount === 4) {
// Hatch the golden galaxy egg with special probabilities
var availableGoldenGalaxyAnimals = [];
var goldenGalaxyAnimalTypes = ['goldenAndromedaGalaxy', 'goldenNormalGalaxy', 'goldenMilkyWayGalaxy'];
for (var typeIndex = 0; typeIndex < goldenGalaxyAnimalTypes.length; typeIndex++) {
var animalType = goldenGalaxyAnimalTypes[typeIndex];
var countInInventory = 0;
for (var invIndex = 0; invIndex < inventory.length; invIndex++) {
if (inventory[invIndex] === animalType) {
countInInventory++;
}
}
if (countInInventory < 3) {
availableGoldenGalaxyAnimals.push(animalType);
}
}
var animal;
if (availableGoldenGalaxyAnimals.length > 0) {
// Special probability distribution for golden galaxy eggs (same as galaxy)
var random = Math.random();
var selectedAnimal;
if (random < 0.009) {
selectedAnimal = 'goldenMilkyWayGalaxy'; // 0.9% chance
} else if (random < 0.199) {
selectedAnimal = 'goldenNormalGalaxy'; // 19% chance
} else {
selectedAnimal = 'goldenAndromedaGalaxy'; // 80.1% chance
}
// Check if selected animal is available
if (availableGoldenGalaxyAnimals.indexOf(selectedAnimal) !== -1) {
animal = selectedAnimal;
} else {
// If selected animal is not available, choose randomly from available
var randomIndex = Math.floor(Math.random() * availableGoldenGalaxyAnimals.length);
animal = availableGoldenGalaxyAnimals[randomIndex];
}
inventory.push(animal);
storage.inventory = inventory;
} else {
// All golden galaxy animal types have 3 in inventory
animal = null;
var allGoldenGalaxyPetsText = new Text2('All golden galaxy pets maxed out!', {
size: 60,
fill: 0xff0000
});
allGoldenGalaxyPetsText.anchor.set(0.5, 0.5);
allGoldenGalaxyPetsText.x = 2048 / 2;
allGoldenGalaxyPetsText.y = 1500;
game.addChild(allGoldenGalaxyPetsText);
LK.setTimeout(function () {
allGoldenGalaxyPetsText.destroy();
}, 2000);
}
// Only show hatched animal if we got a new pet
if (animal) {
var animalSprite = LK.getAsset(animal, {
anchorX: 0.5,
anchorY: 0.5
});
animalSprite.x = fallingEgg.x;
animalSprite.y = fallingEgg.y;
game.addChild(animalSprite);
// Remove animal after showing
LK.setTimeout(function () {
animalSprite.destroy();
}, 2000);
}
// Remove egg
fallingEgg.destroy();
fallingEgg = null;
}
};
}
};
// Handle inventory button
inventoryBtn.down = function () {
if (!isInventoryOpen) {
// Close shop first
if (shopOverlay) {
shopOverlay.destroy();
}
shopOverlay = null;
isShopOpen = false;
// Open inventory
isInventoryOpen = true;
inventoryOverlay = new Container();
var invBackground = LK.getAsset('shopBg', {
width: 2048,
height: 2732,
color: 0x000000,
shape: 'box'
});
inventoryOverlay.addChild(invBackground);
game.addChild(inventoryOverlay);
// Display inventory items by unique pet types
var yPos = 300;
var uniqueTypes = [];
var animalTypes = ['dog', 'cat', 'snake', 'goldenDog', 'goldenCat', 'goldenSnake', 'dinosaur', 'bear', 'bee', 'goldenDinosaur', 'goldenBear', 'goldenBee', 'trex', 'velector', 'titanaBull', 'goldenTrex', 'goldenVelector', 'goldenTitanaBull', 'ironMan', 'captainAmerica', 'spiderman', 'goldenIronMan', 'goldenCaptainAmerica', 'goldenSpiderman', 'king', 'knight', 'human', 'goldenKing', 'goldenKnight', 'goldenHuman', 'earth', 'moon', 'meteor', 'sun', 'jupiter', 'neptune', 'goldenEarth', 'goldenMoon', 'goldenMeteor', 'goldenSun', 'goldenJupiter', 'goldenNeptune', 'andromedaGalaxy', 'normalGalaxy', 'milkyWayGalaxy', 'goldenAndromedaGalaxy', 'goldenNormalGalaxy', 'goldenMilkyWayGalaxy'];
for (var typeIndex = 0; typeIndex < animalTypes.length; typeIndex++) {
var animalType = animalTypes[typeIndex];
var countInInventory = 0;
for (var invIndex = 0; invIndex < inventory.length; invIndex++) {
if (inventory[invIndex] === animalType) {
countInInventory++;
}
}
if (countInInventory > 0) {
uniqueTypes.push({
type: animalType,
count: countInInventory
});
}
}
for (var i = 0; i < uniqueTypes.length; i++) {
var petData = uniqueTypes[i];
var animalItem = LK.getAsset(petData.type, {
anchorX: 0.5,
anchorY: 0.5
});
animalItem.x = 300;
animalItem.y = yPos;
animalItem.animalType = petData.type;
animalItem.inventoryIndex = i;
inventoryOverlay.addChild(animalItem);
// Handle pet deletion when in delete mode
animalItem.down = function () {
if (deleteMode && selectedDeleteAnimalType === this.animalType) {
// Delete the pet
// Remove one instance of this pet from inventory
for (var removeIndex = 0; removeIndex < inventory.length; removeIndex++) {
if (inventory[removeIndex] === this.animalType) {
inventory.splice(removeIndex, 1);
break;
}
}
storage.inventory = inventory;
// Also remove from equipped animals if it was equipped
for (var removeIndex = equippedAnimals.length - 1; removeIndex >= 0; removeIndex--) {
if (equippedAnimals[removeIndex] === this.animalType) {
equippedAnimals.splice(removeIndex, 1);
break;
}
}
// Recalculate pet bonus after removing
var petBonus = 0;
// Count each animal type
var dogCount = 0;
var catCount = 0;
var snakeCount = 0;
for (var j = 0; j < equippedAnimals.length; j++) {
if (equippedAnimals[j] === 'dog') {
dogCount++;
} else if (equippedAnimals[j] === 'cat') {
catCount++;
} else if (equippedAnimals[j] === 'snake') {
snakeCount++;
}
}
// Each dog gives +1 bonus per tap
petBonus += dogCount;
// Cats: 1 cat = +2, 2 cats = +4, 3 cats = +6 (total bonus)
if (catCount === 1) {
petBonus += 2;
} else if (catCount === 2) {
petBonus += 4;
} else if (catCount === 3) {
petBonus += 6;
}
// Snakes: 1 snake = +5, 2 snakes = +10, 3 snakes = +15 (total bonus)
if (snakeCount === 1) {
petBonus += 5;
} else if (snakeCount === 2) {
petBonus += 10;
} else if (snakeCount === 3) {
petBonus += 15;
}
// Store as multiplier format (base 1 + bonus)
currentMultiplier = 1 + petBonus;
storage.equippedAnimals = equippedAnimals;
storage.currentMultiplier = currentMultiplier;
// Exit delete mode
deleteMode = false;
selectedDeleteAnimalType = null;
// Close and reopen inventory to refresh display
inventoryOverlay.destroy();
inventoryOverlay = null;
isInventoryOpen = false;
// Reopen inventory to show updated counts
inventoryBtn.down();
}
};
// Count how many of this type are equipped
var equippedCount = 0;
for (var k = 0; k < equippedAnimals.length; k++) {
if (equippedAnimals[k] === petData.type) {
equippedCount++;
}
}
// Add equip button
var equipBtn = new Text2('Equip', {
size: 50,
fill: 0xFFFFFF
});
equipBtn.anchor.set(0.5, 0.5);
equipBtn.x = 550;
equipBtn.y = yPos;
equipBtn.animalType = inventory[i];
equipBtn.inventoryIndex = i;
inventoryOverlay.addChild(equipBtn);
// Add unequip button
var unequipBtn = new Text2('Unequip', {
size: 50,
fill: 0xFF6B6B
});
unequipBtn.anchor.set(0.5, 0.5);
unequipBtn.x = 700;
unequipBtn.y = yPos;
unequipBtn.animalType = inventory[i];
unequipBtn.inventoryIndex = i;
inventoryOverlay.addChild(unequipBtn);
// Add delete button
var deleteBtn = new Text2('Delete', {
size: 50,
fill: 0xFF0000
});
deleteBtn.anchor.set(0.5, 0.5);
deleteBtn.x = 850;
deleteBtn.y = yPos;
deleteBtn.animalType = inventory[i];
deleteBtn.inventoryIndex = i;
inventoryOverlay.addChild(deleteBtn);
// Add count display
var countText = new Text2('Owned: ' + petData.count + ' | Equipped: ' + equippedCount, {
size: 40,
fill: 0xFFFFFF
});
countText.anchor.set(0.5, 0.5);
countText.x = 1000;
countText.y = yPos;
inventoryOverlay.addChild(countText);
// Handle delete functionality
deleteBtn.down = function () {
if (!deleteMode) {
// First press - enter delete mode
deleteMode = true;
selectedDeleteAnimalType = this.animalType;
// Show message to click on pet
var deleteInstructionText = new Text2('Click on the pet to delete it', {
size: 40,
fill: 0xff0000
});
deleteInstructionText.anchor.set(0.5, 0.5);
deleteInstructionText.x = 2048 / 2;
deleteInstructionText.y = 2500;
inventoryOverlay.addChild(deleteInstructionText);
// Auto-hide instruction after 3 seconds
LK.setTimeout(function () {
if (deleteInstructionText && deleteInstructionText.parent) {
deleteInstructionText.destroy();
}
}, 3000);
} else if (deleteMode && selectedDeleteAnimalType === this.animalType) {
// Second press on same delete button - cancel delete mode
deleteMode = false;
selectedDeleteAnimalType = null;
}
};
// Handle unequip functionality
unequipBtn.down = function () {
// Find and remove one instance of this pet type from equipped animals
for (var removeIndex = 0; removeIndex < equippedAnimals.length; removeIndex++) {
if (equippedAnimals[removeIndex] === this.animalType) {
equippedAnimals.splice(removeIndex, 1);
break;
}
}
// Recalculate pet bonus after unequipping
var petBonus = 0;
// Count each animal type
var dogCount = 0;
var catCount = 0;
var snakeCount = 0;
for (var j = 0; j < equippedAnimals.length; j++) {
if (equippedAnimals[j] === 'dog') {
dogCount++;
} else if (equippedAnimals[j] === 'cat') {
catCount++;
} else if (equippedAnimals[j] === 'snake') {
snakeCount++;
}
}
// Each dog gives +1 bonus per tap
petBonus += dogCount;
// Cats: 1 cat = +2, 2 cats = +4, 3 cats = +6 (total bonus)
if (catCount === 1) {
petBonus += 2;
} else if (catCount === 2) {
petBonus += 4;
} else if (catCount === 3) {
petBonus += 6;
}
// Snakes: 1 snake = +5, 2 snakes = +10, 3 snakes = +15 (total bonus)
if (snakeCount === 1) {
petBonus += 5;
} else if (snakeCount === 2) {
petBonus += 10;
} else if (snakeCount === 3) {
petBonus += 15;
}
// Store as multiplier format (base 1 + bonus)
currentMultiplier = 1 + petBonus;
storage.equippedAnimals = equippedAnimals;
storage.currentMultiplier = currentMultiplier;
// Close and reopen inventory to refresh display
inventoryOverlay.destroy();
inventoryOverlay = null;
isInventoryOpen = false;
// Reopen inventory to show updated counts
inventoryBtn.down();
};
equipBtn.down = function () {
// Count how many of this pet type are in inventory
var inventoryCount = 0;
for (var invIndex = 0; invIndex < inventory.length; invIndex++) {
if (inventory[invIndex] === this.animalType) {
inventoryCount++;
}
}
// Count how many of this pet type are already equipped
var equippedCount = 0;
for (var checkIndex = 0; checkIndex < equippedAnimals.length; checkIndex++) {
if (equippedAnimals[checkIndex] === this.animalType) {
equippedCount++;
}
}
// Check if we have this pet available in inventory to equip
if (equippedCount >= inventoryCount) {
var noPetText = new Text2('Need more pets to equip!', {
size: 40,
fill: 0xff0000
});
noPetText.anchor.set(0.5, 0.5);
noPetText.x = this.x;
noPetText.y = this.y - 50;
inventoryOverlay.addChild(noPetText);
LK.setTimeout(function () {
noPetText.destroy();
}, 1500);
return;
}
// Check if we can equip more pets (total limit of 3)
if (equippedAnimals.length < maxEquippedPets) {
// Equip this pet
equippedAnimals.push(this.animalType);
} else {
// Show message that max pets reached
var maxText = new Text2('Max 3 pets total!', {
size: 40,
fill: 0xff0000
});
maxText.anchor.set(0.5, 0.5);
maxText.x = this.x;
maxText.y = this.y - 50;
inventoryOverlay.addChild(maxText);
LK.setTimeout(function () {
maxText.destroy();
}, 1500);
return;
}
// Calculate pet bonus based on equipped animal quantities
var petBonus = 0;
// Count each animal type
var dogCount = 0;
var catCount = 0;
var snakeCount = 0;
for (var j = 0; j < equippedAnimals.length; j++) {
if (equippedAnimals[j] === 'dog') {
dogCount++;
} else if (equippedAnimals[j] === 'cat') {
catCount++;
} else if (equippedAnimals[j] === 'snake') {
snakeCount++;
}
}
// Each dog gives +1 bonus per tap
petBonus += dogCount;
// Cats: 1 cat = +2, 2 cats = +4, 3 cats = +6 (total bonus)
if (catCount === 1) {
petBonus += 2;
} else if (catCount === 2) {
petBonus += 4;
} else if (catCount === 3) {
petBonus += 6;
}
// Snakes: 1 snake = +5, 2 snakes = +10, 3 snakes = +15 (total bonus)
if (snakeCount === 1) {
petBonus += 5;
} else if (snakeCount === 2) {
petBonus += 10;
} else if (snakeCount === 3) {
petBonus += 15;
}
// Store as multiplier format (base 1 + bonus)
currentMultiplier = 1 + petBonus;
storage.equippedAnimals = equippedAnimals;
storage.currentMultiplier = currentMultiplier;
// Close and reopen inventory to refresh display
inventoryOverlay.destroy();
inventoryOverlay = null;
isInventoryOpen = false;
// Reopen inventory to show updated counts
inventoryBtn.down();
};
yPos += 200;
}
// Add close inventory button
var closeInvBtn = new Text2('Close', {
size: 80,
fill: 0xFFFFFF
});
closeInvBtn.anchor.set(0.5, 0.5);
closeInvBtn.x = 2048 / 2;
closeInvBtn.y = 2400;
inventoryOverlay.addChild(closeInvBtn);
closeInvBtn.down = function () {
// Reset delete mode when closing inventory
deleteMode = false;
selectedDeleteAnimalType = null;
inventoryOverlay.destroy();
inventoryOverlay = null;
isInventoryOpen = false;
};
}
};
// Add shop overlay to main game
game.addChild(shopOverlay);
isShopOpen = true;
} else {
// Close shop - remove overlay
if (shopOverlay) {
shopOverlay.destroy();
shopOverlay = null;
}
isShopOpen = false;
}
};
// Handle menu button tap
menuBtn.down = function () {
if (!isMenuOpen) {
// Function to clean up environment elements
var cleanupEnvironment = function cleanupEnvironment() {
for (var i = 0; i < environmentElements.length; i++) {
if (environmentElements[i] && environmentElements[i].parent) {
environmentElements[i].destroy();
}
}
environmentElements = [];
};
// Open menu
isMenuOpen = true;
menuOverlay = new Container();
// Create menu background
var menuBg = LK.getAsset('shopBg', {
width: 2048,
height: 2732,
color: 0x000000,
shape: 'box'
});
menuOverlay.addChild(menuBg);
// Graphics title
var graphicsTitle = new Text2('Graphics Settings', {
size: 100,
fill: 0xFFFFFF
});
graphicsTitle.anchor.set(0.5, 0.5);
graphicsTitle.x = 2048 / 2;
graphicsTitle.y = 400;
menuOverlay.addChild(graphicsTitle);
// FPS options
var fpsOptions = [30, 60, 90, 120];
var fpsLabels = ['30 FPS - Basic', '60 FPS - Normal', '90 FPS - High Quality', '120 FPS - Ultra'];
var startY = 600;
for (var i = 0; i < fpsOptions.length; i++) {
var fps = fpsOptions[i];
var label = fpsLabels[i];
var isSelected = fps === graphicsMode;
var fpsBtn = new Text2(label, {
size: 70,
fill: isSelected ? 0x00ff00 : 0xffffff
});
fpsBtn.anchor.set(0.5, 0.5);
fpsBtn.x = 2048 / 2;
fpsBtn.y = startY + i * 150;
fpsBtn.fpsValue = fps;
menuOverlay.addChild(fpsBtn);
fpsBtn.down = function () {
graphicsMode = this.fpsValue;
if (this.fpsValue === 120) {
ultraRealisticMode = true;
} else {
ultraRealisticMode = false;
}
// Clean up existing environment and recreate
cleanupEnvironment();
createUltraRealisticEnvironment();
// Close and reopen menu to refresh
menuOverlay.destroy();
isMenuOpen = false;
menuBtn.down();
};
}
// Close button
var closeBtn = new Text2('Close', {
size: 80,
fill: 0xFFFFFF
});
closeBtn.anchor.set(0.5, 0.5);
closeBtn.x = 2048 / 2;
closeBtn.y = 1400;
menuOverlay.addChild(closeBtn);
closeBtn.down = function () {
menuOverlay.destroy();
menuOverlay = null;
isMenuOpen = false;
};
game.addChild(menuOverlay);
} else {
// Close menu
if (menuOverlay) {
menuOverlay.destroy();
menuOverlay = null;
}
isMenuOpen = 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());
// Update rain system for 120 fps mode
if (ultraRealisticMode && graphicsMode === 120) {
var currentTime = Date.now();
// Update clock
updateClock();
// Check if it's time to start raining
if (!isRaining && currentTime >= nextRainTime) {
isRaining = true;
rainTimer = currentTime + rainDuration;
}
// Check if rain should stop
if (isRaining && currentTime >= rainTimer) {
isRaining = false;
nextRainTime = currentTime + rainInterval;
}
// Create rain drops when raining
if (isRaining && Math.random() < 0.3) {
createRainDrop();
}
// Update rain drops
for (var i = rainDrops.length - 1; i >= 0; i--) {
var drop = rainDrops[i];
drop.lastY = drop.y;
drop.y += drop.speed;
// Check if drop hits ground
if (drop.lastY <= 2732 && drop.y > 2732) {
// Create splash effect
createRainSplash(drop.x, 2732);
// Remove drop
drop.destroy();
rainDrops.splice(i, 1);
} else if (drop.y > 2800) {
// Remove drops that went too far off screen
drop.destroy();
rainDrops.splice(i, 1);
}
}
}
}; ===================================================================
--- original.js
+++ change.js
@@ -940,9 +940,9 @@
onFinish: function onFinish() {
plusOneScreenText.destroy();
}
});
- // Create enhanced score text with glow above score
+ // Create enhanced score text with glow above score that shows the full score gained
var plusOneText = new Text2('+' + totalScore, {
size: 120,
fill: 0xFFD700
});