User prompt
Trade sekmesinde oyuncular aktif olan her hangi bir oyuncuyla dinozor takas etsin takas başlamadan oyuncunun yanındaki trade isteğine basmalidir en fazla 4 dinzoru kiyuka bilir ve bir günde 5 kere takas yapılır takas başladığında aynı blox fruits trade'i gibi olsun ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Oyuna daily gify ekleyelim her hafta tekrarlansın 1. Gün 1000 2. Gün 2000 3. Gün 4000 4. Gün 8000 5. Gün 10000 6. Gün 12000 ve 7. Gün 16000 para verilsin gün gelmeden ödüller alınamaz ve menüde en alt yere TRADE ve GİFTS sekmesi ekle ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Tamam nickname kısmı böyle olmalı ama harf ekleye bilelim
User prompt
İnsanlar nickname yazabilsin ama ekstradan harf görülmesin sağ tarafta
User prompt
Nickname yerini düzelt sadece ekstra har görünmesin dedim harf girilmesin demedim çabuk düzelt orayı
User prompt
Enter nickname kısmında nickname yazınca en sağ tarafta ekstra harf görülmesin sadece girilen nickname görünsün
User prompt
Paramız oyuna gir çık yapınca sıfırlanmasın paramız aynı hesapta harcanması sürece kalıcı olarak kalsın aynı şekilde game passler fosiller ve dinozorlarda ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
+1 sellect game passini yukarı çıkar 2x luck altında olsun hizalı ve simetrik şekilde
User prompt
Updrage sistemindeki butonların üstündeki yazıları okunur hala getir
User prompt
Daha belirgin uodrage özellikleri butondaki yazılar daha anlaşılır özellikleri olsun ve max 3 seviyeye çıkaralım yabi 5 ten 3e düşür ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Updrage distemi daha büyük ve anlaşılır olsun + dinizorların kendi görüntüleri olsun gözleri kırmızı olsun ten renkleri değişsin
User prompt
Her dinozorun 3 tane updrage olsun ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Updrage yazısı biraz daha altta olsun
User prompt
Şuana kadar tüm alınan gamepasslari de sıfırla (XRAY 2X MONEY +1 SELLECT) ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Oyun sekmesine geldiğimizde menüye geri dön butonuna basınca menüye geri dönüyoruz menüye geri döndükten sonra tekrar start dersek kaldığımız yerden devam edelim baştan başlayalım ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Dinozorlar güçlendirilince ozellikleirnin etkikeri ve kullanım sayıları artsin ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Dinizorların updrage mantığı öyle değil tek sefer için değil 5 e böl hepsini 5)5 olunca okadar para gitmiş olsum ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Seçtiğimiz dinizor/dinozorlar bag sekmesinde en altta ortada görünsün ve updrage yapmak seçenekleri çıksın altında max 5 updrage ve nadirlige göre saha fazla para vermeliyiz efsanevi önce trexin enderliği efsanevi değil kromatik olsun ve kromatikler için total 30000 coin efsaneviler için 20000 destansılar için 12500 nadirler 7500 sıradanlar ise 5000 olsun totalve kromatik olanların isimleri rengarenk olsun ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Bir dinozor seçiliyken başka dinozora basarsak otomatik olarak o seçilsin ve secilen dinozor en altta görünsün ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Şuan hiç dinzoor secemiyoruz bak duzelt artık şunu sadece oass satın alanlar 1den fazla seçebilir pass almayanlar yalnızca 1 adet seçebilir ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
İnsanlar 1den fazla dinozor seçemez bende dahil sadece pass alanlar ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
İnsanlar 1 den fazla dinozor seçemez sadece pass satın alabilenler seçebilir ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Updrages diye bişey yok kaldır onu
User prompt
Base sınırı 1 olacaktır 5 değil ve herkes için geçerli pass ise en fazla 4 olabilir ve onun için 4 kez satın alınmalıdır ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
+1 vomit +1 Select olarak değişsin
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ var Fossil = Container.expand(function (fossilType) { var self = Container.call(this); var fossilGraphics = self.attachAsset(fossilType, { anchorX: 0.5, anchorY: 0.5 }); self.fossilType = fossilType; self.isCollected = false; self.points = fossilType === 'rareFossil' ? 500 : 100; self.down = function (x, y, obj) { if (!self.isCollected) { self.collectFossil(); } }; self.collectFossil = function () { self.isCollected = true; LK.getSound('fossilFound').play(); // Apply dinosaur abilities if (selectedDinosaur === 'PYTHEREDON') { // PYTHEREDON only collects 1 fossil per level regardless of rarity var fossilsCollectedByPytheredon = storage.fossilsCollectedByPytheredon || 0; if (fossilsCollectedByPytheredon >= 1) { // Skip collection - PYTHEREDON already collected its one fossil self.animateCollection(); return; } storage.fossilsCollectedByPytheredon = fossilsCollectedByPytheredon + 1; } else if (selectedDinosaur === 'Mutated DIMETRODON') { // Mutated DIMETRODON collects 3 most valuable fossils per level self.handleMutatedDimetrodonCollection(); return; } else if (selectedDinosaur === 'DIMETRODON') { // DIMETRODON collects 2 fossils regardless of rarity self.handleDimetrodonCollection(); return; } // Add fossil to inventory playerInventory.push(self.fossilType); storage.playerInventory = playerInventory; // Award points based on extraction speed var speedBonus = Math.max(0, 100 - Math.floor(levelTimer / 100)); var totalPoints = self.points + speedBonus; // Apply 2X MONEY effect if active if (doubleMoneyLevelsLeft > 0) { totalPoints *= 2; } LK.setScore(LK.getScore() + totalPoints); scoreText.setText('Score: ' + LK.getScore()); self.animateCollection(); }; self.handleDimetrodonCollection = function () { // DIMETRODON collects 2 fossils regardless of rarity // Add current fossil first playerInventory.push(self.fossilType); // Add one more fossil if available in inventory if (playerInventory.length > 1) { playerInventory.push(playerInventory[0]); // Add any fossil from inventory } storage.playerInventory = playerInventory; // Award bonus points for rare collection var totalPoints = self.points * 2; // Double points for DIMETRODON if (doubleMoneyLevelsLeft > 0) { totalPoints *= 2; } LK.setScore(LK.getScore() + totalPoints); scoreText.setText('Score: ' + LK.getScore()); self.animateCollection(); }; self.handleMutatedDimetrodonCollection = function () { // Mutated DIMETRODON collects 3 most valuable fossils per level // Find the 3 most valuable fossils from current level var availableFossils = []; for (var i = 0; i < currentLevel.fossils.length; i++) { if (!currentLevel.fossils[i].isCollected) { availableFossils.push(currentLevel.fossils[i]); } } // Sort by fossil value (descending) availableFossils.sort(function (a, b) { return b.points - a.points; }); // Take up to 3 most valuable var fossilsToCollect = Math.min(3, availableFossils.length); var totalPoints = 0; for (var j = 0; j < fossilsToCollect; j++) { playerInventory.push(availableFossils[j].fossilType); totalPoints += availableFossils[j].points; // Mark as collected availableFossils[j].isCollected = true; availableFossils[j].animateCollection(); } storage.playerInventory = playerInventory; // Apply 2X MONEY effect if active if (doubleMoneyLevelsLeft > 0) { totalPoints *= 2; } LK.setScore(LK.getScore() + totalPoints); scoreText.setText('Score: ' + LK.getScore()); self.animateCollection(); }; self.animateCollection = function () { // Animate collection tween(self, { scaleX: 1.5, scaleY: 1.5, alpha: 0 }, { duration: 500, easing: tween.easeOut, onFinish: function onFinish() { currentLevel.fossilsCollected++; currentLevel.checkLevelComplete(); } }); }; return self; }); var Level = Container.expand(function (levelNumber) { var self = Container.call(this); self.levelNumber = levelNumber; self.blocks = []; self.fossils = []; self.fossilsCollected = 0; self.totalFossils = 0; self.blocksCollected = 0; self.totalBlocks = 0; self.createLevel = function () { // Create excavation site background var site = self.attachAsset('excavationSite', { anchorX: 0.5, anchorY: 0.5 }); site.x = 1024; site.y = 1000; // Determine fossils for this level (3-6 fossils) var fossilCount = 3 + Math.floor(Math.random() * 4); var fossilTypes = ['fossil1', 'fossil2', 'fossil3']; // Add rare fossil chance (higher in later levels) if (Math.random() < levelNumber * 0.05) { fossilTypes.push('rareFossil'); } self.totalFossils = fossilCount; // Create limestone blocks grid var blocksPerRow = 8; var rows = 6; var startX = 534; var startY = 600; var spacing = 140; var fossilPositions = []; for (var i = 0; i < fossilCount; i++) { var randomPos = Math.floor(Math.random() * (blocksPerRow * rows)); while (fossilPositions.indexOf(randomPos) !== -1) { randomPos = Math.floor(Math.random() * (blocksPerRow * rows)); } fossilPositions.push(randomPos); } var blockIndex = 0; for (var row = 0; row < rows; row++) { for (var col = 0; col < blocksPerRow; col++) { var block = new LimestoneBlock(); block.x = startX + col * spacing; block.y = startY + row * spacing; // Check if this block contains a fossil if (fossilPositions.indexOf(blockIndex) !== -1) { block.hasFossil = true; var fossilTypeIndex = Math.floor(Math.random() * fossilTypes.length); block.fossilType = fossilTypes[fossilTypeIndex]; } self.blocks.push(block); self.addChild(block); blockIndex++; } } self.totalBlocks = self.blocks.length; }; self.revealFossil = function (fossilType, x, y) { var fossil = new Fossil(fossilType); fossil.x = x; fossil.y = y; // Animate fossil appearance fossil.alpha = 0; fossil.scaleX = 0; fossil.scaleY = 0; self.fossils.push(fossil); self.addChild(fossil); tween(fossil, { alpha: 1, scaleX: 1, scaleY: 1 }, { duration: 400, easing: tween.easeOut }); }; self.checkBlockCollection = function () { self.blocksCollected++; if (self.blocksCollected >= self.totalBlocks) { // All blocks collected, show any remaining fossils for (var i = 0; i < self.blocks.length; i++) { var block = self.blocks[i]; if (block.hasFossil && !block.isCollected) { self.revealFossil(block.fossilType, block.x, block.y); } } } }; self.checkLevelComplete = function () { if (self.fossilsCollected >= self.totalFossils) { LK.getSound('levelComplete').play(); // Level completion bonus var timeBonus = Math.max(0, 1000 - Math.floor(levelTimer / 10)); LK.setScore(LK.getScore() + timeBonus); scoreText.setText('Score: ' + LK.getScore()); // Decrease power-up counters if (xrayLevelsLeft > 0) { xrayLevelsLeft--; storage.xrayLevelsLeft = xrayLevelsLeft; } if (doubleMoneyLevelsLeft > 0) { doubleMoneyLevelsLeft--; storage.doubleMoneyLevelsLeft = doubleMoneyLevelsLeft; } // Progress to next level after delay LK.setTimeout(function () { if (currentLevelNumber < 20) { startLevel(currentLevelNumber + 1); } else { // Game complete LK.showYouWin(); } }, 2000); } }; return self; }); var LimestoneBlock = Container.expand(function () { var self = Container.call(this); var blockGraphics = self.attachAsset('limestone', { anchorX: 0.5, anchorY: 0.5 }); self.hasFossil = false; self.fossilType = null; self.isCollected = false; self.down = function (x, y, obj) { if (!self.isCollected) { self.collectBlock(); } }; self.collectBlock = function () { // Check if dinosaur ability affects digging speed if (selectedDinosaur === 'PARASOUROLUPHUS') { // PARASOUROLUPHUS is very slow - add delay LK.setTimeout(function () { self.performCollection(); }, 1000); // 1 second delay } else if (selectedDinosaur === 'BARYONYX') { // BARYONYX is 0.2x faster (20% speed increase) LK.setTimeout(function () { self.performCollection(); }, 240); // 0.8x delay = faster mining } else if (selectedDinosaur === 'YUTY') { // YUTY is 0.7x faster (70% speed increase) LK.setTimeout(function () { self.performCollection(); }, 90); // 0.3x delay = much faster mining } else if (selectedDinosaur === 'ALLO') { // ALLO is 0.4x faster (40% speed increase) LK.setTimeout(function () { self.performCollection(); }, 180); // 0.6x delay = faster mining } else if (selectedDinosaur === 'TREX') { // TREX breaks 4 surrounding blocks, 3 uses per level var usesLeft = storage.trexUsesLeft || 0; if (usesLeft > 0) { self.performTrexCollection(); storage.trexUsesLeft = usesLeft - 1; } else { self.performCollection(); } } else if (selectedDinosaur === 'SPINO') { // SPINO tail strike breaks 3 blocks in line, 1 use per level var usesLeft = storage.spinoUsesLeft || 0; if (usesLeft > 0) { self.performSpinoCollection(); storage.spinoUsesLeft = usesLeft - 1; } else { self.performCollection(); } } else if (selectedDinosaur === 'GIGA') { // GIGA 2x mining speed LK.setTimeout(function () { self.performCollection(); }, 150); // 0.5x delay = 2x faster mining } else if (selectedDinosaur === 'Mutated BARYONYX') { // Mutated BARYONYX 0.9x faster (90% speed increase) LK.setTimeout(function () { self.performCollection(); }, 30); // 0.1x delay = much faster mining } else if (selectedDinosaur === 'Mutated PARASAUROLUPHUS') { // Mutated PARASAUROLUPHUS is faster than regular PARASAUROLUPHUS - 2 second mining LK.setTimeout(function () { self.performCollection(); }, 2000); // 2 second delay - faster than regular PARASAUROLUPHUS } else { self.performCollection(); } }; self.performCollection = function () { self.isCollected = true; LK.getSound('dig').play(); // Animate collection tween(self, { scaleX: 0, scaleY: 0, alpha: 0 }, { duration: 300, easing: tween.easeIn, onFinish: function onFinish() { if (self.hasFossil) { currentLevel.revealFossil(self.fossilType, self.x, self.y); } currentLevel.checkBlockCollection(); } }); }; self.performTrexCollection = function () { // TREX breaks current block plus 4 surrounding blocks var blocksToBreak = [self]; var currentIndex = currentLevel.blocks.indexOf(self); if (currentIndex !== -1) { var blocksPerRow = 8; var row = Math.floor(currentIndex / blocksPerRow); var col = currentIndex % blocksPerRow; // Add surrounding blocks (up, down, left, right) var surroundingPositions = [{ row: row - 1, col: col }, // up { row: row + 1, col: col }, // down { row: row, col: col - 1 }, // left { row: row, col: col + 1 } // right ]; for (var i = 0; i < surroundingPositions.length; i++) { var pos = surroundingPositions[i]; if (pos.row >= 0 && pos.row < 6 && pos.col >= 0 && pos.col < blocksPerRow) { var blockIndex = pos.row * blocksPerRow + pos.col; if (blockIndex < currentLevel.blocks.length) { var block = currentLevel.blocks[blockIndex]; if (!block.isCollected) { blocksToBreak.push(block); } } } } } // Break all blocks for (var j = 0; j < blocksToBreak.length; j++) { blocksToBreak[j].performCollection(); } }; self.performSpinoCollection = function () { // SPINO tail strike breaks 3 blocks in a horizontal line var blocksToBreak = [self]; var currentIndex = currentLevel.blocks.indexOf(self); if (currentIndex !== -1) { var blocksPerRow = 8; var row = Math.floor(currentIndex / blocksPerRow); var col = currentIndex % blocksPerRow; // Add 2 blocks to the right for (var i = 1; i <= 2; i++) { if (col + i < blocksPerRow) { var blockIndex = row * blocksPerRow + (col + i); if (blockIndex < currentLevel.blocks.length) { var block = currentLevel.blocks[blockIndex]; if (!block.isCollected) { blocksToBreak.push(block); } } } } } // Break all blocks for (var j = 0; j < blocksToBreak.length; j++) { blocksToBreak[j].performCollection(); } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x2F4F4F }); /**** * Game Code ****/ var gameState = 'nickname'; // 'nickname', 'playing' var playerNickname = storage.playerNickname || ''; var alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; var currentLetterIndex = 0; var currentLevelNumber = 1; var currentLevel = null; var levelTimer = 0; var leaderboardTexts = []; // Player data storage - Reset all coins to 0 var playerCoins = 0; storage.playerCoins = 0; var playerInventory = storage.playerInventory || []; var dinosaurCollection = storage.dinosaurCollection || []; var selectedDinosaur = storage.selectedDinosaur || null; var xrayLevelsLeft = storage.xrayLevelsLeft || 0; var doubleMoneyLevelsLeft = storage.doubleMoneyLevelsLeft || 0; var doubleValueActive = storage.doubleValueActive || false; var doubleSpawnChanceActive = storage.doubleSpawnChanceActive || false; var storageUpgradesBought = storage.storageUpgradesBought || 0; var fossilRarities = { 'fossil1': 'common', 'fossil2': 'common', 'fossil3': 'common', 'rareFossil': 'rare' }; var fossilValues = { 'fossil1': 10, 'fossil2': 15, 'fossil3': 20, 'rareFossil': 100 }; var dinosaurRarities = { 'PARASOUROLUPHUS': 'common', 'PYTHEREDON': 'common', 'DIMETRODON': 'common', 'BARYONYX': 'rare', 'ALLO': 'rare', 'YUTY': 'rare', 'TREX': 'legendary', 'SPINO': 'legendary', 'GIGA': 'legendary', 'Mutated BARYONYX': 'legendary', 'Mutated DIMETRODON': 'legendary', 'Mutated PARASAUROLUPHUS': 'legendary' }; // Dinosaur abilities var dinosaurAbilities = { 'PARASOUROLUPHUS': 'slow_dig', // Very slow, breaks 1 block at a time 'PYTHEREDON': 'single_fossil', // Collects only 1 fossil per level regardless of rarity 'DIMETRODON': 'fossil_collector', // Collects 2 fossils regardless of rarity 'BARYONYX': 'fast_dig_1', // 0.2x faster mining (20% speed increase) 'YUTY': 'fast_dig_2', // 0.7x faster mining (70% speed increase) 'ALLO': 'fast_dig_3', // 0.4x faster mining (40% speed increase) 'TREX': 'area_break', // Breaks 4 surrounding blocks, 3 uses per level 'SPINO': 'tail_strike', // Breaks 3 blocks in a line, 1 use per level 'GIGA': 'super_speed', // 2x mining speed increase 'Mutated BARYONYX': 'ultra_speed', // 0.9x faster mining (90% speed increase) 'Mutated DIMETRODON': 'top_collector', // Collects 3 most valuable fossils per level 'Mutated PARASAUROLUPHUS': 'slow_dig' // Same as regular PARASAUROLUPHUS - very slow mining }; // Dinosaur egg contents var commonEggDinosaurs = ['PARASOUROLUPHUS', 'PYTHEREDON', 'DIMETRODON']; var rareEggDinosaurs = [{ name: 'BARYONYX', chance: 0.45 }, { name: 'ALLO', chance: 0.35 }, { name: 'YUTY', chance: 0.20 }]; var legendaryEggDinosaurs = [{ name: 'TREX', chance: 0.03 }, { name: 'SPINO', chance: 0.10 }, { name: 'GIGA', chance: 0.15 }, { name: 'Mutated BARYONYX', chance: 0.25 }, { name: 'Mutated DIMETRODON', chance: 0.17 }, { name: 'Mutated PARASAUROLUPHUS', chance: 0.30 }]; function openEgg(eggType) { var dinosaurName = ''; if (eggType === 'common') { // Equal chance for all common dinosaurs dinosaurName = commonEggDinosaurs[Math.floor(Math.random() * commonEggDinosaurs.length)]; } else if (eggType === 'rare') { // Weighted random selection for rare dinosaurs - apply 2X LUCK if active var randomValue = Math.random(); var cumulativeChance = 0; for (var i = 0; i < rareEggDinosaurs.length; i++) { var currentChance = rareEggDinosaurs[i].chance; // Apply 2X LUCK effect if active if (doubleSpawnChanceActive) { currentChance *= 2; } cumulativeChance += currentChance; if (randomValue <= cumulativeChance) { dinosaurName = rareEggDinosaurs[i].name; break; } } } else if (eggType === 'legendary') { // Weighted random selection for legendary dinosaurs - apply 2X LUCK if active var randomValue = Math.random(); var cumulativeChance = 0; for (var i = 0; i < legendaryEggDinosaurs.length; i++) { var currentChance = legendaryEggDinosaurs[i].chance; // Apply 2X LUCK effect if active if (doubleSpawnChanceActive) { currentChance *= 2; } cumulativeChance += currentChance; if (randomValue <= cumulativeChance) { dinosaurName = legendaryEggDinosaurs[i].name; break; } } } // Reset 2X LUCK effect after use if (doubleSpawnChanceActive) { doubleSpawnChanceActive = false; storage.doubleSpawnChanceActive = doubleSpawnChanceActive; } // Add to dinosaur collection dinosaurCollection.push(dinosaurName); storage.dinosaurCollection = dinosaurCollection; // Show congratulations popup showCongratulationsPopup(dinosaurName); return dinosaurName; } function showCongratulationsPopup(dinosaurName) { gameState = 'congratulations'; // Hide all current UI hideAllStoreUI(); hideAllMenuUI(); hideAllGameUI(); // Create congratulations display var congratsTitle = new Text2('TEBRİKLER!', { size: 100, fill: '#FFD700' }); congratsTitle.anchor.set(0.5, 0.5); congratsTitle.x = 1024; congratsTitle.y = 600; game.addChild(congratsTitle); infoUIElements.push(congratsTitle); var winMessage = new Text2('KAZANDINIZ!', { size: 80, fill: '#FFFFFF' }); winMessage.anchor.set(0.5, 0.5); winMessage.x = 1024; winMessage.y = 800; game.addChild(winMessage); infoUIElements.push(winMessage); var dinosaurMessage = new Text2(dinosaurName, { size: 60, fill: '#32CD32' }); dinosaurMessage.anchor.set(0.5, 0.5); dinosaurMessage.x = 1024; dinosaurMessage.y = 1000; game.addChild(dinosaurMessage); infoUIElements.push(dinosaurMessage); var closeButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); closeButton.x = 1024; closeButton.y = 1300; var closeButtonText = new Text2('TAMAM', { size: 35, fill: '#FFFFFF' }); closeButtonText.anchor.set(0.5, 0.5); closeButtonText.x = 1024; closeButtonText.y = 1300; game.addChild(closeButtonText); infoUIElements.push(closeButton, closeButtonText); closeButton.down = function () { hideInfoScreen(); gameState = 'nickname'; showAllMenuUI(); coinsText.setText('Coins: ' + playerCoins); }; } // UI Element arrays for different game states var menuUIElements = []; var gameUIElements = []; var storeUIElements = []; var sellUIElements = []; var bagUIElements = []; var infoUIElements = []; // UI Elements var nicknameText = new Text2('Enter Nickname: A', { size: 80, fill: '#FFFFFF' }); nicknameText.anchor.set(0.5, 0.5); nicknameText.x = 1024; nicknameText.y = 800; var instructionText = new Text2('Use arrows to select letters, ADD to add, DELETE to remove', { size: 45, fill: '#CCCCCC' }); instructionText.anchor.set(0.5, 0.5); instructionText.x = 1024; instructionText.y = 900; var scoreText = new Text2('Score: 0', { size: 60, fill: '#FFFFFF' }); scoreText.anchor.set(0, 0); var levelText = new Text2('Level: 1', { size: 60, fill: '#FFFFFF' }); levelText.anchor.set(1, 0); var timerText = new Text2('Time: 0', { size: 50, fill: '#FFFFFF' }); timerText.anchor.set(0.5, 0); // Nickname input elements var leftArrow = game.attachAsset('arrowLeft', { anchorX: 0.5, anchorY: 0.5 }); leftArrow.x = 800; leftArrow.y = 1000; var rightArrow = game.attachAsset('arrowRight', { anchorX: 0.5, anchorY: 0.5 }); rightArrow.x = 1248; rightArrow.y = 1000; var startButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); startButton.x = 1024; startButton.y = 1200; var startButtonText = new Text2('START', { size: 40, fill: '#FFFFFF' }); startButtonText.anchor.set(0.5, 0.5); startButtonText.x = 1024; startButtonText.y = 1200; var addButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); addButton.x = 900; addButton.y = 1100; var addButtonText = new Text2('ADD', { size: 35, fill: '#FFFFFF' }); addButtonText.anchor.set(0.5, 0.5); addButtonText.x = 900; addButtonText.y = 1100; var deleteButton = game.attachAsset('deleteButton', { anchorX: 0.5, anchorY: 0.5 }); deleteButton.x = 1148; deleteButton.y = 1100; var deleteButtonText = new Text2('DELETE', { size: 35, fill: '#FFFFFF' }); deleteButtonText.anchor.set(0.5, 0.5); deleteButtonText.x = 1148; deleteButtonText.y = 1100; var storeButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); storeButton.x = 700; storeButton.y = 1300; var storeButtonText = new Text2('STORE', { size: 35, fill: '#FFFFFF' }); storeButtonText.anchor.set(0.5, 0.5); storeButtonText.x = 700; storeButtonText.y = 1300; var sellButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); sellButton.x = 1348; sellButton.y = 1300; var sellButtonText = new Text2('SELL', { size: 35, fill: '#FFFFFF' }); sellButtonText.anchor.set(0.5, 0.5); sellButtonText.x = 1348; sellButtonText.y = 1300; var shopButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); shopButton.x = 1024; shopButton.y = 1500; var shopButtonText = new Text2('SHOP', { size: 35, fill: '#FFFFFF' }); shopButtonText.anchor.set(0.5, 0.5); shopButtonText.x = 1024; shopButtonText.y = 1500; var bagButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); bagButton.x = 1024; bagButton.y = 1600; var bagButtonText = new Text2('BAG', { size: 35, fill: '#FFFFFF' }); bagButtonText.anchor.set(0.5, 0.5); bagButtonText.x = 1024; bagButtonText.y = 1600; var coinsText = new Text2('Coins: ' + playerCoins, { size: 50, fill: '#FFD700' }); coinsText.anchor.set(0.5, 0.5); coinsText.x = 1024; coinsText.y = 1400; // Add nickname UI to game and track as menu elements game.addChild(nicknameText); game.addChild(instructionText); game.addChild(leftArrow); game.addChild(rightArrow); game.addChild(addButton); game.addChild(addButtonText); game.addChild(deleteButton); game.addChild(deleteButtonText); game.addChild(startButton); game.addChild(startButtonText); game.addChild(storeButton); game.addChild(storeButtonText); game.addChild(sellButton); game.addChild(sellButtonText); game.addChild(shopButton); game.addChild(shopButtonText); game.addChild(bagButton); game.addChild(bagButtonText); game.addChild(coinsText); // Track menu UI elements menuUIElements.push(nicknameText, instructionText, leftArrow, rightArrow, addButton, addButtonText, deleteButton, deleteButtonText, startButton, startButtonText, storeButton, storeButtonText, sellButton, sellButtonText, shopButton, shopButtonText, bagButton, bagButtonText, coinsText); // Track game UI elements gameUIElements.push(scoreText, levelText, timerText); // Add game UI to GUI LK.gui.topLeft.addChild(scoreText); scoreText.x = 120; scoreText.y = 20; scoreText.visible = false; LK.gui.topRight.addChild(levelText); levelText.y = 20; levelText.visible = false; LK.gui.top.addChild(timerText); timerText.y = 100; timerText.visible = false; function hideAllMenuUI() { for (var i = 0; i < menuUIElements.length; i++) { menuUIElements[i].visible = false; } } function showAllMenuUI() { for (var i = 0; i < menuUIElements.length; i++) { menuUIElements[i].visible = true; } } function hideAllGameUI() { for (var i = 0; i < gameUIElements.length; i++) { gameUIElements[i].visible = false; } } function showAllGameUI() { for (var i = 0; i < gameUIElements.length; i++) { gameUIElements[i].visible = true; } } function hideAllStoreUI() { for (var i = 0; i < storeUIElements.length; i++) { storeUIElements[i].destroy(); } storeUIElements = []; } function hideAllSellUI() { for (var i = 0; i < sellUIElements.length; i++) { sellUIElements[i].destroy(); } sellUIElements = []; } function hideAllBagUI() { for (var i = 0; i < bagUIElements.length; i++) { bagUIElements[i].destroy(); } bagUIElements = []; } function hideAllInfoUI() { for (var i = 0; i < infoUIElements.length; i++) { infoUIElements[i].destroy(); } infoUIElements = []; } function updateNicknameDisplay() { var displayText = 'Enter Nickname: ' + playerNickname + alphabet[currentLetterIndex]; nicknameText.setText(displayText); } function startLevel(levelNumber) { // Clean up previous level if (currentLevel) { currentLevel.destroy(); } currentLevelNumber = levelNumber; levelTimer = 0; // Reset PYTHEREDON fossil counter for new level if (selectedDinosaur === 'PYTHEREDON') { storage.fossilsCollectedByPytheredon = 0; } // Reset legendary dinosaur ability counters for new level if (selectedDinosaur === 'TREX') { storage.trexUsesLeft = 3; } if (selectedDinosaur === 'SPINO') { storage.spinoUsesLeft = 1; } // Create new level currentLevel = new Level(levelNumber); currentLevel.createLevel(); game.addChild(currentLevel); levelText.setText('Level: ' + levelNumber); } function showStore() { gameState = 'store'; // Hide all menu and game UI elements hideAllMenuUI(); hideAllGameUI(); // Create store display var storeTitle = new Text2('FOSSIL STORE', { size: 80, fill: '#FFFFFF' }); storeTitle.anchor.set(0.5, 0.5); storeTitle.x = 1024; storeTitle.y = 200; game.addChild(storeTitle); storeUIElements.push(storeTitle); var backButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); backButton.x = 1024; backButton.y = 1500; var backButtonText = new Text2('BACK', { size: 35, fill: '#FFFFFF' }); backButtonText.anchor.set(0.5, 0.5); backButtonText.x = 1024; backButtonText.y = 1500; game.addChild(backButtonText); storeUIElements.push(backButton, backButtonText); // Sort and display inventory by rarity var rareFossils = []; var commonFossils = []; for (var i = 0; i < playerInventory.length; i++) { if (fossilRarities[playerInventory[i]] === 'rare') { rareFossils.push(playerInventory[i]); } else { commonFossils.push(playerInventory[i]); } } var allFossils = rareFossils.concat(commonFossils); var startY = 350; for (var j = 0; j < allFossils.length; j++) { var fossilName = allFossils[j]; var rarity = fossilRarities[fossilName]; var color = rarity === 'rare' ? '#FFD700' : '#FFFFFF'; var fossilText = new Text2(fossilName + ' (' + rarity + ')', { size: 40, fill: color }); fossilText.anchor.set(0.5, 0.5); fossilText.x = 1024; fossilText.y = startY + j * 60; game.addChild(fossilText); storeUIElements.push(fossilText); } backButton.down = function () { hideStore(); }; } function hideStore() { gameState = 'nickname'; // Remove all store UI elements hideAllStoreUI(); // Restore menu UI elements showAllMenuUI(); } function showSell() { gameState = 'sell'; // Hide all menu and game UI elements hideAllMenuUI(); hideAllGameUI(); // Create sell display var sellTitle = new Text2('SELL FOSSILS', { size: 80, fill: '#FFFFFF' }); sellTitle.anchor.set(0.5, 0.5); sellTitle.x = 1024; sellTitle.y = 200; game.addChild(sellTitle); sellUIElements.push(sellTitle); var sellAllButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); sellAllButton.x = 1024; sellAllButton.y = 1400; var sellAllButtonText = new Text2('SELL ALL', { size: 35, fill: '#FFFFFF' }); sellAllButtonText.anchor.set(0.5, 0.5); sellAllButtonText.x = 1024; sellAllButtonText.y = 1400; game.addChild(sellAllButtonText); sellUIElements.push(sellAllButton, sellAllButtonText); var sellBackButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); sellBackButton.x = 1024; sellBackButton.y = 1600; var sellBackButtonText = new Text2('BACK', { size: 35, fill: '#FFFFFF' }); sellBackButtonText.anchor.set(0.5, 0.5); sellBackButtonText.x = 1024; sellBackButtonText.y = 1600; game.addChild(sellBackButtonText); // Add 2X MONEY use button var use2xMoneyButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); use2xMoneyButton.x = 1024; use2xMoneyButton.y = 1500; var use2xMoneyButtonText = new Text2('2X MONEY (' + doubleMoneyLevelsLeft + ')', { size: 35, fill: '#FFFFFF' }); use2xMoneyButtonText.anchor.set(0.5, 0.5); use2xMoneyButtonText.x = 1024; use2xMoneyButtonText.y = 1500; game.addChild(use2xMoneyButtonText); sellUIElements.push(sellBackButton, sellBackButtonText, use2xMoneyButton, use2xMoneyButtonText); // Calculate total value var totalValue = 0; for (var i = 0; i < playerInventory.length; i++) { var fossilValue = fossilValues[playerInventory[i]]; if (doubleValueActive) { fossilValue *= 2; } totalValue += fossilValue; } var totalValueText = new Text2('Total Value: ' + totalValue + ' coins', { size: 50, fill: '#FFD700' }); totalValueText.anchor.set(0.5, 0.5); totalValueText.x = 1024; totalValueText.y = 300; game.addChild(totalValueText); sellUIElements.push(totalValueText); sellAllButton.down = function () { playerCoins += totalValue; playerInventory = []; // Reset 2X VALUE effect after use if (doubleValueActive) { doubleValueActive = false; storage.doubleValueActive = doubleValueActive; } storage.playerCoins = playerCoins; storage.playerInventory = playerInventory; hideSell(); }; use2xMoneyButton.down = function () { if (doubleMoneyLevelsLeft > 0) { // Activate 2X MONEY effect for selling doubleValueActive = true; storage.doubleValueActive = doubleValueActive; // Update button text to show remaining uses use2xMoneyButtonText.setText('2X MONEY (' + doubleMoneyLevelsLeft + ')'); // Recalculate and update total value display var newTotalValue = 0; for (var i = 0; i < playerInventory.length; i++) { var fossilValue = fossilValues[playerInventory[i]]; if (doubleValueActive) { fossilValue *= 2; } newTotalValue += fossilValue; } totalValueText.setText('Total Value: ' + newTotalValue + ' coins'); } }; sellBackButton.down = function () { hideSell(); }; } function hideSell() { gameState = 'nickname'; // Remove all sell UI elements hideAllSellUI(); // Restore menu UI elements showAllMenuUI(); coinsText.setText('Coins: ' + playerCoins); } function showShop() { gameState = 'shop'; // Hide all menu and game UI elements hideAllMenuUI(); hideAllGameUI(); // Create shop display var shopTitle = new Text2('POWER-UP SHOP', { size: 80, fill: '#FFFFFF' }); shopTitle.anchor.set(0.5, 0.5); shopTitle.x = 1024; shopTitle.y = 200; game.addChild(shopTitle); storeUIElements.push(shopTitle); // XRAY Power-up var xrayButton = game.attachAsset('purchaseButton', { anchorX: 0.5, anchorY: 0.5 }); xrayButton.x = 1024; xrayButton.y = 400; var xrayText = new Text2('XRAY - 500 Coins\nReveals all fossils for 1 level', { size: 35, fill: '#FFFFFF' }); xrayText.anchor.set(0.5, 0.5); xrayText.x = 1024; xrayText.y = 400; // 2X MONEY Power-up var doubleMoneyButton = game.attachAsset('purchaseButton', { anchorX: 0.5, anchorY: 0.5 }); doubleMoneyButton.x = 1024; doubleMoneyButton.y = 550; var doubleMoneyText = new Text2('2X MONEY - 10000 Coins\nDouble money for 20 levels', { size: 35, fill: '#FFFFFF' }); doubleMoneyText.anchor.set(0.5, 0.5); doubleMoneyText.x = 1024; doubleMoneyText.y = 550; // 2X VALUE Power-up var doubleValueButton = game.attachAsset('purchaseButton', { anchorX: 0.5, anchorY: 0.5 }); doubleValueButton.x = 1024; doubleValueButton.y = 700; var doubleValueText = new Text2('2X LUCK - 1250 Coins\nDouble egg chances', { size: 35, fill: '#FFFFFF' }); doubleValueText.anchor.set(0.5, 0.5); doubleValueText.x = 1024; doubleValueText.y = 700; // +1 STORAGE Power-up var storageButton = game.attachAsset('purchaseButton', { anchorX: 0.5, anchorY: 0.5 }); storageButton.x = 1024; storageButton.y = 850; var storageUpgradesBought = storage.storageUpgradesBought || 0; var storageText = new Text2('+1 SELECT - 100000 Coins\nAdd 1 dinosaur slot (' + storageUpgradesBought + '/4)', { size: 35, fill: '#FFFFFF' }); storageText.anchor.set(0.5, 0.5); storageText.x = 1024; storageText.y = 850; // +1 SELECT Pass Power-up var passButton = game.attachAsset('purchaseButton', { anchorX: 0.5, anchorY: 0.5 }); passButton.x = 1024; passButton.y = 1000; var passText = new Text2('+1 SELECT - 50000 Coins\nAdd 1 extra selection slot', { size: 35, fill: '#FFFFFF' }); passText.anchor.set(0.5, 0.5); passText.x = 1024; passText.y = 1000; // Common Egg var commonEggButton = game.attachAsset('purchaseButton', { anchorX: 0.5, anchorY: 0.5 }); commonEggButton.x = 1024; commonEggButton.y = 1400; var commonEggText = new Text2('Sıradan Yumurta - 500 Coins\nCommon fossil guaranteed', { size: 35, fill: '#FFFFFF' }); commonEggText.anchor.set(0.5, 0.5); commonEggText.x = 1024; commonEggText.y = 1400; // Common Egg Info Button var commonEggInfoButton = new Text2('❗', { size: 60, fill: '#FFD700' }); commonEggInfoButton.anchor.set(0.5, 0.5); commonEggInfoButton.x = 1350; commonEggInfoButton.y = 1400; game.addChild(commonEggInfoButton); // Rare Egg var rareEggButton = game.attachAsset('purchaseButton', { anchorX: 0.5, anchorY: 0.5 }); rareEggButton.x = 1024; rareEggButton.y = 1550; var rareEggText = new Text2('Nadir Yumurta - 2000 Coins\nRare fossil guaranteed', { size: 35, fill: '#FFD700' }); rareEggText.anchor.set(0.5, 0.5); rareEggText.x = 1024; rareEggText.y = 1550; // Rare Egg Info Button var rareEggInfoButton = new Text2('❗', { size: 60, fill: '#FFD700' }); rareEggInfoButton.anchor.set(0.5, 0.5); rareEggInfoButton.x = 1350; rareEggInfoButton.y = 1550; game.addChild(rareEggInfoButton); // Legendary Egg var legendaryEggButton = game.attachAsset('purchaseButton', { anchorX: 0.5, anchorY: 0.5 }); legendaryEggButton.x = 1024; legendaryEggButton.y = 1700; var legendaryEggText = new Text2('Destansı - 10000 Coins\nLegendary guaranteed', { size: 35, fill: '#FF69B4' }); legendaryEggText.anchor.set(0.5, 0.5); legendaryEggText.x = 1024; legendaryEggText.y = 1700; // Legendary Egg Info Button var legendaryEggInfoButton = new Text2('❗', { size: 60, fill: '#FFD700' }); legendaryEggInfoButton.anchor.set(0.5, 0.5); legendaryEggInfoButton.x = 1350; legendaryEggInfoButton.y = 1700; game.addChild(legendaryEggInfoButton); // Back button var shopBackButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); shopBackButton.x = 1024; shopBackButton.y = 1200; var shopBackButtonText = new Text2('BACK', { size: 35, fill: '#FFFFFF' }); shopBackButtonText.anchor.set(0.5, 0.5); shopBackButtonText.x = 1024; shopBackButtonText.y = 1200; game.addChild(xrayText); game.addChild(doubleMoneyText); game.addChild(doubleValueText); game.addChild(commonEggText); game.addChild(rareEggText); game.addChild(legendaryEggText); game.addChild(shopBackButtonText); game.addChild(storageText); game.addChild(passText); storeUIElements.push(xrayButton, xrayText, doubleMoneyButton, doubleMoneyText, doubleValueButton, doubleValueText, storageButton, storageText, passButton, passText, commonEggButton, commonEggText, commonEggInfoButton, rareEggButton, rareEggText, rareEggInfoButton, legendaryEggButton, legendaryEggText, legendaryEggInfoButton, shopBackButton, shopBackButtonText); // Purchase handlers xrayButton.down = function () { if (playerCoins >= 500) { playerCoins -= 500; storage.playerCoins = playerCoins; xrayLevelsLeft++; storage.xrayLevelsLeft = xrayLevelsLeft; hideShop(); } }; doubleMoneyButton.down = function () { if (playerCoins >= 10000) { playerCoins -= 10000; storage.playerCoins = playerCoins; doubleMoneyLevelsLeft += 20; storage.doubleMoneyLevelsLeft = doubleMoneyLevelsLeft; hideShop(); } }; doubleValueButton.down = function () { if (playerCoins >= 1250) { playerCoins -= 1250; storage.playerCoins = playerCoins; doubleSpawnChanceActive = true; storage.doubleSpawnChanceActive = doubleSpawnChanceActive; hideShop(); } }; storageButton.down = function () { var storageUpgradesBought = storage.storageUpgradesBought || 0; if (storageUpgradesBought < 4 && playerCoins >= 100000) { playerCoins -= 100000; storage.playerCoins = playerCoins; storageUpgradesBought++; storage.storageUpgradesBought = storageUpgradesBought; hideShop(); } }; passButton.down = function () { if (playerCoins >= 50000) { playerCoins -= 50000; storage.playerCoins = playerCoins; var passPurchases = storage.passPurchases || 0; passPurchases++; storage.passPurchases = passPurchases; hideShop(); } }; // Common egg info handler commonEggInfoButton.down = function () { showCommonEggInfo(); }; // Egg purchase handlers commonEggButton.down = function () { if (playerCoins >= 500) { playerCoins -= 500; storage.playerCoins = playerCoins; // Open common egg and get dinosaur var dinosaurName = openEgg('common'); } }; // Rare egg info handler rareEggInfoButton.down = function () { showRareEggInfo(); }; rareEggButton.down = function () { if (playerCoins >= 2000) { playerCoins -= 2000; storage.playerCoins = playerCoins; // Open rare egg and get dinosaur var dinosaurName = openEgg('rare'); } }; // Legendary egg info handler legendaryEggInfoButton.down = function () { showLegendaryEggInfo(); }; legendaryEggButton.down = function () { if (playerCoins >= 10000) { playerCoins -= 10000; storage.playerCoins = playerCoins; // Open legendary egg and get dinosaur var dinosaurName = openEgg('legendary'); } }; shopBackButton.down = function () { hideShop(); }; } function hideShop() { gameState = 'nickname'; // Remove all shop UI elements hideAllStoreUI(); // Restore menu UI elements showAllMenuUI(); coinsText.setText('Coins: ' + playerCoins); } function showBag() { gameState = 'bag'; // Hide all menu and game UI elements hideAllMenuUI(); hideAllGameUI(); // Create bag display var bagTitle = new Text2('DINOSAUR BAG', { size: 80, fill: '#FFFFFF' }); bagTitle.anchor.set(0.5, 0.5); bagTitle.x = 1024; bagTitle.y = 200; game.addChild(bagTitle); bagUIElements.push(bagTitle); // Calculate vomit limit (1 base + upgrades bought + pass purchases) var passPurchases = storage.passPurchases || 0; var maxVomitSlots = 1 + (storage.storageUpgradesBought || 0) + passPurchases; var baseSlots = 1 + (storage.storageUpgradesBought || 0); var passSlots = storage.passPurchases || 0; var vomitText = new Text2('Select Slots: ' + maxVomitSlots + ' available (Base: ' + baseSlots + ' + Pass: ' + passSlots + ')', { size: 35, fill: '#FFD700' }); vomitText.anchor.set(0.5, 0.5); vomitText.x = 1024; vomitText.y = 280; game.addChild(vomitText); bagUIElements.push(vomitText); // Sort dinosaurs by rarity var legendaryDinos = []; var rareDinos = []; var commonDinos = []; for (var i = 0; i < dinosaurCollection.length; i++) { var dino = dinosaurCollection[i]; var rarity = dinosaurRarities[dino]; if (rarity === 'legendary') { legendaryDinos.push(dino); } else if (rarity === 'rare') { rareDinos.push(dino); } else { commonDinos.push(dino); } } var allDinos = legendaryDinos.concat(rareDinos).concat(commonDinos); // Convert selectedDinosaur to array if needed for multiple selection support var selectedDinosaurs = []; if (storage.selectedDinosaurs && Array.isArray(storage.selectedDinosaurs)) { selectedDinosaurs = storage.selectedDinosaurs; } else if (selectedDinosaur) { selectedDinosaurs = [selectedDinosaur]; } // Display all dinosaurs - unlimited storage, but limited vomit selection var startY = 350; for (var j = 0; j < allDinos.length; j++) { var dinoName = allDinos[j]; var rarity = dinosaurRarities[dinoName]; var color = '#87CEEB'; // Light blue for common/regular dinosaurs if (rarity === 'legendary') color = '#FF0000'; // Red for legendary else if (rarity === 'rare') color = '#800080'; // Purple for rare else if (rarity === 'common') color = '#00008B'; // Dark blue for common var isSelected = selectedDinosaurs.indexOf(dinoName) !== -1; var displayText = dinoName + ' (' + rarity + ')' + (isSelected ? ' [SELECTED]' : ''); var dinoButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); dinoButton.x = 1024; dinoButton.y = startY + j * 80; var dinoText = new Text2(displayText, { size: 35, fill: isSelected ? '#000000' : color }); dinoText.anchor.set(0.5, 0.5); dinoText.x = 1024; dinoText.y = startY + j * 80; game.addChild(dinoText); bagUIElements.push(dinoButton, dinoText); // Create closure for selection - check vomit limit (function (dinosaurName) { dinoButton.down = function () { var currentIndex = selectedDinosaurs.indexOf(dinosaurName); if (currentIndex !== -1) { // Remove from selection selectedDinosaurs.splice(currentIndex, 1); } else if (selectedDinosaurs.length < maxVomitSlots) { // Add to selection if under vomit limit selectedDinosaurs.push(dinosaurName); } // Update storage and backward compatibility storage.selectedDinosaurs = selectedDinosaurs; if (selectedDinosaurs.length > 0) { selectedDinosaur = selectedDinosaurs[0]; // Keep backward compatibility storage.selectedDinosaur = selectedDinosaur; } else { selectedDinosaur = null; storage.selectedDinosaur = null; } hideBag(); }; })(dinoName); } // Back button // Delete button var deleteButton = game.attachAsset('deleteButton', { anchorX: 0.5, anchorY: 0.5 }); deleteButton.x = 700; deleteButton.y = 1500; var deleteButtonText = new Text2('DELETE', { size: 35, fill: '#FFFFFF' }); deleteButtonText.anchor.set(0.5, 0.5); deleteButtonText.x = 700; deleteButtonText.y = 1500; game.addChild(deleteButtonText); bagUIElements.push(deleteButton, deleteButtonText); var bagBackButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); bagBackButton.x = 1348; bagBackButton.y = 1500; var bagBackButtonText = new Text2('BACK', { size: 35, fill: '#FFFFFF' }); bagBackButtonText.anchor.set(0.5, 0.5); bagBackButtonText.x = 1348; bagBackButtonText.y = 1500; game.addChild(bagBackButtonText); bagUIElements.push(bagBackButton, bagBackButtonText); // Delete button handler deleteButton.down = function () { showDeleteMode(); }; bagBackButton.down = function () { hideBag(); }; } function showDeleteMode() { gameState = 'deleteMode'; // Hide current bag UI hideAllBagUI(); // Create delete mode display var deleteTitle = new Text2('DELETE DINOSAURS', { size: 80, fill: '#FF4444' }); deleteTitle.anchor.set(0.5, 0.5); deleteTitle.x = 1024; deleteTitle.y = 200; game.addChild(deleteTitle); bagUIElements.push(deleteTitle); var deleteInstructionText = new Text2('Select dinosaurs to delete:', { size: 50, fill: '#FFFFFF' }); deleteInstructionText.anchor.set(0.5, 0.5); deleteInstructionText.x = 1024; deleteInstructionText.y = 280; game.addChild(deleteInstructionText); bagUIElements.push(deleteInstructionText); // Sort dinosaurs by rarity for display var legendaryDinos = []; var rareDinos = []; var commonDinos = []; for (var i = 0; i < dinosaurCollection.length; i++) { var dino = dinosaurCollection[i]; var rarity = dinosaurRarities[dino]; if (rarity === 'legendary') { legendaryDinos.push(dino); } else if (rarity === 'rare') { rareDinos.push(dino); } else { commonDinos.push(dino); } } var allDinos = legendaryDinos.concat(rareDinos).concat(commonDinos); // Track selected dinosaurs for deletion var selectedForDeletion = []; // Display all dinosaurs with delete option var startY = 350; for (var j = 0; j < allDinos.length; j++) { var dinoName = allDinos[j]; var rarity = dinosaurRarities[dinoName]; var color = '#87CEEB'; // Light blue for common/regular dinosaurs if (rarity === 'legendary') color = '#FF0000'; // Red for legendary else if (rarity === 'rare') color = '#800080'; // Purple for rare else if (rarity === 'common') color = '#00008B'; // Dark blue for common var isSelectedForDeletion = selectedForDeletion.indexOf(dinoName) !== -1; var displayText = dinoName + ' (' + rarity + ')' + (isSelectedForDeletion ? ' [TO DELETE]' : ''); var dinoButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); dinoButton.x = 1024; dinoButton.y = startY + j * 80; var dinoText = new Text2(displayText, { size: 35, fill: isSelectedForDeletion ? '#FF4444' : color }); dinoText.anchor.set(0.5, 0.5); dinoText.x = 1024; dinoText.y = startY + j * 80; game.addChild(dinoText); bagUIElements.push(dinoButton, dinoText); // Create closure for selection toggle (function (dinosaurName, textElement) { dinoButton.down = function () { var index = selectedForDeletion.indexOf(dinosaurName); if (index === -1) { // Add to deletion list selectedForDeletion.push(dinosaurName); textElement.setText(dinosaurName + ' (' + dinosaurRarities[dinosaurName] + ') [TO DELETE]'); textElement.fill = '#FF4444'; } else { // Remove from deletion list selectedForDeletion.splice(index, 1); var rarity = dinosaurRarities[dinosaurName]; var color = '#87CEEB'; // Light blue for common/regular dinosaurs if (rarity === 'legendary') color = '#FF0000'; // Red for legendary else if (rarity === 'rare') color = '#800080'; // Purple for rare else if (rarity === 'common') color = '#00008B'; // Dark blue for common textElement.setText(dinosaurName + ' (' + rarity + ')'); textElement.fill = color; } }; })(dinoName, dinoText); } // Confirm delete button var confirmDeleteButton = game.attachAsset('deleteButton', { anchorX: 0.5, anchorY: 0.5 }); confirmDeleteButton.x = 700; confirmDeleteButton.y = 1500; var confirmDeleteText = new Text2('CONFIRM DELETE', { size: 30, fill: '#FFFFFF' }); confirmDeleteText.anchor.set(0.5, 0.5); confirmDeleteText.x = 700; confirmDeleteText.y = 1500; game.addChild(confirmDeleteText); bagUIElements.push(confirmDeleteButton, confirmDeleteText); // Cancel delete button var cancelDeleteButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); cancelDeleteButton.x = 1348; cancelDeleteButton.y = 1500; var cancelDeleteText = new Text2('CANCEL', { size: 35, fill: '#FFFFFF' }); cancelDeleteText.anchor.set(0.5, 0.5); cancelDeleteText.x = 1348; cancelDeleteText.y = 1500; game.addChild(cancelDeleteText); bagUIElements.push(cancelDeleteButton, cancelDeleteText); // Event handlers confirmDeleteButton.down = function () { // Remove selected dinosaurs from collection for (var i = 0; i < selectedForDeletion.length; i++) { var dinoToDelete = selectedForDeletion[i]; var index = dinosaurCollection.indexOf(dinoToDelete); if (index !== -1) { dinosaurCollection.splice(index, 1); // If deleted dinosaur was selected, clear selection if (selectedDinosaur === dinoToDelete) { selectedDinosaur = null; storage.selectedDinosaur = null; } } } // Save updated collection storage.dinosaurCollection = dinosaurCollection; // Return to bag view hideAllBagUI(); showBag(); }; cancelDeleteButton.down = function () { // Return to bag view without deleting hideAllBagUI(); showBag(); }; } function hideBag() { gameState = 'nickname'; // Remove all bag UI elements hideAllBagUI(); // Restore menu UI elements showAllMenuUI(); } function showCommonEggInfo() { gameState = 'commonEggInfo'; // Hide all shop UI elements hideAllStoreUI(); // Create info display var infoTitle = new Text2('SIRADAN YUMURTA İÇERİĞİ', { size: 60, fill: '#FFFFFF' }); infoTitle.anchor.set(0.5, 0.5); infoTitle.x = 1024; infoTitle.y = 200; game.addChild(infoTitle); infoUIElements.push(infoTitle); var infoText = 'PARASOUROLUPHUS - %33.33\n'; infoText += 'Yavaş kazma (1 saniye gecikme)\n\n'; infoText += 'PYTHEREDON - %33.33\n'; infoText += 'Seviye başı sadece 1 fosil alır\n\n'; infoText += 'DIMETRODON - %33.33\n'; infoText += 'Nadirlık fark etmez 2 fosil alır'; var infoDisplay = new Text2(infoText, { size: 40, fill: '#FFFFFF' }); infoDisplay.anchor.set(0.5, 0.5); infoDisplay.x = 1024; infoDisplay.y = 600; game.addChild(infoDisplay); infoUIElements.push(infoDisplay); var backButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); backButton.x = 1024; backButton.y = 1200; var backButtonText = new Text2('BACK', { size: 35, fill: '#FFFFFF' }); backButtonText.anchor.set(0.5, 0.5); backButtonText.x = 1024; backButtonText.y = 1200; game.addChild(backButtonText); infoUIElements.push(backButton, backButtonText); backButton.down = function () { hideInfoScreen(); showShop(); }; } function showRareEggInfo() { gameState = 'rareEggInfo'; // Hide all shop UI elements hideAllStoreUI(); // Create info display var infoTitle = new Text2('NADİR YUMURTA İÇERİĞİ', { size: 60, fill: '#FFFFFF' }); infoTitle.anchor.set(0.5, 0.5); infoTitle.x = 1024; infoTitle.y = 200; game.addChild(infoTitle); infoUIElements.push(infoTitle); var infoText = 'BARYONYX - %45\n'; infoText += '0.2x daha hızlı kaya kazma\n\n'; infoText += 'ALLO - %35\n'; infoText += '0.4x daha hızlı kaya kazma\n\n'; infoText += 'YUTY - %20\n'; infoText += '0.7x daha hızlı kaya kazma'; var infoDisplay = new Text2(infoText, { size: 40, fill: '#FFFFFF' }); infoDisplay.anchor.set(0.5, 0.5); infoDisplay.x = 1024; infoDisplay.y = 600; game.addChild(infoDisplay); infoUIElements.push(infoDisplay); var backButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); backButton.x = 1024; backButton.y = 1200; var backButtonText = new Text2('BACK', { size: 35, fill: '#FFFFFF' }); backButtonText.anchor.set(0.5, 0.5); backButtonText.x = 1024; backButtonText.y = 1200; game.addChild(backButtonText); infoUIElements.push(backButton, backButtonText); backButton.down = function () { hideInfoScreen(); showShop(); }; } function showLegendaryEggInfo() { gameState = 'legendaryEggInfo'; // Hide all shop UI elements hideAllStoreUI(); // Create info display var infoTitle = new Text2('DESTANSI YUMURTA İÇERİĞİ', { size: 60, fill: '#FFFFFF' }); infoTitle.anchor.set(0.5, 0.5); infoTitle.x = 1024; infoTitle.y = 200; game.addChild(infoTitle); infoUIElements.push(infoTitle); var infoText = 'TREX - %3\n'; infoText += 'Etraftaki 4 kayayı kırar (3 kullanım)\n\n'; infoText += 'SPINO - %10\n'; infoText += 'Kuyruk darbesi 3 kaya kırar (1 kullanım)\n\n'; infoText += 'GIGA - %15\n'; infoText += 'Kaya kırma hızı 2x artar\n\n'; infoText += 'Mutasyonlu BARYONYX - %25\n'; infoText += 'Kaya kırma 0.9x daha hızlı\n\n'; infoText += 'Mutasyonlu DIMETRODON - %17\n'; infoText += 'En değerli 3 fosili alır\n\n'; infoText += 'Mutasyonlu PARASAUROLUPHUS - %30\n'; infoText += 'Hızlı blok kırma (2 saniye)'; var infoDisplay = new Text2(infoText, { size: 30, fill: '#FFFFFF' }); infoDisplay.anchor.set(0.5, 0.5); infoDisplay.x = 1024; infoDisplay.y = 700; game.addChild(infoDisplay); infoUIElements.push(infoDisplay); var backButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); backButton.x = 1024; backButton.y = 1200; var backButtonText = new Text2('BACK', { size: 35, fill: '#FFFFFF' }); backButtonText.anchor.set(0.5, 0.5); backButtonText.x = 1024; backButtonText.y = 1200; game.addChild(backButtonText); infoUIElements.push(backButton, backButtonText); backButton.down = function () { hideInfoScreen(); showShop(); }; } function hideInfoScreen() { // Remove all info UI elements hideAllInfoUI(); } function startGame() { if (playerNickname.length === 0) { return; } storage.playerNickname = playerNickname; gameState = 'playing'; // Hide menu UI elements hideAllMenuUI(); // Show game UI elements timerText.visible = true; scoreText.visible = true; levelText.visible = true; // Show power-up purchase options purchaseOption1.visible = true; purchaseText1.visible = true; purchaseOption2.visible = true; purchaseText2.visible = true; purchaseOption3.visible = true; purchaseText3.visible = true; // Show XRAY use button xrayUseButton.visible = true; xrayUseText.visible = true; xrayUseText.setText('XRAY (' + xrayLevelsLeft + ')'); // Show back to menu button backToMenuButton.visible = true; backToMenuText.visible = true; // Start first level startLevel(1); } // Event handlers leftArrow.down = function (x, y, obj) { if (gameState !== 'nickname') { return; } currentLetterIndex = (currentLetterIndex - 1 + alphabet.length) % alphabet.length; updateNicknameDisplay(); }; rightArrow.down = function (x, y, obj) { if (gameState !== 'nickname') { return; } currentLetterIndex = (currentLetterIndex + 1) % alphabet.length; updateNicknameDisplay(); }; addButton.down = function (x, y, obj) { if (gameState !== 'nickname') { return; } // Add current letter to nickname if (playerNickname.length < 12) { playerNickname += alphabet[currentLetterIndex]; updateNicknameDisplay(); } }; startButton.down = function (x, y, obj) { if (gameState !== 'nickname') { return; } startGame(); }; deleteButton.down = function (x, y, obj) { if (gameState !== 'nickname') { return; } if (playerNickname.length > 0) { playerNickname = playerNickname.slice(0, -1); updateNicknameDisplay(); } }; storeButton.down = function (x, y, obj) { if (gameState !== 'nickname') { return; } showStore(); }; sellButton.down = function (x, y, obj) { if (gameState !== 'nickname') { return; } showSell(); }; shopButton.down = function (x, y, obj) { if (gameState !== 'nickname') { return; } showShop(); }; bagButton.down = function (x, y, obj) { if (gameState !== 'nickname') { return; } showBag(); }; game.down = function (x, y, obj) { // Game down handler for playing state only }; // Game update loop game.update = function () { if (gameState === 'playing') { levelTimer++; timerText.setText('Time: ' + Math.floor(levelTimer / 60)); // Slowly decrease score over time to encourage speed if (levelTimer % 120 === 0 && LK.getScore() > 0) { // Every 2 seconds LK.setScore(Math.max(0, LK.getScore() - 1)); scoreText.setText('Score: ' + LK.getScore()); } } }; // Power-up purchase options (shown when game is playing) var purchaseOption1 = game.attachAsset('purchaseButton', { anchorX: 0.5, anchorY: 0.5 }); purchaseOption1.x = 1800; purchaseOption1.y = 400; purchaseOption1.visible = false; var purchaseText1 = new Text2('XRAY\n500 Coins', { size: 30, fill: '#FFFFFF' }); purchaseText1.anchor.set(0.5, 0.5); purchaseText1.x = 1800; purchaseText1.y = 400; purchaseText1.visible = false; game.addChild(purchaseText1); var purchaseOption2 = game.attachAsset('purchaseButton', { anchorX: 0.5, anchorY: 0.5 }); purchaseOption2.x = 1800; purchaseOption2.y = 520; purchaseOption2.visible = false; var purchaseText2 = new Text2('2X MONEY\n10000 Coins', { size: 30, fill: '#FFFFFF' }); purchaseText2.anchor.set(0.5, 0.5); purchaseText2.x = 1800; purchaseText2.y = 520; purchaseText2.visible = false; game.addChild(purchaseText2); var purchaseOption3 = game.attachAsset('purchaseButton', { anchorX: 0.5, anchorY: 0.5 }); purchaseOption3.x = 1800; purchaseOption3.y = 640; purchaseOption3.visible = false; var purchaseText3 = new Text2('2X LUCK\n1250', { size: 30, fill: '#FFFFFF' }); purchaseText3.anchor.set(0.5, 0.5); purchaseText3.x = 1800; purchaseText3.y = 640; purchaseText3.visible = false; game.addChild(purchaseText3); // Track purchase UI elements as game UI gameUIElements.push(purchaseOption1, purchaseText1, purchaseOption2, purchaseText2, purchaseOption3, purchaseText3); // Purchase event handlers purchaseOption1.down = function (x, y, obj) { if (gameState === 'playing' && playerCoins >= 500) { playerCoins -= 500; storage.playerCoins = playerCoins; xrayLevelsLeft++; storage.xrayLevelsLeft = xrayLevelsLeft; xrayUseText.setText('XRAY (' + xrayLevelsLeft + ')'); // Show all fossils for current level if (currentLevel) { for (var i = 0; i < currentLevel.blocks.length; i++) { var block = currentLevel.blocks[i]; if (block.hasFossil && !block.isCollected) { block.alpha = 0.5; // Make blocks with fossils semi-transparent } } } } }; purchaseOption2.down = function (x, y, obj) { if (gameState === 'playing' && playerCoins >= 10000) { playerCoins -= 10000; storage.playerCoins = playerCoins; doubleMoneyLevelsLeft = 20; storage.doubleMoneyLevelsLeft = doubleMoneyLevelsLeft; } }; purchaseOption3.down = function (x, y, obj) { if (gameState === 'playing' && playerCoins >= 1250) { playerCoins -= 1250; storage.playerCoins = playerCoins; doubleSpawnChanceActive = true; storage.doubleSpawnChanceActive = doubleSpawnChanceActive; } }; // XRAY use button (shown when game is playing) var xrayUseButton = game.attachAsset('purchaseButton', { anchorX: 0.5, anchorY: 0.5 }); xrayUseButton.x = 624; // Further left side of bottom center xrayUseButton.y = 2500; // Bottom of screen xrayUseButton.visible = false; var xrayUseText = new Text2('XRAY (' + xrayLevelsLeft + ')', { size: 30, fill: '#FFFFFF' }); xrayUseText.anchor.set(0.5, 0.5); xrayUseText.x = 624; xrayUseText.y = 2500; xrayUseText.visible = false; game.addChild(xrayUseText); // Back to menu button (shown when game is playing) var backToMenuButton = game.attachAsset('purchaseButton', { anchorX: 0.5, anchorY: 0.5 }); backToMenuButton.x = 1424; // Further right side of bottom center backToMenuButton.y = 2500; // Bottom of screen, same level as XRAY backToMenuButton.visible = false; var backToMenuText = new Text2('MENÜYE GERİ DÖN', { size: 25, fill: '#FFFFFF' }); backToMenuText.anchor.set(0.5, 0.5); backToMenuText.x = 1424; backToMenuText.y = 2500; backToMenuText.visible = false; game.addChild(backToMenuText); // Track XRAY use and back to menu UI elements as game UI gameUIElements.push(xrayUseButton, xrayUseText, backToMenuButton, backToMenuText); // XRAY use button click handler xrayUseButton.down = function (x, y, obj) { if (gameState === 'playing' && xrayLevelsLeft > 0) { xrayLevelsLeft--; storage.xrayLevelsLeft = xrayLevelsLeft; xrayUseText.setText('XRAY (' + xrayLevelsLeft + ')'); // Show all fossils for current level if (currentLevel) { for (var i = 0; i < currentLevel.blocks.length; i++) { var block = currentLevel.blocks[i]; if (block.hasFossil && !block.isCollected) { block.alpha = 0.5; // Make blocks with fossils semi-transparent } } } } }; // Back to menu button click handler backToMenuButton.down = function (x, y, obj) { if (gameState === 'playing') { // Clean up current level if (currentLevel) { currentLevel.destroy(); currentLevel = null; } // Reset game state gameState = 'nickname'; // Hide game UI elements hideAllGameUI(); // Show menu UI elements showAllMenuUI(); } }; // Initialize display updateNicknameDisplay(); coinsText.setText('Coins: ' + playerCoins); // Start background music LK.playMusic('backgroundMusic');
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var Fossil = Container.expand(function (fossilType) {
var self = Container.call(this);
var fossilGraphics = self.attachAsset(fossilType, {
anchorX: 0.5,
anchorY: 0.5
});
self.fossilType = fossilType;
self.isCollected = false;
self.points = fossilType === 'rareFossil' ? 500 : 100;
self.down = function (x, y, obj) {
if (!self.isCollected) {
self.collectFossil();
}
};
self.collectFossil = function () {
self.isCollected = true;
LK.getSound('fossilFound').play();
// Apply dinosaur abilities
if (selectedDinosaur === 'PYTHEREDON') {
// PYTHEREDON only collects 1 fossil per level regardless of rarity
var fossilsCollectedByPytheredon = storage.fossilsCollectedByPytheredon || 0;
if (fossilsCollectedByPytheredon >= 1) {
// Skip collection - PYTHEREDON already collected its one fossil
self.animateCollection();
return;
}
storage.fossilsCollectedByPytheredon = fossilsCollectedByPytheredon + 1;
} else if (selectedDinosaur === 'Mutated DIMETRODON') {
// Mutated DIMETRODON collects 3 most valuable fossils per level
self.handleMutatedDimetrodonCollection();
return;
} else if (selectedDinosaur === 'DIMETRODON') {
// DIMETRODON collects 2 fossils regardless of rarity
self.handleDimetrodonCollection();
return;
}
// Add fossil to inventory
playerInventory.push(self.fossilType);
storage.playerInventory = playerInventory;
// Award points based on extraction speed
var speedBonus = Math.max(0, 100 - Math.floor(levelTimer / 100));
var totalPoints = self.points + speedBonus;
// Apply 2X MONEY effect if active
if (doubleMoneyLevelsLeft > 0) {
totalPoints *= 2;
}
LK.setScore(LK.getScore() + totalPoints);
scoreText.setText('Score: ' + LK.getScore());
self.animateCollection();
};
self.handleDimetrodonCollection = function () {
// DIMETRODON collects 2 fossils regardless of rarity
// Add current fossil first
playerInventory.push(self.fossilType);
// Add one more fossil if available in inventory
if (playerInventory.length > 1) {
playerInventory.push(playerInventory[0]); // Add any fossil from inventory
}
storage.playerInventory = playerInventory;
// Award bonus points for rare collection
var totalPoints = self.points * 2; // Double points for DIMETRODON
if (doubleMoneyLevelsLeft > 0) {
totalPoints *= 2;
}
LK.setScore(LK.getScore() + totalPoints);
scoreText.setText('Score: ' + LK.getScore());
self.animateCollection();
};
self.handleMutatedDimetrodonCollection = function () {
// Mutated DIMETRODON collects 3 most valuable fossils per level
// Find the 3 most valuable fossils from current level
var availableFossils = [];
for (var i = 0; i < currentLevel.fossils.length; i++) {
if (!currentLevel.fossils[i].isCollected) {
availableFossils.push(currentLevel.fossils[i]);
}
}
// Sort by fossil value (descending)
availableFossils.sort(function (a, b) {
return b.points - a.points;
});
// Take up to 3 most valuable
var fossilsToCollect = Math.min(3, availableFossils.length);
var totalPoints = 0;
for (var j = 0; j < fossilsToCollect; j++) {
playerInventory.push(availableFossils[j].fossilType);
totalPoints += availableFossils[j].points;
// Mark as collected
availableFossils[j].isCollected = true;
availableFossils[j].animateCollection();
}
storage.playerInventory = playerInventory;
// Apply 2X MONEY effect if active
if (doubleMoneyLevelsLeft > 0) {
totalPoints *= 2;
}
LK.setScore(LK.getScore() + totalPoints);
scoreText.setText('Score: ' + LK.getScore());
self.animateCollection();
};
self.animateCollection = function () {
// Animate collection
tween(self, {
scaleX: 1.5,
scaleY: 1.5,
alpha: 0
}, {
duration: 500,
easing: tween.easeOut,
onFinish: function onFinish() {
currentLevel.fossilsCollected++;
currentLevel.checkLevelComplete();
}
});
};
return self;
});
var Level = Container.expand(function (levelNumber) {
var self = Container.call(this);
self.levelNumber = levelNumber;
self.blocks = [];
self.fossils = [];
self.fossilsCollected = 0;
self.totalFossils = 0;
self.blocksCollected = 0;
self.totalBlocks = 0;
self.createLevel = function () {
// Create excavation site background
var site = self.attachAsset('excavationSite', {
anchorX: 0.5,
anchorY: 0.5
});
site.x = 1024;
site.y = 1000;
// Determine fossils for this level (3-6 fossils)
var fossilCount = 3 + Math.floor(Math.random() * 4);
var fossilTypes = ['fossil1', 'fossil2', 'fossil3'];
// Add rare fossil chance (higher in later levels)
if (Math.random() < levelNumber * 0.05) {
fossilTypes.push('rareFossil');
}
self.totalFossils = fossilCount;
// Create limestone blocks grid
var blocksPerRow = 8;
var rows = 6;
var startX = 534;
var startY = 600;
var spacing = 140;
var fossilPositions = [];
for (var i = 0; i < fossilCount; i++) {
var randomPos = Math.floor(Math.random() * (blocksPerRow * rows));
while (fossilPositions.indexOf(randomPos) !== -1) {
randomPos = Math.floor(Math.random() * (blocksPerRow * rows));
}
fossilPositions.push(randomPos);
}
var blockIndex = 0;
for (var row = 0; row < rows; row++) {
for (var col = 0; col < blocksPerRow; col++) {
var block = new LimestoneBlock();
block.x = startX + col * spacing;
block.y = startY + row * spacing;
// Check if this block contains a fossil
if (fossilPositions.indexOf(blockIndex) !== -1) {
block.hasFossil = true;
var fossilTypeIndex = Math.floor(Math.random() * fossilTypes.length);
block.fossilType = fossilTypes[fossilTypeIndex];
}
self.blocks.push(block);
self.addChild(block);
blockIndex++;
}
}
self.totalBlocks = self.blocks.length;
};
self.revealFossil = function (fossilType, x, y) {
var fossil = new Fossil(fossilType);
fossil.x = x;
fossil.y = y;
// Animate fossil appearance
fossil.alpha = 0;
fossil.scaleX = 0;
fossil.scaleY = 0;
self.fossils.push(fossil);
self.addChild(fossil);
tween(fossil, {
alpha: 1,
scaleX: 1,
scaleY: 1
}, {
duration: 400,
easing: tween.easeOut
});
};
self.checkBlockCollection = function () {
self.blocksCollected++;
if (self.blocksCollected >= self.totalBlocks) {
// All blocks collected, show any remaining fossils
for (var i = 0; i < self.blocks.length; i++) {
var block = self.blocks[i];
if (block.hasFossil && !block.isCollected) {
self.revealFossil(block.fossilType, block.x, block.y);
}
}
}
};
self.checkLevelComplete = function () {
if (self.fossilsCollected >= self.totalFossils) {
LK.getSound('levelComplete').play();
// Level completion bonus
var timeBonus = Math.max(0, 1000 - Math.floor(levelTimer / 10));
LK.setScore(LK.getScore() + timeBonus);
scoreText.setText('Score: ' + LK.getScore());
// Decrease power-up counters
if (xrayLevelsLeft > 0) {
xrayLevelsLeft--;
storage.xrayLevelsLeft = xrayLevelsLeft;
}
if (doubleMoneyLevelsLeft > 0) {
doubleMoneyLevelsLeft--;
storage.doubleMoneyLevelsLeft = doubleMoneyLevelsLeft;
}
// Progress to next level after delay
LK.setTimeout(function () {
if (currentLevelNumber < 20) {
startLevel(currentLevelNumber + 1);
} else {
// Game complete
LK.showYouWin();
}
}, 2000);
}
};
return self;
});
var LimestoneBlock = Container.expand(function () {
var self = Container.call(this);
var blockGraphics = self.attachAsset('limestone', {
anchorX: 0.5,
anchorY: 0.5
});
self.hasFossil = false;
self.fossilType = null;
self.isCollected = false;
self.down = function (x, y, obj) {
if (!self.isCollected) {
self.collectBlock();
}
};
self.collectBlock = function () {
// Check if dinosaur ability affects digging speed
if (selectedDinosaur === 'PARASOUROLUPHUS') {
// PARASOUROLUPHUS is very slow - add delay
LK.setTimeout(function () {
self.performCollection();
}, 1000); // 1 second delay
} else if (selectedDinosaur === 'BARYONYX') {
// BARYONYX is 0.2x faster (20% speed increase)
LK.setTimeout(function () {
self.performCollection();
}, 240); // 0.8x delay = faster mining
} else if (selectedDinosaur === 'YUTY') {
// YUTY is 0.7x faster (70% speed increase)
LK.setTimeout(function () {
self.performCollection();
}, 90); // 0.3x delay = much faster mining
} else if (selectedDinosaur === 'ALLO') {
// ALLO is 0.4x faster (40% speed increase)
LK.setTimeout(function () {
self.performCollection();
}, 180); // 0.6x delay = faster mining
} else if (selectedDinosaur === 'TREX') {
// TREX breaks 4 surrounding blocks, 3 uses per level
var usesLeft = storage.trexUsesLeft || 0;
if (usesLeft > 0) {
self.performTrexCollection();
storage.trexUsesLeft = usesLeft - 1;
} else {
self.performCollection();
}
} else if (selectedDinosaur === 'SPINO') {
// SPINO tail strike breaks 3 blocks in line, 1 use per level
var usesLeft = storage.spinoUsesLeft || 0;
if (usesLeft > 0) {
self.performSpinoCollection();
storage.spinoUsesLeft = usesLeft - 1;
} else {
self.performCollection();
}
} else if (selectedDinosaur === 'GIGA') {
// GIGA 2x mining speed
LK.setTimeout(function () {
self.performCollection();
}, 150); // 0.5x delay = 2x faster mining
} else if (selectedDinosaur === 'Mutated BARYONYX') {
// Mutated BARYONYX 0.9x faster (90% speed increase)
LK.setTimeout(function () {
self.performCollection();
}, 30); // 0.1x delay = much faster mining
} else if (selectedDinosaur === 'Mutated PARASAUROLUPHUS') {
// Mutated PARASAUROLUPHUS is faster than regular PARASAUROLUPHUS - 2 second mining
LK.setTimeout(function () {
self.performCollection();
}, 2000); // 2 second delay - faster than regular PARASAUROLUPHUS
} else {
self.performCollection();
}
};
self.performCollection = function () {
self.isCollected = true;
LK.getSound('dig').play();
// Animate collection
tween(self, {
scaleX: 0,
scaleY: 0,
alpha: 0
}, {
duration: 300,
easing: tween.easeIn,
onFinish: function onFinish() {
if (self.hasFossil) {
currentLevel.revealFossil(self.fossilType, self.x, self.y);
}
currentLevel.checkBlockCollection();
}
});
};
self.performTrexCollection = function () {
// TREX breaks current block plus 4 surrounding blocks
var blocksToBreak = [self];
var currentIndex = currentLevel.blocks.indexOf(self);
if (currentIndex !== -1) {
var blocksPerRow = 8;
var row = Math.floor(currentIndex / blocksPerRow);
var col = currentIndex % blocksPerRow;
// Add surrounding blocks (up, down, left, right)
var surroundingPositions = [{
row: row - 1,
col: col
},
// up
{
row: row + 1,
col: col
},
// down
{
row: row,
col: col - 1
},
// left
{
row: row,
col: col + 1
} // right
];
for (var i = 0; i < surroundingPositions.length; i++) {
var pos = surroundingPositions[i];
if (pos.row >= 0 && pos.row < 6 && pos.col >= 0 && pos.col < blocksPerRow) {
var blockIndex = pos.row * blocksPerRow + pos.col;
if (blockIndex < currentLevel.blocks.length) {
var block = currentLevel.blocks[blockIndex];
if (!block.isCollected) {
blocksToBreak.push(block);
}
}
}
}
}
// Break all blocks
for (var j = 0; j < blocksToBreak.length; j++) {
blocksToBreak[j].performCollection();
}
};
self.performSpinoCollection = function () {
// SPINO tail strike breaks 3 blocks in a horizontal line
var blocksToBreak = [self];
var currentIndex = currentLevel.blocks.indexOf(self);
if (currentIndex !== -1) {
var blocksPerRow = 8;
var row = Math.floor(currentIndex / blocksPerRow);
var col = currentIndex % blocksPerRow;
// Add 2 blocks to the right
for (var i = 1; i <= 2; i++) {
if (col + i < blocksPerRow) {
var blockIndex = row * blocksPerRow + (col + i);
if (blockIndex < currentLevel.blocks.length) {
var block = currentLevel.blocks[blockIndex];
if (!block.isCollected) {
blocksToBreak.push(block);
}
}
}
}
}
// Break all blocks
for (var j = 0; j < blocksToBreak.length; j++) {
blocksToBreak[j].performCollection();
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x2F4F4F
});
/****
* Game Code
****/
var gameState = 'nickname'; // 'nickname', 'playing'
var playerNickname = storage.playerNickname || '';
var alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
var currentLetterIndex = 0;
var currentLevelNumber = 1;
var currentLevel = null;
var levelTimer = 0;
var leaderboardTexts = [];
// Player data storage - Reset all coins to 0
var playerCoins = 0;
storage.playerCoins = 0;
var playerInventory = storage.playerInventory || [];
var dinosaurCollection = storage.dinosaurCollection || [];
var selectedDinosaur = storage.selectedDinosaur || null;
var xrayLevelsLeft = storage.xrayLevelsLeft || 0;
var doubleMoneyLevelsLeft = storage.doubleMoneyLevelsLeft || 0;
var doubleValueActive = storage.doubleValueActive || false;
var doubleSpawnChanceActive = storage.doubleSpawnChanceActive || false;
var storageUpgradesBought = storage.storageUpgradesBought || 0;
var fossilRarities = {
'fossil1': 'common',
'fossil2': 'common',
'fossil3': 'common',
'rareFossil': 'rare'
};
var fossilValues = {
'fossil1': 10,
'fossil2': 15,
'fossil3': 20,
'rareFossil': 100
};
var dinosaurRarities = {
'PARASOUROLUPHUS': 'common',
'PYTHEREDON': 'common',
'DIMETRODON': 'common',
'BARYONYX': 'rare',
'ALLO': 'rare',
'YUTY': 'rare',
'TREX': 'legendary',
'SPINO': 'legendary',
'GIGA': 'legendary',
'Mutated BARYONYX': 'legendary',
'Mutated DIMETRODON': 'legendary',
'Mutated PARASAUROLUPHUS': 'legendary'
};
// Dinosaur abilities
var dinosaurAbilities = {
'PARASOUROLUPHUS': 'slow_dig',
// Very slow, breaks 1 block at a time
'PYTHEREDON': 'single_fossil',
// Collects only 1 fossil per level regardless of rarity
'DIMETRODON': 'fossil_collector',
// Collects 2 fossils regardless of rarity
'BARYONYX': 'fast_dig_1',
// 0.2x faster mining (20% speed increase)
'YUTY': 'fast_dig_2',
// 0.7x faster mining (70% speed increase)
'ALLO': 'fast_dig_3',
// 0.4x faster mining (40% speed increase)
'TREX': 'area_break',
// Breaks 4 surrounding blocks, 3 uses per level
'SPINO': 'tail_strike',
// Breaks 3 blocks in a line, 1 use per level
'GIGA': 'super_speed',
// 2x mining speed increase
'Mutated BARYONYX': 'ultra_speed',
// 0.9x faster mining (90% speed increase)
'Mutated DIMETRODON': 'top_collector',
// Collects 3 most valuable fossils per level
'Mutated PARASAUROLUPHUS': 'slow_dig'
// Same as regular PARASAUROLUPHUS - very slow mining
};
// Dinosaur egg contents
var commonEggDinosaurs = ['PARASOUROLUPHUS', 'PYTHEREDON', 'DIMETRODON'];
var rareEggDinosaurs = [{
name: 'BARYONYX',
chance: 0.45
}, {
name: 'ALLO',
chance: 0.35
}, {
name: 'YUTY',
chance: 0.20
}];
var legendaryEggDinosaurs = [{
name: 'TREX',
chance: 0.03
}, {
name: 'SPINO',
chance: 0.10
}, {
name: 'GIGA',
chance: 0.15
}, {
name: 'Mutated BARYONYX',
chance: 0.25
}, {
name: 'Mutated DIMETRODON',
chance: 0.17
}, {
name: 'Mutated PARASAUROLUPHUS',
chance: 0.30
}];
function openEgg(eggType) {
var dinosaurName = '';
if (eggType === 'common') {
// Equal chance for all common dinosaurs
dinosaurName = commonEggDinosaurs[Math.floor(Math.random() * commonEggDinosaurs.length)];
} else if (eggType === 'rare') {
// Weighted random selection for rare dinosaurs - apply 2X LUCK if active
var randomValue = Math.random();
var cumulativeChance = 0;
for (var i = 0; i < rareEggDinosaurs.length; i++) {
var currentChance = rareEggDinosaurs[i].chance;
// Apply 2X LUCK effect if active
if (doubleSpawnChanceActive) {
currentChance *= 2;
}
cumulativeChance += currentChance;
if (randomValue <= cumulativeChance) {
dinosaurName = rareEggDinosaurs[i].name;
break;
}
}
} else if (eggType === 'legendary') {
// Weighted random selection for legendary dinosaurs - apply 2X LUCK if active
var randomValue = Math.random();
var cumulativeChance = 0;
for (var i = 0; i < legendaryEggDinosaurs.length; i++) {
var currentChance = legendaryEggDinosaurs[i].chance;
// Apply 2X LUCK effect if active
if (doubleSpawnChanceActive) {
currentChance *= 2;
}
cumulativeChance += currentChance;
if (randomValue <= cumulativeChance) {
dinosaurName = legendaryEggDinosaurs[i].name;
break;
}
}
}
// Reset 2X LUCK effect after use
if (doubleSpawnChanceActive) {
doubleSpawnChanceActive = false;
storage.doubleSpawnChanceActive = doubleSpawnChanceActive;
}
// Add to dinosaur collection
dinosaurCollection.push(dinosaurName);
storage.dinosaurCollection = dinosaurCollection;
// Show congratulations popup
showCongratulationsPopup(dinosaurName);
return dinosaurName;
}
function showCongratulationsPopup(dinosaurName) {
gameState = 'congratulations';
// Hide all current UI
hideAllStoreUI();
hideAllMenuUI();
hideAllGameUI();
// Create congratulations display
var congratsTitle = new Text2('TEBRİKLER!', {
size: 100,
fill: '#FFD700'
});
congratsTitle.anchor.set(0.5, 0.5);
congratsTitle.x = 1024;
congratsTitle.y = 600;
game.addChild(congratsTitle);
infoUIElements.push(congratsTitle);
var winMessage = new Text2('KAZANDINIZ!', {
size: 80,
fill: '#FFFFFF'
});
winMessage.anchor.set(0.5, 0.5);
winMessage.x = 1024;
winMessage.y = 800;
game.addChild(winMessage);
infoUIElements.push(winMessage);
var dinosaurMessage = new Text2(dinosaurName, {
size: 60,
fill: '#32CD32'
});
dinosaurMessage.anchor.set(0.5, 0.5);
dinosaurMessage.x = 1024;
dinosaurMessage.y = 1000;
game.addChild(dinosaurMessage);
infoUIElements.push(dinosaurMessage);
var closeButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
closeButton.x = 1024;
closeButton.y = 1300;
var closeButtonText = new Text2('TAMAM', {
size: 35,
fill: '#FFFFFF'
});
closeButtonText.anchor.set(0.5, 0.5);
closeButtonText.x = 1024;
closeButtonText.y = 1300;
game.addChild(closeButtonText);
infoUIElements.push(closeButton, closeButtonText);
closeButton.down = function () {
hideInfoScreen();
gameState = 'nickname';
showAllMenuUI();
coinsText.setText('Coins: ' + playerCoins);
};
}
// UI Element arrays for different game states
var menuUIElements = [];
var gameUIElements = [];
var storeUIElements = [];
var sellUIElements = [];
var bagUIElements = [];
var infoUIElements = [];
// UI Elements
var nicknameText = new Text2('Enter Nickname: A', {
size: 80,
fill: '#FFFFFF'
});
nicknameText.anchor.set(0.5, 0.5);
nicknameText.x = 1024;
nicknameText.y = 800;
var instructionText = new Text2('Use arrows to select letters, ADD to add, DELETE to remove', {
size: 45,
fill: '#CCCCCC'
});
instructionText.anchor.set(0.5, 0.5);
instructionText.x = 1024;
instructionText.y = 900;
var scoreText = new Text2('Score: 0', {
size: 60,
fill: '#FFFFFF'
});
scoreText.anchor.set(0, 0);
var levelText = new Text2('Level: 1', {
size: 60,
fill: '#FFFFFF'
});
levelText.anchor.set(1, 0);
var timerText = new Text2('Time: 0', {
size: 50,
fill: '#FFFFFF'
});
timerText.anchor.set(0.5, 0);
// Nickname input elements
var leftArrow = game.attachAsset('arrowLeft', {
anchorX: 0.5,
anchorY: 0.5
});
leftArrow.x = 800;
leftArrow.y = 1000;
var rightArrow = game.attachAsset('arrowRight', {
anchorX: 0.5,
anchorY: 0.5
});
rightArrow.x = 1248;
rightArrow.y = 1000;
var startButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
startButton.x = 1024;
startButton.y = 1200;
var startButtonText = new Text2('START', {
size: 40,
fill: '#FFFFFF'
});
startButtonText.anchor.set(0.5, 0.5);
startButtonText.x = 1024;
startButtonText.y = 1200;
var addButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
addButton.x = 900;
addButton.y = 1100;
var addButtonText = new Text2('ADD', {
size: 35,
fill: '#FFFFFF'
});
addButtonText.anchor.set(0.5, 0.5);
addButtonText.x = 900;
addButtonText.y = 1100;
var deleteButton = game.attachAsset('deleteButton', {
anchorX: 0.5,
anchorY: 0.5
});
deleteButton.x = 1148;
deleteButton.y = 1100;
var deleteButtonText = new Text2('DELETE', {
size: 35,
fill: '#FFFFFF'
});
deleteButtonText.anchor.set(0.5, 0.5);
deleteButtonText.x = 1148;
deleteButtonText.y = 1100;
var storeButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
storeButton.x = 700;
storeButton.y = 1300;
var storeButtonText = new Text2('STORE', {
size: 35,
fill: '#FFFFFF'
});
storeButtonText.anchor.set(0.5, 0.5);
storeButtonText.x = 700;
storeButtonText.y = 1300;
var sellButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
sellButton.x = 1348;
sellButton.y = 1300;
var sellButtonText = new Text2('SELL', {
size: 35,
fill: '#FFFFFF'
});
sellButtonText.anchor.set(0.5, 0.5);
sellButtonText.x = 1348;
sellButtonText.y = 1300;
var shopButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
shopButton.x = 1024;
shopButton.y = 1500;
var shopButtonText = new Text2('SHOP', {
size: 35,
fill: '#FFFFFF'
});
shopButtonText.anchor.set(0.5, 0.5);
shopButtonText.x = 1024;
shopButtonText.y = 1500;
var bagButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
bagButton.x = 1024;
bagButton.y = 1600;
var bagButtonText = new Text2('BAG', {
size: 35,
fill: '#FFFFFF'
});
bagButtonText.anchor.set(0.5, 0.5);
bagButtonText.x = 1024;
bagButtonText.y = 1600;
var coinsText = new Text2('Coins: ' + playerCoins, {
size: 50,
fill: '#FFD700'
});
coinsText.anchor.set(0.5, 0.5);
coinsText.x = 1024;
coinsText.y = 1400;
// Add nickname UI to game and track as menu elements
game.addChild(nicknameText);
game.addChild(instructionText);
game.addChild(leftArrow);
game.addChild(rightArrow);
game.addChild(addButton);
game.addChild(addButtonText);
game.addChild(deleteButton);
game.addChild(deleteButtonText);
game.addChild(startButton);
game.addChild(startButtonText);
game.addChild(storeButton);
game.addChild(storeButtonText);
game.addChild(sellButton);
game.addChild(sellButtonText);
game.addChild(shopButton);
game.addChild(shopButtonText);
game.addChild(bagButton);
game.addChild(bagButtonText);
game.addChild(coinsText);
// Track menu UI elements
menuUIElements.push(nicknameText, instructionText, leftArrow, rightArrow, addButton, addButtonText, deleteButton, deleteButtonText, startButton, startButtonText, storeButton, storeButtonText, sellButton, sellButtonText, shopButton, shopButtonText, bagButton, bagButtonText, coinsText);
// Track game UI elements
gameUIElements.push(scoreText, levelText, timerText);
// Add game UI to GUI
LK.gui.topLeft.addChild(scoreText);
scoreText.x = 120;
scoreText.y = 20;
scoreText.visible = false;
LK.gui.topRight.addChild(levelText);
levelText.y = 20;
levelText.visible = false;
LK.gui.top.addChild(timerText);
timerText.y = 100;
timerText.visible = false;
function hideAllMenuUI() {
for (var i = 0; i < menuUIElements.length; i++) {
menuUIElements[i].visible = false;
}
}
function showAllMenuUI() {
for (var i = 0; i < menuUIElements.length; i++) {
menuUIElements[i].visible = true;
}
}
function hideAllGameUI() {
for (var i = 0; i < gameUIElements.length; i++) {
gameUIElements[i].visible = false;
}
}
function showAllGameUI() {
for (var i = 0; i < gameUIElements.length; i++) {
gameUIElements[i].visible = true;
}
}
function hideAllStoreUI() {
for (var i = 0; i < storeUIElements.length; i++) {
storeUIElements[i].destroy();
}
storeUIElements = [];
}
function hideAllSellUI() {
for (var i = 0; i < sellUIElements.length; i++) {
sellUIElements[i].destroy();
}
sellUIElements = [];
}
function hideAllBagUI() {
for (var i = 0; i < bagUIElements.length; i++) {
bagUIElements[i].destroy();
}
bagUIElements = [];
}
function hideAllInfoUI() {
for (var i = 0; i < infoUIElements.length; i++) {
infoUIElements[i].destroy();
}
infoUIElements = [];
}
function updateNicknameDisplay() {
var displayText = 'Enter Nickname: ' + playerNickname + alphabet[currentLetterIndex];
nicknameText.setText(displayText);
}
function startLevel(levelNumber) {
// Clean up previous level
if (currentLevel) {
currentLevel.destroy();
}
currentLevelNumber = levelNumber;
levelTimer = 0;
// Reset PYTHEREDON fossil counter for new level
if (selectedDinosaur === 'PYTHEREDON') {
storage.fossilsCollectedByPytheredon = 0;
}
// Reset legendary dinosaur ability counters for new level
if (selectedDinosaur === 'TREX') {
storage.trexUsesLeft = 3;
}
if (selectedDinosaur === 'SPINO') {
storage.spinoUsesLeft = 1;
}
// Create new level
currentLevel = new Level(levelNumber);
currentLevel.createLevel();
game.addChild(currentLevel);
levelText.setText('Level: ' + levelNumber);
}
function showStore() {
gameState = 'store';
// Hide all menu and game UI elements
hideAllMenuUI();
hideAllGameUI();
// Create store display
var storeTitle = new Text2('FOSSIL STORE', {
size: 80,
fill: '#FFFFFF'
});
storeTitle.anchor.set(0.5, 0.5);
storeTitle.x = 1024;
storeTitle.y = 200;
game.addChild(storeTitle);
storeUIElements.push(storeTitle);
var backButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
backButton.x = 1024;
backButton.y = 1500;
var backButtonText = new Text2('BACK', {
size: 35,
fill: '#FFFFFF'
});
backButtonText.anchor.set(0.5, 0.5);
backButtonText.x = 1024;
backButtonText.y = 1500;
game.addChild(backButtonText);
storeUIElements.push(backButton, backButtonText);
// Sort and display inventory by rarity
var rareFossils = [];
var commonFossils = [];
for (var i = 0; i < playerInventory.length; i++) {
if (fossilRarities[playerInventory[i]] === 'rare') {
rareFossils.push(playerInventory[i]);
} else {
commonFossils.push(playerInventory[i]);
}
}
var allFossils = rareFossils.concat(commonFossils);
var startY = 350;
for (var j = 0; j < allFossils.length; j++) {
var fossilName = allFossils[j];
var rarity = fossilRarities[fossilName];
var color = rarity === 'rare' ? '#FFD700' : '#FFFFFF';
var fossilText = new Text2(fossilName + ' (' + rarity + ')', {
size: 40,
fill: color
});
fossilText.anchor.set(0.5, 0.5);
fossilText.x = 1024;
fossilText.y = startY + j * 60;
game.addChild(fossilText);
storeUIElements.push(fossilText);
}
backButton.down = function () {
hideStore();
};
}
function hideStore() {
gameState = 'nickname';
// Remove all store UI elements
hideAllStoreUI();
// Restore menu UI elements
showAllMenuUI();
}
function showSell() {
gameState = 'sell';
// Hide all menu and game UI elements
hideAllMenuUI();
hideAllGameUI();
// Create sell display
var sellTitle = new Text2('SELL FOSSILS', {
size: 80,
fill: '#FFFFFF'
});
sellTitle.anchor.set(0.5, 0.5);
sellTitle.x = 1024;
sellTitle.y = 200;
game.addChild(sellTitle);
sellUIElements.push(sellTitle);
var sellAllButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
sellAllButton.x = 1024;
sellAllButton.y = 1400;
var sellAllButtonText = new Text2('SELL ALL', {
size: 35,
fill: '#FFFFFF'
});
sellAllButtonText.anchor.set(0.5, 0.5);
sellAllButtonText.x = 1024;
sellAllButtonText.y = 1400;
game.addChild(sellAllButtonText);
sellUIElements.push(sellAllButton, sellAllButtonText);
var sellBackButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
sellBackButton.x = 1024;
sellBackButton.y = 1600;
var sellBackButtonText = new Text2('BACK', {
size: 35,
fill: '#FFFFFF'
});
sellBackButtonText.anchor.set(0.5, 0.5);
sellBackButtonText.x = 1024;
sellBackButtonText.y = 1600;
game.addChild(sellBackButtonText);
// Add 2X MONEY use button
var use2xMoneyButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
use2xMoneyButton.x = 1024;
use2xMoneyButton.y = 1500;
var use2xMoneyButtonText = new Text2('2X MONEY (' + doubleMoneyLevelsLeft + ')', {
size: 35,
fill: '#FFFFFF'
});
use2xMoneyButtonText.anchor.set(0.5, 0.5);
use2xMoneyButtonText.x = 1024;
use2xMoneyButtonText.y = 1500;
game.addChild(use2xMoneyButtonText);
sellUIElements.push(sellBackButton, sellBackButtonText, use2xMoneyButton, use2xMoneyButtonText);
// Calculate total value
var totalValue = 0;
for (var i = 0; i < playerInventory.length; i++) {
var fossilValue = fossilValues[playerInventory[i]];
if (doubleValueActive) {
fossilValue *= 2;
}
totalValue += fossilValue;
}
var totalValueText = new Text2('Total Value: ' + totalValue + ' coins', {
size: 50,
fill: '#FFD700'
});
totalValueText.anchor.set(0.5, 0.5);
totalValueText.x = 1024;
totalValueText.y = 300;
game.addChild(totalValueText);
sellUIElements.push(totalValueText);
sellAllButton.down = function () {
playerCoins += totalValue;
playerInventory = [];
// Reset 2X VALUE effect after use
if (doubleValueActive) {
doubleValueActive = false;
storage.doubleValueActive = doubleValueActive;
}
storage.playerCoins = playerCoins;
storage.playerInventory = playerInventory;
hideSell();
};
use2xMoneyButton.down = function () {
if (doubleMoneyLevelsLeft > 0) {
// Activate 2X MONEY effect for selling
doubleValueActive = true;
storage.doubleValueActive = doubleValueActive;
// Update button text to show remaining uses
use2xMoneyButtonText.setText('2X MONEY (' + doubleMoneyLevelsLeft + ')');
// Recalculate and update total value display
var newTotalValue = 0;
for (var i = 0; i < playerInventory.length; i++) {
var fossilValue = fossilValues[playerInventory[i]];
if (doubleValueActive) {
fossilValue *= 2;
}
newTotalValue += fossilValue;
}
totalValueText.setText('Total Value: ' + newTotalValue + ' coins');
}
};
sellBackButton.down = function () {
hideSell();
};
}
function hideSell() {
gameState = 'nickname';
// Remove all sell UI elements
hideAllSellUI();
// Restore menu UI elements
showAllMenuUI();
coinsText.setText('Coins: ' + playerCoins);
}
function showShop() {
gameState = 'shop';
// Hide all menu and game UI elements
hideAllMenuUI();
hideAllGameUI();
// Create shop display
var shopTitle = new Text2('POWER-UP SHOP', {
size: 80,
fill: '#FFFFFF'
});
shopTitle.anchor.set(0.5, 0.5);
shopTitle.x = 1024;
shopTitle.y = 200;
game.addChild(shopTitle);
storeUIElements.push(shopTitle);
// XRAY Power-up
var xrayButton = game.attachAsset('purchaseButton', {
anchorX: 0.5,
anchorY: 0.5
});
xrayButton.x = 1024;
xrayButton.y = 400;
var xrayText = new Text2('XRAY - 500 Coins\nReveals all fossils for 1 level', {
size: 35,
fill: '#FFFFFF'
});
xrayText.anchor.set(0.5, 0.5);
xrayText.x = 1024;
xrayText.y = 400;
// 2X MONEY Power-up
var doubleMoneyButton = game.attachAsset('purchaseButton', {
anchorX: 0.5,
anchorY: 0.5
});
doubleMoneyButton.x = 1024;
doubleMoneyButton.y = 550;
var doubleMoneyText = new Text2('2X MONEY - 10000 Coins\nDouble money for 20 levels', {
size: 35,
fill: '#FFFFFF'
});
doubleMoneyText.anchor.set(0.5, 0.5);
doubleMoneyText.x = 1024;
doubleMoneyText.y = 550;
// 2X VALUE Power-up
var doubleValueButton = game.attachAsset('purchaseButton', {
anchorX: 0.5,
anchorY: 0.5
});
doubleValueButton.x = 1024;
doubleValueButton.y = 700;
var doubleValueText = new Text2('2X LUCK - 1250 Coins\nDouble egg chances', {
size: 35,
fill: '#FFFFFF'
});
doubleValueText.anchor.set(0.5, 0.5);
doubleValueText.x = 1024;
doubleValueText.y = 700;
// +1 STORAGE Power-up
var storageButton = game.attachAsset('purchaseButton', {
anchorX: 0.5,
anchorY: 0.5
});
storageButton.x = 1024;
storageButton.y = 850;
var storageUpgradesBought = storage.storageUpgradesBought || 0;
var storageText = new Text2('+1 SELECT - 100000 Coins\nAdd 1 dinosaur slot (' + storageUpgradesBought + '/4)', {
size: 35,
fill: '#FFFFFF'
});
storageText.anchor.set(0.5, 0.5);
storageText.x = 1024;
storageText.y = 850;
// +1 SELECT Pass Power-up
var passButton = game.attachAsset('purchaseButton', {
anchorX: 0.5,
anchorY: 0.5
});
passButton.x = 1024;
passButton.y = 1000;
var passText = new Text2('+1 SELECT - 50000 Coins\nAdd 1 extra selection slot', {
size: 35,
fill: '#FFFFFF'
});
passText.anchor.set(0.5, 0.5);
passText.x = 1024;
passText.y = 1000;
// Common Egg
var commonEggButton = game.attachAsset('purchaseButton', {
anchorX: 0.5,
anchorY: 0.5
});
commonEggButton.x = 1024;
commonEggButton.y = 1400;
var commonEggText = new Text2('Sıradan Yumurta - 500 Coins\nCommon fossil guaranteed', {
size: 35,
fill: '#FFFFFF'
});
commonEggText.anchor.set(0.5, 0.5);
commonEggText.x = 1024;
commonEggText.y = 1400;
// Common Egg Info Button
var commonEggInfoButton = new Text2('❗', {
size: 60,
fill: '#FFD700'
});
commonEggInfoButton.anchor.set(0.5, 0.5);
commonEggInfoButton.x = 1350;
commonEggInfoButton.y = 1400;
game.addChild(commonEggInfoButton);
// Rare Egg
var rareEggButton = game.attachAsset('purchaseButton', {
anchorX: 0.5,
anchorY: 0.5
});
rareEggButton.x = 1024;
rareEggButton.y = 1550;
var rareEggText = new Text2('Nadir Yumurta - 2000 Coins\nRare fossil guaranteed', {
size: 35,
fill: '#FFD700'
});
rareEggText.anchor.set(0.5, 0.5);
rareEggText.x = 1024;
rareEggText.y = 1550;
// Rare Egg Info Button
var rareEggInfoButton = new Text2('❗', {
size: 60,
fill: '#FFD700'
});
rareEggInfoButton.anchor.set(0.5, 0.5);
rareEggInfoButton.x = 1350;
rareEggInfoButton.y = 1550;
game.addChild(rareEggInfoButton);
// Legendary Egg
var legendaryEggButton = game.attachAsset('purchaseButton', {
anchorX: 0.5,
anchorY: 0.5
});
legendaryEggButton.x = 1024;
legendaryEggButton.y = 1700;
var legendaryEggText = new Text2('Destansı - 10000 Coins\nLegendary guaranteed', {
size: 35,
fill: '#FF69B4'
});
legendaryEggText.anchor.set(0.5, 0.5);
legendaryEggText.x = 1024;
legendaryEggText.y = 1700;
// Legendary Egg Info Button
var legendaryEggInfoButton = new Text2('❗', {
size: 60,
fill: '#FFD700'
});
legendaryEggInfoButton.anchor.set(0.5, 0.5);
legendaryEggInfoButton.x = 1350;
legendaryEggInfoButton.y = 1700;
game.addChild(legendaryEggInfoButton);
// Back button
var shopBackButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
shopBackButton.x = 1024;
shopBackButton.y = 1200;
var shopBackButtonText = new Text2('BACK', {
size: 35,
fill: '#FFFFFF'
});
shopBackButtonText.anchor.set(0.5, 0.5);
shopBackButtonText.x = 1024;
shopBackButtonText.y = 1200;
game.addChild(xrayText);
game.addChild(doubleMoneyText);
game.addChild(doubleValueText);
game.addChild(commonEggText);
game.addChild(rareEggText);
game.addChild(legendaryEggText);
game.addChild(shopBackButtonText);
game.addChild(storageText);
game.addChild(passText);
storeUIElements.push(xrayButton, xrayText, doubleMoneyButton, doubleMoneyText, doubleValueButton, doubleValueText, storageButton, storageText, passButton, passText, commonEggButton, commonEggText, commonEggInfoButton, rareEggButton, rareEggText, rareEggInfoButton, legendaryEggButton, legendaryEggText, legendaryEggInfoButton, shopBackButton, shopBackButtonText);
// Purchase handlers
xrayButton.down = function () {
if (playerCoins >= 500) {
playerCoins -= 500;
storage.playerCoins = playerCoins;
xrayLevelsLeft++;
storage.xrayLevelsLeft = xrayLevelsLeft;
hideShop();
}
};
doubleMoneyButton.down = function () {
if (playerCoins >= 10000) {
playerCoins -= 10000;
storage.playerCoins = playerCoins;
doubleMoneyLevelsLeft += 20;
storage.doubleMoneyLevelsLeft = doubleMoneyLevelsLeft;
hideShop();
}
};
doubleValueButton.down = function () {
if (playerCoins >= 1250) {
playerCoins -= 1250;
storage.playerCoins = playerCoins;
doubleSpawnChanceActive = true;
storage.doubleSpawnChanceActive = doubleSpawnChanceActive;
hideShop();
}
};
storageButton.down = function () {
var storageUpgradesBought = storage.storageUpgradesBought || 0;
if (storageUpgradesBought < 4 && playerCoins >= 100000) {
playerCoins -= 100000;
storage.playerCoins = playerCoins;
storageUpgradesBought++;
storage.storageUpgradesBought = storageUpgradesBought;
hideShop();
}
};
passButton.down = function () {
if (playerCoins >= 50000) {
playerCoins -= 50000;
storage.playerCoins = playerCoins;
var passPurchases = storage.passPurchases || 0;
passPurchases++;
storage.passPurchases = passPurchases;
hideShop();
}
};
// Common egg info handler
commonEggInfoButton.down = function () {
showCommonEggInfo();
};
// Egg purchase handlers
commonEggButton.down = function () {
if (playerCoins >= 500) {
playerCoins -= 500;
storage.playerCoins = playerCoins;
// Open common egg and get dinosaur
var dinosaurName = openEgg('common');
}
};
// Rare egg info handler
rareEggInfoButton.down = function () {
showRareEggInfo();
};
rareEggButton.down = function () {
if (playerCoins >= 2000) {
playerCoins -= 2000;
storage.playerCoins = playerCoins;
// Open rare egg and get dinosaur
var dinosaurName = openEgg('rare');
}
};
// Legendary egg info handler
legendaryEggInfoButton.down = function () {
showLegendaryEggInfo();
};
legendaryEggButton.down = function () {
if (playerCoins >= 10000) {
playerCoins -= 10000;
storage.playerCoins = playerCoins;
// Open legendary egg and get dinosaur
var dinosaurName = openEgg('legendary');
}
};
shopBackButton.down = function () {
hideShop();
};
}
function hideShop() {
gameState = 'nickname';
// Remove all shop UI elements
hideAllStoreUI();
// Restore menu UI elements
showAllMenuUI();
coinsText.setText('Coins: ' + playerCoins);
}
function showBag() {
gameState = 'bag';
// Hide all menu and game UI elements
hideAllMenuUI();
hideAllGameUI();
// Create bag display
var bagTitle = new Text2('DINOSAUR BAG', {
size: 80,
fill: '#FFFFFF'
});
bagTitle.anchor.set(0.5, 0.5);
bagTitle.x = 1024;
bagTitle.y = 200;
game.addChild(bagTitle);
bagUIElements.push(bagTitle);
// Calculate vomit limit (1 base + upgrades bought + pass purchases)
var passPurchases = storage.passPurchases || 0;
var maxVomitSlots = 1 + (storage.storageUpgradesBought || 0) + passPurchases;
var baseSlots = 1 + (storage.storageUpgradesBought || 0);
var passSlots = storage.passPurchases || 0;
var vomitText = new Text2('Select Slots: ' + maxVomitSlots + ' available (Base: ' + baseSlots + ' + Pass: ' + passSlots + ')', {
size: 35,
fill: '#FFD700'
});
vomitText.anchor.set(0.5, 0.5);
vomitText.x = 1024;
vomitText.y = 280;
game.addChild(vomitText);
bagUIElements.push(vomitText);
// Sort dinosaurs by rarity
var legendaryDinos = [];
var rareDinos = [];
var commonDinos = [];
for (var i = 0; i < dinosaurCollection.length; i++) {
var dino = dinosaurCollection[i];
var rarity = dinosaurRarities[dino];
if (rarity === 'legendary') {
legendaryDinos.push(dino);
} else if (rarity === 'rare') {
rareDinos.push(dino);
} else {
commonDinos.push(dino);
}
}
var allDinos = legendaryDinos.concat(rareDinos).concat(commonDinos);
// Convert selectedDinosaur to array if needed for multiple selection support
var selectedDinosaurs = [];
if (storage.selectedDinosaurs && Array.isArray(storage.selectedDinosaurs)) {
selectedDinosaurs = storage.selectedDinosaurs;
} else if (selectedDinosaur) {
selectedDinosaurs = [selectedDinosaur];
}
// Display all dinosaurs - unlimited storage, but limited vomit selection
var startY = 350;
for (var j = 0; j < allDinos.length; j++) {
var dinoName = allDinos[j];
var rarity = dinosaurRarities[dinoName];
var color = '#87CEEB'; // Light blue for common/regular dinosaurs
if (rarity === 'legendary') color = '#FF0000'; // Red for legendary
else if (rarity === 'rare') color = '#800080'; // Purple for rare
else if (rarity === 'common') color = '#00008B'; // Dark blue for common
var isSelected = selectedDinosaurs.indexOf(dinoName) !== -1;
var displayText = dinoName + ' (' + rarity + ')' + (isSelected ? ' [SELECTED]' : '');
var dinoButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
dinoButton.x = 1024;
dinoButton.y = startY + j * 80;
var dinoText = new Text2(displayText, {
size: 35,
fill: isSelected ? '#000000' : color
});
dinoText.anchor.set(0.5, 0.5);
dinoText.x = 1024;
dinoText.y = startY + j * 80;
game.addChild(dinoText);
bagUIElements.push(dinoButton, dinoText);
// Create closure for selection - check vomit limit
(function (dinosaurName) {
dinoButton.down = function () {
var currentIndex = selectedDinosaurs.indexOf(dinosaurName);
if (currentIndex !== -1) {
// Remove from selection
selectedDinosaurs.splice(currentIndex, 1);
} else if (selectedDinosaurs.length < maxVomitSlots) {
// Add to selection if under vomit limit
selectedDinosaurs.push(dinosaurName);
}
// Update storage and backward compatibility
storage.selectedDinosaurs = selectedDinosaurs;
if (selectedDinosaurs.length > 0) {
selectedDinosaur = selectedDinosaurs[0]; // Keep backward compatibility
storage.selectedDinosaur = selectedDinosaur;
} else {
selectedDinosaur = null;
storage.selectedDinosaur = null;
}
hideBag();
};
})(dinoName);
}
// Back button
// Delete button
var deleteButton = game.attachAsset('deleteButton', {
anchorX: 0.5,
anchorY: 0.5
});
deleteButton.x = 700;
deleteButton.y = 1500;
var deleteButtonText = new Text2('DELETE', {
size: 35,
fill: '#FFFFFF'
});
deleteButtonText.anchor.set(0.5, 0.5);
deleteButtonText.x = 700;
deleteButtonText.y = 1500;
game.addChild(deleteButtonText);
bagUIElements.push(deleteButton, deleteButtonText);
var bagBackButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
bagBackButton.x = 1348;
bagBackButton.y = 1500;
var bagBackButtonText = new Text2('BACK', {
size: 35,
fill: '#FFFFFF'
});
bagBackButtonText.anchor.set(0.5, 0.5);
bagBackButtonText.x = 1348;
bagBackButtonText.y = 1500;
game.addChild(bagBackButtonText);
bagUIElements.push(bagBackButton, bagBackButtonText);
// Delete button handler
deleteButton.down = function () {
showDeleteMode();
};
bagBackButton.down = function () {
hideBag();
};
}
function showDeleteMode() {
gameState = 'deleteMode';
// Hide current bag UI
hideAllBagUI();
// Create delete mode display
var deleteTitle = new Text2('DELETE DINOSAURS', {
size: 80,
fill: '#FF4444'
});
deleteTitle.anchor.set(0.5, 0.5);
deleteTitle.x = 1024;
deleteTitle.y = 200;
game.addChild(deleteTitle);
bagUIElements.push(deleteTitle);
var deleteInstructionText = new Text2('Select dinosaurs to delete:', {
size: 50,
fill: '#FFFFFF'
});
deleteInstructionText.anchor.set(0.5, 0.5);
deleteInstructionText.x = 1024;
deleteInstructionText.y = 280;
game.addChild(deleteInstructionText);
bagUIElements.push(deleteInstructionText);
// Sort dinosaurs by rarity for display
var legendaryDinos = [];
var rareDinos = [];
var commonDinos = [];
for (var i = 0; i < dinosaurCollection.length; i++) {
var dino = dinosaurCollection[i];
var rarity = dinosaurRarities[dino];
if (rarity === 'legendary') {
legendaryDinos.push(dino);
} else if (rarity === 'rare') {
rareDinos.push(dino);
} else {
commonDinos.push(dino);
}
}
var allDinos = legendaryDinos.concat(rareDinos).concat(commonDinos);
// Track selected dinosaurs for deletion
var selectedForDeletion = [];
// Display all dinosaurs with delete option
var startY = 350;
for (var j = 0; j < allDinos.length; j++) {
var dinoName = allDinos[j];
var rarity = dinosaurRarities[dinoName];
var color = '#87CEEB'; // Light blue for common/regular dinosaurs
if (rarity === 'legendary') color = '#FF0000'; // Red for legendary
else if (rarity === 'rare') color = '#800080'; // Purple for rare
else if (rarity === 'common') color = '#00008B'; // Dark blue for common
var isSelectedForDeletion = selectedForDeletion.indexOf(dinoName) !== -1;
var displayText = dinoName + ' (' + rarity + ')' + (isSelectedForDeletion ? ' [TO DELETE]' : '');
var dinoButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
dinoButton.x = 1024;
dinoButton.y = startY + j * 80;
var dinoText = new Text2(displayText, {
size: 35,
fill: isSelectedForDeletion ? '#FF4444' : color
});
dinoText.anchor.set(0.5, 0.5);
dinoText.x = 1024;
dinoText.y = startY + j * 80;
game.addChild(dinoText);
bagUIElements.push(dinoButton, dinoText);
// Create closure for selection toggle
(function (dinosaurName, textElement) {
dinoButton.down = function () {
var index = selectedForDeletion.indexOf(dinosaurName);
if (index === -1) {
// Add to deletion list
selectedForDeletion.push(dinosaurName);
textElement.setText(dinosaurName + ' (' + dinosaurRarities[dinosaurName] + ') [TO DELETE]');
textElement.fill = '#FF4444';
} else {
// Remove from deletion list
selectedForDeletion.splice(index, 1);
var rarity = dinosaurRarities[dinosaurName];
var color = '#87CEEB'; // Light blue for common/regular dinosaurs
if (rarity === 'legendary') color = '#FF0000'; // Red for legendary
else if (rarity === 'rare') color = '#800080'; // Purple for rare
else if (rarity === 'common') color = '#00008B'; // Dark blue for common
textElement.setText(dinosaurName + ' (' + rarity + ')');
textElement.fill = color;
}
};
})(dinoName, dinoText);
}
// Confirm delete button
var confirmDeleteButton = game.attachAsset('deleteButton', {
anchorX: 0.5,
anchorY: 0.5
});
confirmDeleteButton.x = 700;
confirmDeleteButton.y = 1500;
var confirmDeleteText = new Text2('CONFIRM DELETE', {
size: 30,
fill: '#FFFFFF'
});
confirmDeleteText.anchor.set(0.5, 0.5);
confirmDeleteText.x = 700;
confirmDeleteText.y = 1500;
game.addChild(confirmDeleteText);
bagUIElements.push(confirmDeleteButton, confirmDeleteText);
// Cancel delete button
var cancelDeleteButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
cancelDeleteButton.x = 1348;
cancelDeleteButton.y = 1500;
var cancelDeleteText = new Text2('CANCEL', {
size: 35,
fill: '#FFFFFF'
});
cancelDeleteText.anchor.set(0.5, 0.5);
cancelDeleteText.x = 1348;
cancelDeleteText.y = 1500;
game.addChild(cancelDeleteText);
bagUIElements.push(cancelDeleteButton, cancelDeleteText);
// Event handlers
confirmDeleteButton.down = function () {
// Remove selected dinosaurs from collection
for (var i = 0; i < selectedForDeletion.length; i++) {
var dinoToDelete = selectedForDeletion[i];
var index = dinosaurCollection.indexOf(dinoToDelete);
if (index !== -1) {
dinosaurCollection.splice(index, 1);
// If deleted dinosaur was selected, clear selection
if (selectedDinosaur === dinoToDelete) {
selectedDinosaur = null;
storage.selectedDinosaur = null;
}
}
}
// Save updated collection
storage.dinosaurCollection = dinosaurCollection;
// Return to bag view
hideAllBagUI();
showBag();
};
cancelDeleteButton.down = function () {
// Return to bag view without deleting
hideAllBagUI();
showBag();
};
}
function hideBag() {
gameState = 'nickname';
// Remove all bag UI elements
hideAllBagUI();
// Restore menu UI elements
showAllMenuUI();
}
function showCommonEggInfo() {
gameState = 'commonEggInfo';
// Hide all shop UI elements
hideAllStoreUI();
// Create info display
var infoTitle = new Text2('SIRADAN YUMURTA İÇERİĞİ', {
size: 60,
fill: '#FFFFFF'
});
infoTitle.anchor.set(0.5, 0.5);
infoTitle.x = 1024;
infoTitle.y = 200;
game.addChild(infoTitle);
infoUIElements.push(infoTitle);
var infoText = 'PARASOUROLUPHUS - %33.33\n';
infoText += 'Yavaş kazma (1 saniye gecikme)\n\n';
infoText += 'PYTHEREDON - %33.33\n';
infoText += 'Seviye başı sadece 1 fosil alır\n\n';
infoText += 'DIMETRODON - %33.33\n';
infoText += 'Nadirlık fark etmez 2 fosil alır';
var infoDisplay = new Text2(infoText, {
size: 40,
fill: '#FFFFFF'
});
infoDisplay.anchor.set(0.5, 0.5);
infoDisplay.x = 1024;
infoDisplay.y = 600;
game.addChild(infoDisplay);
infoUIElements.push(infoDisplay);
var backButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
backButton.x = 1024;
backButton.y = 1200;
var backButtonText = new Text2('BACK', {
size: 35,
fill: '#FFFFFF'
});
backButtonText.anchor.set(0.5, 0.5);
backButtonText.x = 1024;
backButtonText.y = 1200;
game.addChild(backButtonText);
infoUIElements.push(backButton, backButtonText);
backButton.down = function () {
hideInfoScreen();
showShop();
};
}
function showRareEggInfo() {
gameState = 'rareEggInfo';
// Hide all shop UI elements
hideAllStoreUI();
// Create info display
var infoTitle = new Text2('NADİR YUMURTA İÇERİĞİ', {
size: 60,
fill: '#FFFFFF'
});
infoTitle.anchor.set(0.5, 0.5);
infoTitle.x = 1024;
infoTitle.y = 200;
game.addChild(infoTitle);
infoUIElements.push(infoTitle);
var infoText = 'BARYONYX - %45\n';
infoText += '0.2x daha hızlı kaya kazma\n\n';
infoText += 'ALLO - %35\n';
infoText += '0.4x daha hızlı kaya kazma\n\n';
infoText += 'YUTY - %20\n';
infoText += '0.7x daha hızlı kaya kazma';
var infoDisplay = new Text2(infoText, {
size: 40,
fill: '#FFFFFF'
});
infoDisplay.anchor.set(0.5, 0.5);
infoDisplay.x = 1024;
infoDisplay.y = 600;
game.addChild(infoDisplay);
infoUIElements.push(infoDisplay);
var backButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
backButton.x = 1024;
backButton.y = 1200;
var backButtonText = new Text2('BACK', {
size: 35,
fill: '#FFFFFF'
});
backButtonText.anchor.set(0.5, 0.5);
backButtonText.x = 1024;
backButtonText.y = 1200;
game.addChild(backButtonText);
infoUIElements.push(backButton, backButtonText);
backButton.down = function () {
hideInfoScreen();
showShop();
};
}
function showLegendaryEggInfo() {
gameState = 'legendaryEggInfo';
// Hide all shop UI elements
hideAllStoreUI();
// Create info display
var infoTitle = new Text2('DESTANSI YUMURTA İÇERİĞİ', {
size: 60,
fill: '#FFFFFF'
});
infoTitle.anchor.set(0.5, 0.5);
infoTitle.x = 1024;
infoTitle.y = 200;
game.addChild(infoTitle);
infoUIElements.push(infoTitle);
var infoText = 'TREX - %3\n';
infoText += 'Etraftaki 4 kayayı kırar (3 kullanım)\n\n';
infoText += 'SPINO - %10\n';
infoText += 'Kuyruk darbesi 3 kaya kırar (1 kullanım)\n\n';
infoText += 'GIGA - %15\n';
infoText += 'Kaya kırma hızı 2x artar\n\n';
infoText += 'Mutasyonlu BARYONYX - %25\n';
infoText += 'Kaya kırma 0.9x daha hızlı\n\n';
infoText += 'Mutasyonlu DIMETRODON - %17\n';
infoText += 'En değerli 3 fosili alır\n\n';
infoText += 'Mutasyonlu PARASAUROLUPHUS - %30\n';
infoText += 'Hızlı blok kırma (2 saniye)';
var infoDisplay = new Text2(infoText, {
size: 30,
fill: '#FFFFFF'
});
infoDisplay.anchor.set(0.5, 0.5);
infoDisplay.x = 1024;
infoDisplay.y = 700;
game.addChild(infoDisplay);
infoUIElements.push(infoDisplay);
var backButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
backButton.x = 1024;
backButton.y = 1200;
var backButtonText = new Text2('BACK', {
size: 35,
fill: '#FFFFFF'
});
backButtonText.anchor.set(0.5, 0.5);
backButtonText.x = 1024;
backButtonText.y = 1200;
game.addChild(backButtonText);
infoUIElements.push(backButton, backButtonText);
backButton.down = function () {
hideInfoScreen();
showShop();
};
}
function hideInfoScreen() {
// Remove all info UI elements
hideAllInfoUI();
}
function startGame() {
if (playerNickname.length === 0) {
return;
}
storage.playerNickname = playerNickname;
gameState = 'playing';
// Hide menu UI elements
hideAllMenuUI();
// Show game UI elements
timerText.visible = true;
scoreText.visible = true;
levelText.visible = true;
// Show power-up purchase options
purchaseOption1.visible = true;
purchaseText1.visible = true;
purchaseOption2.visible = true;
purchaseText2.visible = true;
purchaseOption3.visible = true;
purchaseText3.visible = true;
// Show XRAY use button
xrayUseButton.visible = true;
xrayUseText.visible = true;
xrayUseText.setText('XRAY (' + xrayLevelsLeft + ')');
// Show back to menu button
backToMenuButton.visible = true;
backToMenuText.visible = true;
// Start first level
startLevel(1);
}
// Event handlers
leftArrow.down = function (x, y, obj) {
if (gameState !== 'nickname') {
return;
}
currentLetterIndex = (currentLetterIndex - 1 + alphabet.length) % alphabet.length;
updateNicknameDisplay();
};
rightArrow.down = function (x, y, obj) {
if (gameState !== 'nickname') {
return;
}
currentLetterIndex = (currentLetterIndex + 1) % alphabet.length;
updateNicknameDisplay();
};
addButton.down = function (x, y, obj) {
if (gameState !== 'nickname') {
return;
}
// Add current letter to nickname
if (playerNickname.length < 12) {
playerNickname += alphabet[currentLetterIndex];
updateNicknameDisplay();
}
};
startButton.down = function (x, y, obj) {
if (gameState !== 'nickname') {
return;
}
startGame();
};
deleteButton.down = function (x, y, obj) {
if (gameState !== 'nickname') {
return;
}
if (playerNickname.length > 0) {
playerNickname = playerNickname.slice(0, -1);
updateNicknameDisplay();
}
};
storeButton.down = function (x, y, obj) {
if (gameState !== 'nickname') {
return;
}
showStore();
};
sellButton.down = function (x, y, obj) {
if (gameState !== 'nickname') {
return;
}
showSell();
};
shopButton.down = function (x, y, obj) {
if (gameState !== 'nickname') {
return;
}
showShop();
};
bagButton.down = function (x, y, obj) {
if (gameState !== 'nickname') {
return;
}
showBag();
};
game.down = function (x, y, obj) {
// Game down handler for playing state only
};
// Game update loop
game.update = function () {
if (gameState === 'playing') {
levelTimer++;
timerText.setText('Time: ' + Math.floor(levelTimer / 60));
// Slowly decrease score over time to encourage speed
if (levelTimer % 120 === 0 && LK.getScore() > 0) {
// Every 2 seconds
LK.setScore(Math.max(0, LK.getScore() - 1));
scoreText.setText('Score: ' + LK.getScore());
}
}
};
// Power-up purchase options (shown when game is playing)
var purchaseOption1 = game.attachAsset('purchaseButton', {
anchorX: 0.5,
anchorY: 0.5
});
purchaseOption1.x = 1800;
purchaseOption1.y = 400;
purchaseOption1.visible = false;
var purchaseText1 = new Text2('XRAY\n500 Coins', {
size: 30,
fill: '#FFFFFF'
});
purchaseText1.anchor.set(0.5, 0.5);
purchaseText1.x = 1800;
purchaseText1.y = 400;
purchaseText1.visible = false;
game.addChild(purchaseText1);
var purchaseOption2 = game.attachAsset('purchaseButton', {
anchorX: 0.5,
anchorY: 0.5
});
purchaseOption2.x = 1800;
purchaseOption2.y = 520;
purchaseOption2.visible = false;
var purchaseText2 = new Text2('2X MONEY\n10000 Coins', {
size: 30,
fill: '#FFFFFF'
});
purchaseText2.anchor.set(0.5, 0.5);
purchaseText2.x = 1800;
purchaseText2.y = 520;
purchaseText2.visible = false;
game.addChild(purchaseText2);
var purchaseOption3 = game.attachAsset('purchaseButton', {
anchorX: 0.5,
anchorY: 0.5
});
purchaseOption3.x = 1800;
purchaseOption3.y = 640;
purchaseOption3.visible = false;
var purchaseText3 = new Text2('2X LUCK\n1250', {
size: 30,
fill: '#FFFFFF'
});
purchaseText3.anchor.set(0.5, 0.5);
purchaseText3.x = 1800;
purchaseText3.y = 640;
purchaseText3.visible = false;
game.addChild(purchaseText3);
// Track purchase UI elements as game UI
gameUIElements.push(purchaseOption1, purchaseText1, purchaseOption2, purchaseText2, purchaseOption3, purchaseText3);
// Purchase event handlers
purchaseOption1.down = function (x, y, obj) {
if (gameState === 'playing' && playerCoins >= 500) {
playerCoins -= 500;
storage.playerCoins = playerCoins;
xrayLevelsLeft++;
storage.xrayLevelsLeft = xrayLevelsLeft;
xrayUseText.setText('XRAY (' + xrayLevelsLeft + ')');
// Show all fossils for current level
if (currentLevel) {
for (var i = 0; i < currentLevel.blocks.length; i++) {
var block = currentLevel.blocks[i];
if (block.hasFossil && !block.isCollected) {
block.alpha = 0.5; // Make blocks with fossils semi-transparent
}
}
}
}
};
purchaseOption2.down = function (x, y, obj) {
if (gameState === 'playing' && playerCoins >= 10000) {
playerCoins -= 10000;
storage.playerCoins = playerCoins;
doubleMoneyLevelsLeft = 20;
storage.doubleMoneyLevelsLeft = doubleMoneyLevelsLeft;
}
};
purchaseOption3.down = function (x, y, obj) {
if (gameState === 'playing' && playerCoins >= 1250) {
playerCoins -= 1250;
storage.playerCoins = playerCoins;
doubleSpawnChanceActive = true;
storage.doubleSpawnChanceActive = doubleSpawnChanceActive;
}
};
// XRAY use button (shown when game is playing)
var xrayUseButton = game.attachAsset('purchaseButton', {
anchorX: 0.5,
anchorY: 0.5
});
xrayUseButton.x = 624; // Further left side of bottom center
xrayUseButton.y = 2500; // Bottom of screen
xrayUseButton.visible = false;
var xrayUseText = new Text2('XRAY (' + xrayLevelsLeft + ')', {
size: 30,
fill: '#FFFFFF'
});
xrayUseText.anchor.set(0.5, 0.5);
xrayUseText.x = 624;
xrayUseText.y = 2500;
xrayUseText.visible = false;
game.addChild(xrayUseText);
// Back to menu button (shown when game is playing)
var backToMenuButton = game.attachAsset('purchaseButton', {
anchorX: 0.5,
anchorY: 0.5
});
backToMenuButton.x = 1424; // Further right side of bottom center
backToMenuButton.y = 2500; // Bottom of screen, same level as XRAY
backToMenuButton.visible = false;
var backToMenuText = new Text2('MENÜYE GERİ DÖN', {
size: 25,
fill: '#FFFFFF'
});
backToMenuText.anchor.set(0.5, 0.5);
backToMenuText.x = 1424;
backToMenuText.y = 2500;
backToMenuText.visible = false;
game.addChild(backToMenuText);
// Track XRAY use and back to menu UI elements as game UI
gameUIElements.push(xrayUseButton, xrayUseText, backToMenuButton, backToMenuText);
// XRAY use button click handler
xrayUseButton.down = function (x, y, obj) {
if (gameState === 'playing' && xrayLevelsLeft > 0) {
xrayLevelsLeft--;
storage.xrayLevelsLeft = xrayLevelsLeft;
xrayUseText.setText('XRAY (' + xrayLevelsLeft + ')');
// Show all fossils for current level
if (currentLevel) {
for (var i = 0; i < currentLevel.blocks.length; i++) {
var block = currentLevel.blocks[i];
if (block.hasFossil && !block.isCollected) {
block.alpha = 0.5; // Make blocks with fossils semi-transparent
}
}
}
}
};
// Back to menu button click handler
backToMenuButton.down = function (x, y, obj) {
if (gameState === 'playing') {
// Clean up current level
if (currentLevel) {
currentLevel.destroy();
currentLevel = null;
}
// Reset game state
gameState = 'nickname';
// Hide game UI elements
hideAllGameUI();
// Show menu UI elements
showAllMenuUI();
}
};
// Initialize display
updateNicknameDisplay();
coinsText.setText('Coins: ' + playerCoins);
// Start background music
LK.playMusic('backgroundMusic');