User prompt
GİFTS kısmına birde indirimli teklifler ekle her gün indirimli teklifler değişsin ve indirimli teklifte yan yana 3 farklı teklif olsun ayrıca GİFTS sekmesinin en altında olsunlar %50 ilan %20 arası indirimli olsun ürünler ama bu ürün yumurtada olabilir game pass te
User prompt
2xmoney gamepassinin fiyatını 3250 yap özelliğini değiştir özelliği ise toplanan tüm fosillerden 2 kat daha fazla kazanılır olsun ve her hangi zamanda kullanıla bilsin
User prompt
Spinonun özelliğini değiştirmek spinonun özelliği ile harita altındaki fosil olan 3 yayılan uada sertleşen yada aşırı sert yayılan kıralım
User prompt
Spinonun özelliğini değiştir spinonun özelliği ile maptaki altında fosil olan 3 bloğu uada sert bloğu yada aşırı sert bloğu kıralım
User prompt
Spino kuyruk darbesi ile yan yana olan tüm 3 bloğu kırsın
User prompt
Spinonun özelliği maptaki yan yana olan tüm 3 blokları kırsın yani aşırı sert ve sert bloğuda kırsın
User prompt
Gift sekmesine haftalık yem ödülü ekle yani günlük hediyelerin yem versiyonu ilk gün tüm yemlerden 1 paket 2. Gün tüm yemlerden 2 paket paket 3. Gün tüm yemlerden 3 paket 4. Gün tüm yemlerden 5 paket 5. Gün tüm yemlerden 7 paket er 6. Gün tüm yemlerden 8 paket 7. Gün tüm yemlerden 10 paket ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Biraz daha aşağıya insinler
User prompt
Bag sekmesinde dinozrlar ve Delete ile BACK yazısı biraz aşağı heksin
User prompt
Her dinozor farklı bir zamanda aciksin TREX GİGA ve SPİNO her 2 günde 1 kere mutasyonlu PARASAUROLUPHUS dışında mutasyonlu dinozorlar günde 1 SPİNO dışında tüm balıkçıllar ve tüm otçullar günde 2 kere yem yesin
User prompt
Please fix the bug: 'Uncaught ReferenceError: getPointsBonus is not defined' in or related to this line: 'totalPoints = Math.floor(basePoints * getPointsBonus(selectedDinosaur));' Line Number: 131
User prompt
İsim koymak için harf ilerlettigimiz ve geri getirdiğimiz mavi tuşların görüntüsü < > böyle yap
User prompt
Otçul dinozorlardan PARASAUROLUPHUS 0,5 paket mutasyonlu PARASAUROLUPHUS ise 1 paket ot tüketsin
User prompt
Balıkçıl dinzorlar ise Spino 2 paket baryonyx 1 mutasyonlu BARYONYX ise 1,5 paket balık eti yesin
User prompt
Dinozorların hepsi farklı miktarda beisn tüketsin etçiller arasında trex 2 paket et giga 1,5 paket et yuty,mutasyonlu dimetredon ve allo 1 paket et PYTHEREDON ve DİMETRODON ise 0,5 paket besin tüketsin
User prompt
Dinozorların solundaki ❗ dinozrların sağına geçsin
User prompt
Dinozorların sağındaki butonu kaldır ve solundaki ❗ büyüt
User prompt
Feed sekmesindeki yemlerin yanındaki ❗ basınca o yemi oyundaki hangi dinozorların yediği yazsın ve dinozorlar sadece kendi yemini yesin ve bag sekmesinde dinozorların soluna ❗ ekle basınca bag sekmesinin en altında dijzorun adi resmi ve açlık durumu yazsın onların altında ise dinozoru belse yazsın
User prompt
Yaprak paketinin fiyatı 15 coin et paketinin fiyatı 100 coin balık paketinin fiyatı 55 coin olsun
User prompt
Feed sekmesindeki back özelliğinin üstüne tam irtada olucak şekilde BACK yaz
User prompt
Feed sekmesindeki yem Butonlarındaki yazının içinde olan ❗ kaldır sadece butonun yanında olsun ❗
User prompt
Hayır feed sekmesindeki yemlerin butonunun yanına ❗koy
User prompt
Feed sekmesindeki yemlerin fiyatını yarıya indir ve yanlarına ❗koy
User prompt
Shop sekwmsindeki back özelliğinin üstünde yazan BACK yazısı butonun ortasında olsun
User prompt
Shop sekmesindeki back özelliğinin üstünde BACK yazısın
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ var DinosaurImage = Container.expand(function (dinosaurName) { var self = Container.call(this); // Main dinosaur body var dinoBody = self.attachAsset(dinosaurName, { anchorX: 0.5, anchorY: 0.5 }); // Add red eyes var leftEye = self.attachAsset('redEye', { anchorX: 0.5, anchorY: 0.5 }); leftEye.x = -30; leftEye.y = -20; var rightEye = self.attachAsset('redEye', { anchorX: 0.5, anchorY: 0.5 }); rightEye.x = 30; rightEye.y = -20; return self; }); 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 collects 1 fossil per click (no level restriction) self.handlePytheredonCollection(); return; } else if (selectedDinosaur === 'Mutated DIMETRODON') { // Mutated DIMETRODON collects 3 most valuable fossils every 3 levels if (currentLevelNumber % 3 === 0) { self.handleMutatedDimetrodonCollection(); return; } else { // Regular collection on non-3rd levels // 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 basePoints = self.points + speedBonus; // Apply upgrade bonus to points if dinosaur is selected and not hungry var totalPoints = basePoints; if (selectedDinosaur && canDinosaurUseAbilities(selectedDinosaur)) { totalPoints = Math.floor(basePoints * getPointsBonus(selectedDinosaur)); } // Apply 2X MONEY effect if active if (doubleMoneyLevelsLeft > 0) { totalPoints *= 2; } LK.setScore(LK.getScore() + totalPoints); scoreText.setText('Score: ' + LK.getScore()); self.animateCollection(); return; } } else if (selectedDinosaur === 'DIMETRODON') { // DIMETRODON collects 2 fossils regardless of rarity (every level) 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 basePoints = self.points + speedBonus; // Apply upgrade bonus to points if dinosaur is selected var totalPoints = basePoints; if (selectedDinosaur) { totalPoints = Math.floor(basePoints * getPointsBonus(selectedDinosaur)); } // 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 var fossilsToCollect = 2; // Add current fossil first playerInventory.push(self.fossilType); // Add one more fossil of same type playerInventory.push(self.fossilType); storage.playerInventory = playerInventory; // Award bonus points for dual collection var basePoints = self.points * fossilsToCollect; var totalPoints = basePoints; if (doubleMoneyLevelsLeft > 0) { totalPoints *= 2; } LK.setScore(LK.getScore() + totalPoints); scoreText.setText('Score: ' + LK.getScore()); self.animateCollection(); }; self.handlePytheredonCollection = function () { // PYTHEREDON collects 1 fossil per click playerInventory.push(self.fossilType); storage.playerInventory = playerInventory; // Award points for fossil collection var basePoints = self.points; var totalPoints = basePoints; if (selectedDinosaur && canDinosaurUseAbilities(selectedDinosaur)) { totalPoints = Math.floor(basePoints * getPointsBonus(selectedDinosaur)); } // Apply 2X MONEY effect if active 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 available 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 fossils 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; // Get difficulty settings for this level var difficulty = getLevelDifficulty(levelNumber); var fossilCount = difficulty.fossilCount; var blocksPerRow = difficulty.gridWidth; var rows = difficulty.gridHeight; var rareChance = difficulty.rareChance; var fossilTypes = ['fossil1', 'fossil2', 'fossil3']; // Add rare fossil chance based on level difficulty if (Math.random() < rareChance) { fossilTypes.push('rareFossil'); } self.totalFossils = fossilCount; // Create limestone blocks grid with scaling difficulty var startX = 1024 - blocksPerRow * 140 / 2 + 70; // Center the grid 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++) { // Determine block type - 25% chance for ultra hard block, 30% chance for hard rock, 45% chance for limestone var random = Math.random(); var blockType; if (random < 0.25) { blockType = 'ultraHardBlock'; } else if (random < 0.55) { blockType = 'hardRock'; } else { blockType = 'limestone'; } var block = new LimestoneBlock(blockType); 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 with scaling difficulty var baseLevelBonus = Math.floor(currentLevelNumber / 10) * 100; // Bonus increases every 10 levels var timeBonus = Math.max(0, 1000 + baseLevelBonus - 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 < maxLevels) { // Check if next level is a puzzle level if (isPuzzleLevel(currentLevelNumber + 1)) { startPuzzleLevel(currentLevelNumber + 1); } else { startLevel(currentLevelNumber + 1); } } else { // Game complete - reset progress storage.currentLevelNumber = 1; currentLevelNumber = 1; LK.showYouWin(); } }, 2000); } }; return self; }); var LimestoneBlock = Container.expand(function (blockType) { var self = Container.call(this); self.blockType = blockType || 'limestone'; // Use tan colored asset for ultra hard blocks var assetName = self.blockType === 'ultraHardBlock' ? 'ultraHardRock' : self.blockType; var blockGraphics = self.attachAsset(assetName, { anchorX: 0.5, anchorY: 0.5 }); self.hasFossil = false; self.fossilType = null; self.isCollected = false; self.hitsRequired = self.blockType === 'ultraHardBlock' ? 10 : self.blockType === 'hardRock' ? 5 : 3; self.currentHits = 0; self.down = function (x, y, obj) { if (!self.isCollected) { self.currentHits++; if (self.currentHits >= self.hitsRequired) { self.collectBlock(); } else { // Show visual feedback for partial damage var damageAlpha = 1 - self.currentHits / self.hitsRequired * 0.6; blockGraphics.alpha = damageAlpha; LK.getSound('dig').play(); } } }; self.collectBlock = function () { // All dinosaurs now use normal collection - abilities only work via button press 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 roars and collects all fossils (every 10 levels) if (currentLevelNumber % 10 === 0) { // Create roar effect with screen shake animation var roarEffect = LK.getAsset('TREX', { anchorX: 0.5, anchorY: 0.5, scaleX: 3.0, scaleY: 3.0 }); roarEffect.x = 1024; roarEffect.y = 1000; roarEffect.alpha = 0.7; roarEffect.tint = 0xFF4500; // Orange roar effect currentLevel.addChild(roarEffect); // Animate roar effect with tween tween(roarEffect, { scaleX: 5.0, scaleY: 5.0, alpha: 0 }, { duration: 2000, easing: tween.easeOut, onFinish: function onFinish() { roarEffect.destroy(); } }); // Collect all fossils on the level instantly for (var i = 0; i < currentLevel.blocks.length; i++) { var block = currentLevel.blocks[i]; if (block.hasFossil && !block.isCollected) { // Instantly reveal and collect the fossil currentLevel.revealFossil(block.fossilType, block.x, block.y); // Mark block as collected block.isCollected = true; block.alpha = 0; } } // Break current block normally self.performCollection(); } else { // Regular collection for non-10th levels self.performCollection(); } }; self.performSpinoCollection = function () { // SPINO tail strike breaks 3 blocks in a horizontal line (1 use per level) if (storage.spinoUsedThisLevel === undefined) storage.spinoUsedThisLevel = false; if (storage.spinoUsedThisLevel) { // Already used this level self.performCollection(); return; } storage.spinoUsedThisLevel = true; // Create visual tail strike effect var tailStrikeEffect = LK.getAsset('SPINO', { anchorX: 0.5, anchorY: 0.5, scaleX: 2.0, scaleY: 2.0 }); tailStrikeEffect.x = self.x; tailStrikeEffect.y = self.y; tailStrikeEffect.alpha = 0.8; tailStrikeEffect.tint = 0x228B22; // Green tail strike effect currentLevel.addChild(tailStrikeEffect); // Animate tail strike effect tween(tailStrikeEffect, { scaleX: 3.5, scaleY: 1.5, alpha: 0 }, { duration: 1000, easing: tween.easeOut, onFinish: function onFinish() { tailStrikeEffect.destroy(); } }); 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: 0x8B7D6B // Desert sand color }); /**** * Game Code ****/ // Background rotation system - select different background each time function selectNextBackground() { var availableBackgrounds = [0, 1, 2, 3]; // 4 different backgrounds // Remove last shown background from available options if (lastBackgroundIndex !== -1) { var lastIndex = availableBackgrounds.indexOf(lastBackgroundIndex); if (lastIndex !== -1) { availableBackgrounds.splice(lastIndex, 1); } } // Select random background from remaining options currentBackgroundIndex = availableBackgrounds[Math.floor(Math.random() * availableBackgrounds.length)]; // Save current selection as last shown storage.lastBackgroundIndex = currentBackgroundIndex; lastBackgroundIndex = currentBackgroundIndex; } // Create dynamic backgrounds based on selection function createBackground(backgroundIndex) { if (backgroundIndex === 0) { // 1. Current arid desert with gold and dinosaur bones var desertBackground = game.attachAsset('excavationSite', { anchorX: 0.5, anchorY: 0.5 }); desertBackground.x = 1024; desertBackground.y = 1366; desertBackground.alpha = 0.3; desertBackground.tint = 0xD2B48C; // Sandy brown color // Add scattered dinosaur bones and gold pieces for (var i = 0; i < 8; i++) { var bone = LK.getAsset('fossil2', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.7, scaleY: 0.7 }); bone.x = 200 + Math.random() * 1648; bone.y = 1500 + Math.random() * 1000; bone.alpha = 0.4; bone.rotation = Math.random() * Math.PI * 2; game.addChild(bone); } // Add scattered gold pieces for (var j = 0; j < 6; j++) { var gold = LK.getAsset('rareFossil', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.5, scaleY: 0.5 }); gold.x = 300 + Math.random() * 1448; gold.y = 1600 + Math.random() * 900; gold.alpha = 0.6; gold.tint = 0xFFD700; // Golden color game.addChild(gold); } } else if (backgroundIndex === 1) { // 2. Swampy forest with Spinosaurus and Sarcosuchus fossils var swampBackground = game.attachAsset('excavationSite', { anchorX: 0.5, anchorY: 0.5 }); swampBackground.x = 1024; swampBackground.y = 1366; swampBackground.alpha = 0.3; swampBackground.tint = 0x228B22; // Forest green color // Add shore trees along the edges using limestone blocks for (var t = 0; t < 10; t++) { var tree = LK.getAsset('limestone', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.6, scaleY: 1.5 }); // Place trees along the shore (top and bottom edges) if (t < 5) { // Top shore trees tree.x = 200 + t * 300; tree.y = 800 + Math.random() * 200; } else { // Bottom shore trees tree.x = 200 + (t - 5) * 300; tree.y = 2300 + Math.random() * 200; } tree.alpha = 0.4; tree.tint = 0x8B4513; // Brown color for tree trunks game.addChild(tree); } // Add SPINO fossils scattered around for (var s = 0; s < 4; s++) { var spinoFossil = LK.getAsset('SPINO', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.8, scaleY: 0.8 }); spinoFossil.x = 300 + Math.random() * 1448; spinoFossil.y = 1600 + Math.random() * 800; spinoFossil.alpha = 0.3; spinoFossil.rotation = Math.random() * Math.PI * 2; game.addChild(spinoFossil); } // Add crocodile-like fossils (using BARYONYX as substitute for Sarcosuchus) for (var c = 0; c < 3; c++) { var crocFossil = LK.getAsset('BARYONYX', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.6, scaleY: 0.6 }); crocFossil.x = 400 + Math.random() * 1248; crocFossil.y = 1700 + Math.random() * 700; crocFossil.alpha = 0.3; crocFossil.rotation = Math.random() * Math.PI * 2; game.addChild(crocFossil); } } else if (backgroundIndex === 2) { // 3. Snowy mountain with GIGA and Argentavis fossils (white background) var snowyBackground = game.attachAsset('excavationSite', { anchorX: 0.5, anchorY: 0.5 }); snowyBackground.x = 1024; snowyBackground.y = 1366; snowyBackground.alpha = 0.3; snowyBackground.tint = 0xFFFFFF; // White color for snowy mountain // Add GIGA fossils scattered around for (var g = 0; g < 3; g++) { var gigaFossil = LK.getAsset('GIGA', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.8, scaleY: 0.8 }); gigaFossil.x = 300 + Math.random() * 1448; gigaFossil.y = 1600 + Math.random() * 800; gigaFossil.alpha = 0.3; gigaFossil.rotation = Math.random() * Math.PI * 2; game.addChild(gigaFossil); } // Add Argentavis fossils (using YUTY as substitute for Argentavis) for (var a = 0; a < 2; a++) { var argentavisFossil = LK.getAsset('YUTY', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.6, scaleY: 0.6 }); argentavisFossil.x = 400 + Math.random() * 1248; argentavisFossil.y = 1700 + Math.random() * 700; argentavisFossil.alpha = 0.3; argentavisFossil.rotation = Math.random() * Math.PI * 2; game.addChild(argentavisFossil); } // Add snow patches using limestone blocks for (var s = 0; s < 8; s++) { var snowPatch = LK.getAsset('limestone', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.2, scaleY: 1.2 }); snowPatch.x = 200 + Math.random() * 1648; snowPatch.y = 1500 + Math.random() * 1000; snowPatch.alpha = 0.4; snowPatch.tint = 0xF0F8FF; // Alice blue for snow patches snowPatch.rotation = Math.random() * Math.PI * 2; game.addChild(snowPatch); } } else if (backgroundIndex === 3) { // 4. Ocean floor with Megalodon and Mosasaurus fossils (light blue background) var oceanBackground = game.attachAsset('excavationSite', { anchorX: 0.5, anchorY: 0.5 }); oceanBackground.x = 1024; oceanBackground.y = 1366; oceanBackground.alpha = 0.3; oceanBackground.tint = 0x87CEEB; // Light blue color for ocean // Add Megalodon fossils (using TREX as substitute for Megalodon) for (var m = 0; m < 2; m++) { var megalodonFossil = LK.getAsset('TREX', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.0, scaleY: 1.0 }); megalodonFossil.x = 300 + Math.random() * 1448; megalodonFossil.y = 1600 + Math.random() * 800; megalodonFossil.alpha = 0.3; megalodonFossil.rotation = Math.random() * Math.PI * 2; game.addChild(megalodonFossil); } // Add Mosasaurus fossils (using SPINO as substitute for Mosasaurus) for (var mo = 0; mo < 3; mo++) { var mosasaurusFossil = LK.getAsset('SPINO', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.9, scaleY: 0.9 }); mosasaurusFossil.x = 400 + Math.random() * 1248; mosasaurusFossil.y = 1700 + Math.random() * 700; mosasaurusFossil.alpha = 0.3; mosasaurusFossil.rotation = Math.random() * Math.PI * 2; game.addChild(mosasaurusFossil); } // Add coral formations using fossil shapes for (var c = 0; c < 6; c++) { var coral = LK.getAsset('fossil3', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.8, scaleY: 0.8 }); coral.x = 200 + Math.random() * 1648; coral.y = 1500 + Math.random() * 1000; coral.alpha = 0.4; coral.tint = 0xFF7F50; // Coral color coral.rotation = Math.random() * Math.PI * 2; game.addChild(coral); } } } // Select and create background selectNextBackground(); createBackground(currentBackgroundIndex); // Dinosaur images with red eyes and different skin colors var gameState = 'nickname'; // 'nickname', 'playing' var playerNickname = storage.playerNickname || ''; var alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; var currentLetterIndex = 0; var currentLevelNumber = storage.currentLevelNumber || 1; var maxLevels = 200; var currentLevel = null; var levelTimer = 0; var leaderboardTexts = []; // Player data storage - Load persistent data from storage var playerCoins = storage.playerCoins || 0; var playerInventory = storage.playerInventory || []; var dinosaurCollection = storage.dinosaurCollection || []; var selectedDinosaur = storage.selectedDinosaur || null; // Dinosaur hunger system - Load persistent data var dinosaurHunger = storage.dinosaurHunger || {}; var lastFeedingCheck = storage.lastFeedingCheck || Date.now(); // Food inventory - Load persistent data var leafFood = storage.leafFood || 0; var meatFood = storage.meatFood || 0; var fishFood = storage.fishFood || 0; // Dinosaur diet mapping based on real-life diets var dinosaurDiets = { 'PARASOUROLUPHUS': 'leaf', // Herbivore - ate plants, leaves 'PYTHEREDON': 'meat', // Carnivore - small predator 'DIMETRODON': 'meat', // Carnivore - apex predator of its time 'BARYONYX': 'fish', // Piscivore - fish eater with crocodile-like snout 'ALLO': 'meat', // Carnivore - large predator 'YUTY': 'meat', // Carnivore - feathered tyrannosaur 'TREX': 'meat', // Carnivore - apex predator 'SPINO': 'fish', // Piscivore - semi-aquatic fish eater 'GIGA': 'meat', // Carnivore - massive predator 'Mutated BARYONYX': 'fish', // Piscivore - enhanced fish eater 'Mutated DIMETRODON': 'meat', // Carnivore - enhanced predator 'Mutated PARASAUROLUPHUS': 'leaf' // Herbivore - enhanced plant eater }; var feedingCosts = { 'PARASOUROLUPHUS': 50, 'PYTHEREDON': 75, 'DIMETRODON': 100, 'BARYONYX': 200, 'ALLO': 300, 'YUTY': 400, 'TREX': 800, 'SPINO': 600, 'GIGA': 700, 'Mutated BARYONYX': 500, 'Mutated DIMETRODON': 600, 'Mutated PARASAUROLUPHUS': 550 }; // Ensure storage is properly initialized storage.playerCoins = playerCoins; storage.playerInventory = playerInventory; storage.dinosaurCollection = dinosaurCollection; storage.selectedDinosaur = selectedDinosaur; storage.dinosaurHunger = dinosaurHunger; storage.lastFeedingCheck = lastFeedingCheck; // Background rotation system - track last shown background var lastBackgroundIndex = storage.lastBackgroundIndex || -1; var currentBackgroundIndex = 0; // Load persistent gamepass purchases var xrayLevelsLeft = storage.xrayLevelsLeft || 0; var doubleMoneyLevelsLeft = storage.doubleMoneyLevelsLeft || 0; var doubleValueActive = storage.doubleValueActive || false; var doubleSpawnChanceActive = storage.doubleSpawnChanceActive || false; // Load persistent +1 SELECT gamepass purchases // Note: passPurchases is already loaded from storage in the showBag function // Daily gifts system - Load persistent data var lastGiftDate = storage.lastGiftDate || 0; var currentGiftDay = storage.currentGiftDay || 1; var dailyGifts = [1000, 2000, 4000, 8000, 10000, 12000, 16000]; // 7 days of gifts var dailyGiftClaimed = storage.dailyGiftClaimed || false; // Trade system - Load persistent data var dailyTradesLeft = storage.dailyTradesLeft || 5; // 5 trades per day var lastTradeDate = storage.lastTradeDate || 0; var currentTradeOffer = storage.currentTradeOffer || null; var tradeRequestsReceived = storage.tradeRequestsReceived || []; var activePlayers = ['Player1', 'Player2', 'Player3', 'Player4', 'Player5']; // Mock active players // Puzzle and difficulty system var puzzleLevels = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]; // Puzzle every 10 levels var currentPuzzle = null; var puzzleUIElements = []; function isPuzzleLevel(levelNumber) { return puzzleLevels.indexOf(levelNumber) !== -1; } function getLevelDifficulty(levelNumber) { // Calculate difficulty scaling: more fossils, less time, harder patterns var baseFossils = 3; var bonusFossils = Math.floor(levelNumber / 20); // +1 fossil every 20 levels var totalFossils = Math.min(baseFossils + bonusFossils, 10); // Max 10 fossils var baseBlocks = 48; // 8x6 grid var bonusBlocks = Math.floor(levelNumber / 25) * 8; // +8 blocks every 25 levels var totalBlocks = Math.min(baseBlocks + bonusBlocks, 80); // Max 80 blocks (10x8 grid) var rareChance = Math.min(0.05 + levelNumber * 0.002, 0.25); // Increase rare fossil chance, max 25% return { fossilCount: totalFossils, blockCount: totalBlocks, rareChance: rareChance, gridWidth: Math.min(8 + Math.floor(bonusBlocks / 8), 10), gridHeight: Math.min(6 + Math.floor(bonusBlocks / 16), 8) }; } // Stock system - Load persistent data (coming soon) var stockUIElements = []; 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': 'chromatic', 'SPINO': 'legendary', 'GIGA': 'legendary', 'Mutated BARYONYX': 'legendary', 'Mutated DIMETRODON': 'legendary', 'Mutated PARASAUROLUPHUS': 'legendary' }; // Dinosaur abilities - Original characteristics restored var dinosaurAbilities = { 'PARASOUROLUPHUS': 'slow_dig', // Very slow digging, takes more time to break blocks 'PYTHEREDON': 'limited_fossil', // Can only collect 1 fossil per level regardless of upgrades 'DIMETRODON': 'dual_fossil', // Collects 2 fossils regardless of rarity 'BARYONYX': 'speed_dig', // 20% faster digging speed 'YUTY': 'fast_dig', // 70% faster digging speed 'ALLO': 'medium_speed_dig', // 40% faster digging speed 'TREX': 'roar_collector', // Roars every 10 levels and collects all fossils 'SPINO': 'line_breaker', // Tail strike breaks 3 blocks in horizontal line, 1 use per level 'GIGA': 'super_miner', // Double mining speed 'Mutated BARYONYX': 'ultra_fast_dig', // 90% faster digging speed 'Mutated DIMETRODON': 'value_collector', // Collects 3 most valuable fossils per level 'Mutated PARASAUROLUPHUS': 'improved_slow_dig' // Faster than regular PARASAUROLUPHUS but still slower than others }; // 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); // Add dinosaur image var dinoImage = new DinosaurImage(dinosaurName); dinoImage.x = 1024; dinoImage.y = 900; dinoImage.scaleX = 2; dinoImage.scaleY = 2; game.addChild(dinoImage); infoUIElements.push(dinoImage); var dinosaurMessage = new Text2(dinosaurName, { size: 60, fill: '#32CD32' }); dinosaurMessage.anchor.set(0.5, 0.5); dinosaurMessage.x = 1024; dinosaurMessage.y = 1100; 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 = []; var giftsUIElements = []; var tradeUIElements = []; var stockUIElements = []; // 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 = 650; storeButton.y = 1300; var storeButtonText = new Text2('STORE', { size: 35, fill: '#FFFFFF' }); storeButtonText.anchor.set(0.5, 0.5); storeButtonText.x = 650; storeButtonText.y = 1300; var sellButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); sellButton.x = 1398; sellButton.y = 1300; var sellButtonText = new Text2('SELL', { size: 35, fill: '#FFFFFF' }); sellButtonText.anchor.set(0.5, 0.5); sellButtonText.x = 1398; sellButtonText.y = 1300; var shopButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); shopButton.x = 1024; shopButton.y = 1550; var shopButtonText = new Text2('SHOP', { size: 35, fill: '#FFFFFF' }); shopButtonText.anchor.set(0.5, 0.5); shopButtonText.x = 1024; shopButtonText.y = 1550; var bagButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); bagButton.x = 1024; bagButton.y = 1650; var bagButtonText = new Text2('BAG', { size: 35, fill: '#FFFFFF' }); bagButtonText.anchor.set(0.5, 0.5); bagButtonText.x = 1024; bagButtonText.y = 1650; var tradeButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); tradeButton.x = 650; tradeButton.y = 1750; var tradeButtonText = new Text2('TRADE', { size: 35, fill: '#FFFFFF' }); tradeButtonText.anchor.set(0.5, 0.5); tradeButtonText.x = 650; tradeButtonText.y = 1750; var giftsButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); giftsButton.x = 1398; giftsButton.y = 1750; var giftsButtonText = new Text2('GIFTS', { size: 35, fill: '#FFFFFF' }); giftsButtonText.anchor.set(0.5, 0.5); giftsButtonText.x = 1398; giftsButtonText.y = 1750; var stockButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); stockButton.x = 1024; stockButton.y = 1850; var stockButtonText = new Text2('STOCK', { size: 35, fill: '#FFFFFF' }); stockButtonText.anchor.set(0.5, 0.5); stockButtonText.x = 1024; stockButtonText.y = 1850; 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(tradeButton); game.addChild(tradeButtonText); game.addChild(giftsButton); game.addChild(giftsButtonText); game.addChild(stockButton); game.addChild(stockButtonText); 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, tradeButton, tradeButtonText, giftsButton, giftsButtonText, stockButton, stockButtonText, 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 currentLetter = alphabet[currentLetterIndex]; var displayText = 'Enter Nickname: ' + playerNickname + currentLetter; nicknameText.setText(displayText); // Update instruction text to show current letter selection instructionText.setText('Current Letter: ' + currentLetter + ' - Use arrows to select, ADD to add, DELETE to remove'); } function startLevel(levelNumber) { // Clean up previous level if (currentLevel) { currentLevel.destroy(); } currentLevelNumber = levelNumber; storage.currentLevelNumber = currentLevelNumber; levelTimer = 0; // Reset SPINO usage for new level storage.spinoUsedThisLevel = false; // No special ability resets needed for original abilities // Create new level currentLevel = new Level(levelNumber); currentLevel.createLevel(); game.addChild(currentLevel); levelText.setText('Level: ' + levelNumber + '/' + maxLevels); } function startPuzzleLevel(levelNumber) { // Clean up previous level if (currentLevel) { currentLevel.destroy(); } if (currentPuzzle) { currentPuzzle.destroy(); } currentLevelNumber = levelNumber; storage.currentLevelNumber = currentLevelNumber; levelTimer = 0; levelText.setText('Level: ' + levelNumber + ' (PUZZLE)'); // Create dinosaur trivia puzzle createPuzzle(0, levelNumber); } function createPuzzle(puzzleType, levelNumber) { currentPuzzle = new Container(); game.addChild(currentPuzzle); // All puzzles are now dinosaur trivia questions createDinosaurTriviaPuzzle(levelNumber); } function createDinosaurTriviaPuzzle(levelNumber) { // Create trivia questions with increasing difficulty based on level var triviaQuestions = [ // Levels 10-30: Basic questions { question: "En güçlü theropod hangisidir?", answers: ["Tyrannosaurus Rex", "Velociraptor", "Compsognathus"], correct: 0, minLevel: 10 }, { question: "En büyük sauropod hangisidir?", answers: ["Diplodocus", "Argentinasaurus", "Brachiosaurus"], correct: 1, minLevel: 10 }, { question: "En hızlı dinozor hangisidir?", answers: ["Triceratops", "Ornithomimus", "Stegosaurus"], correct: 1, minLevel: 20 }, // Levels 40-70: Intermediate questions { question: "Spinosaurus'un beslenme türü nedir?", answers: ["Otçul", "Balık yiyen", "Et yiyen"], correct: 1, minLevel: 40 }, { question: "En büyük uçan dinozor hangisidir?", answers: ["Pteranodon", "Quetzalcoatlus", "Archaeopteryx"], correct: 1, minLevel: 50 }, { question: "Triceratops kaç boynuzludur?", answers: ["İki", "Üç", "Dört"], correct: 1, minLevel: 60 }, // Levels 80-120: Advanced questions { question: "Carnotaurus'un özel özelliği nedir?", answers: ["Boynuzları", "Kanatları", "Uzun kuyruğu"], correct: 0, minLevel: 80 }, { question: "En küçük bilinen dinozor hangisidir?", answers: ["Microraptor", "Compsognathus", "Epidexipteryx"], correct: 0, minLevel: 100 }, { question: "Therizinosaurus'un beslenme türü nedir?", answers: ["Et yiyen", "Otçul", "Her şey yiyen"], correct: 1, minLevel: 110 }, // Levels 130-200: Expert questions { question: "Dracorex'in anlamı nedir?", answers: ["Ejder Kralı", "Büyük Avcı", "Hızlı Koşucu"], correct: 0, minLevel: 130 }, { question: "En uzun boyunlu dinozor hangisidir?", answers: ["Mamenchisaurus", "Supersaurus", "Giraffatitan"], correct: 0, minLevel: 150 }, { question: "Parasaurolophus'un özel özelliği nedir?", answers: ["Ses çıkarması", "Zehirli dişleri", "Renkli tüyleri"], correct: 0, minLevel: 170 }]; // Filter questions appropriate for current level var availableQuestions = []; for (var i = 0; i < triviaQuestions.length; i++) { if (levelNumber >= triviaQuestions[i].minLevel) { availableQuestions.push(triviaQuestions[i]); } } // Select random question from available ones var selectedQuestion = availableQuestions[Math.floor(Math.random() * availableQuestions.length)]; // Create puzzle title var puzzleTitle = new Text2('DİNOZOR BİLGİ YARIŞMASI', { size: 60, fill: '#FFD700' }); puzzleTitle.anchor.set(0.5, 0.5); puzzleTitle.x = 1024; puzzleTitle.y = 300; currentPuzzle.addChild(puzzleTitle); puzzleUIElements.push(puzzleTitle); // Display question var questionText = new Text2(selectedQuestion.question, { size: 50, fill: '#FFFFFF' }); questionText.anchor.set(0.5, 0.5); questionText.x = 1024; questionText.y = 600; currentPuzzle.addChild(questionText); puzzleUIElements.push(questionText); // Create answer buttons for (var a = 0; a < 3; a++) { var answerButton = currentPuzzle.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); answerButton.x = 1024; answerButton.y = 900 + a * 150; currentPuzzle.addChild(answerButton); puzzleUIElements.push(answerButton); var answerText = new Text2(selectedQuestion.answers[a], { size: 40, fill: '#FFFFFF' }); answerText.anchor.set(0.5, 0.5); answerText.x = 1024; answerText.y = 900 + a * 150; currentPuzzle.addChild(answerText); puzzleUIElements.push(answerText); // Add click handler with closure (function (answerIndex, correctIndex) { answerButton.down = function () { if (answerIndex === correctIndex) { solvePuzzle(); } else { resetTriviaPuzzle(); } }; })(a, selectedQuestion.correct); } } function resetTriviaPuzzle() { // Reset puzzle on wrong answer createDinosaurTriviaPuzzle(currentLevelNumber); } function createSequencePuzzle(levelNumber) { // Sequence puzzle: Click fossils in correct order var puzzleTitle = new Text2('SEQUENCE PUZZLE - Click fossils in order!', { size: 60, fill: '#FFD700' }); puzzleTitle.anchor.set(0.5, 0.5); puzzleTitle.x = 1024; puzzleTitle.y = 300; currentPuzzle.addChild(puzzleTitle); puzzleUIElements.push(puzzleTitle); var sequenceLength = Math.min(3 + Math.floor(levelNumber / 30), 8); // Longer sequences for higher levels var correctSequence = []; var playerSequence = []; var fossils = []; // Create sequence of fossils for (var i = 0; i < sequenceLength; i++) { var fossil = currentPuzzle.attachAsset('fossil' + (i % 3 + 1), { anchorX: 0.5, anchorY: 0.5 }); fossil.x = 300 + i * 150; fossil.y = 800; fossil.sequenceNumber = i + 1; fossils.push(fossil); correctSequence.push(i); puzzleUIElements.push(fossil); var numberText = new Text2(String(i + 1), { size: 40, fill: '#FFFFFF' }); numberText.anchor.set(0.5, 0.5); numberText.x = fossil.x; numberText.y = fossil.y - 80; currentPuzzle.addChild(numberText); puzzleUIElements.push(numberText); // Add click handler (function (index, fossilObj) { fossilObj.down = function () { playerSequence.push(index); fossilObj.alpha = 0.5; if (playerSequence.length === sequenceLength) { checkSequence(); } }; })(i, fossil); } function checkSequence() { var correct = true; for (var i = 0; i < sequenceLength; i++) { if (playerSequence[i] !== correctSequence[i]) { correct = false; break; } } if (correct) { solvePuzzle(); } else { resetSequencePuzzle(); } } function resetSequencePuzzle() { playerSequence = []; for (var i = 0; i < fossils.length; i++) { fossils[i].alpha = 1; } } } function createPatternPuzzle(levelNumber) { // Pattern puzzle: Complete the fossil pattern var puzzleTitle = new Text2('PATTERN PUZZLE - Complete the pattern!', { size: 60, fill: '#FFD700' }); puzzleTitle.anchor.set(0.5, 0.5); puzzleTitle.x = 1024; puzzleTitle.y = 300; currentPuzzle.addChild(puzzleTitle); puzzleUIElements.push(puzzleTitle); var gridSize = Math.min(3 + Math.floor(levelNumber / 50), 5); // Larger grids for higher levels var pattern = []; var playerPattern = []; // Generate pattern for (var i = 0; i < gridSize * gridSize; i++) { pattern.push(Math.random() > 0.5 ? 1 : 0); } // Show pattern briefly, then hide half of it for (var row = 0; row < gridSize; row++) { for (var col = 0; col < gridSize; col++) { var index = row * gridSize + col; var shouldShow = pattern[index] === 1; var isHidden = (row + col) % 2 === 1; // Checkerboard hiding pattern var fossil = null; if (shouldShow && !isHidden) { fossil = currentPuzzle.attachAsset('fossil1', { anchorX: 0.5, anchorY: 0.5 }); } else if (shouldShow && isHidden) { fossil = currentPuzzle.attachAsset('limestone', { anchorX: 0.5, anchorY: 0.5 }); fossil.isHiddenPattern = true; fossil.correctPattern = true; } else if (isHidden) { fossil = currentPuzzle.attachAsset('limestone', { anchorX: 0.5, anchorY: 0.5 }); fossil.isHiddenPattern = true; fossil.correctPattern = false; } if (fossil) { fossil.x = 700 + col * 100; fossil.y = 600 + row * 100; fossil.gridIndex = index; puzzleUIElements.push(fossil); if (fossil.isHiddenPattern) { (function (fossilObj) { fossilObj.down = function () { if (fossilObj.correctPattern) { fossilObj.destroy(); var correctFossil = currentPuzzle.attachAsset('fossil1', { anchorX: 0.5, anchorY: 0.5 }); correctFossil.x = fossilObj.x; correctFossil.y = fossilObj.y; currentPuzzle.addChild(correctFossil); checkPatternComplete(); } else { resetPatternPuzzle(); } }; })(fossil); } } } } } function checkPatternComplete() { // Simple check - if we get here from correct clicks, puzzle is solved solvePuzzle(); } function resetPatternPuzzle() { // Reset puzzle on wrong click createPatternPuzzle(currentLevelNumber); } function createMemoryPuzzle(levelNumber) { // Memory puzzle: Remember fossil locations var puzzleTitle = new Text2('MEMORY PUZZLE - Remember the fossil locations!', { size: 60, fill: '#FFD700' }); puzzleTitle.anchor.set(0.5, 0.5); puzzleTitle.x = 1024; puzzleTitle.y = 300; currentPuzzle.addChild(puzzleTitle); puzzleUIElements.push(puzzleTitle); var fossilCount = Math.min(3 + Math.floor(levelNumber / 40), 6); var memoryPositions = []; var revealedFossils = []; // Generate random positions for (var i = 0; i < fossilCount; i++) { var pos = { x: 400 + Math.floor(Math.random() * 5) * 150, y: 600 + Math.floor(Math.random() * 3) * 150 }; memoryPositions.push(pos); var fossil = currentPuzzle.attachAsset('fossil' + (i % 3 + 1), { anchorX: 0.5, anchorY: 0.5 }); fossil.x = pos.x; fossil.y = pos.y; fossil.memoryIndex = i; currentPuzzle.addChild(fossil); revealedFossils.push(fossil); puzzleUIElements.push(fossil); } // Hide fossils after showing them briefly LK.setTimeout(function () { for (var i = 0; i < revealedFossils.length; i++) { revealedFossils[i].alpha = 0; } createMemoryGrid(); }, 2000); function createMemoryGrid() { var playerGuesses = 0; var correctGuesses = 0; for (var row = 0; row < 3; row++) { for (var col = 0; col < 5; col++) { var gridX = 400 + col * 150; var gridY = 600 + row * 150; var isCorrectPos = false; for (var p = 0; p < memoryPositions.length; p++) { if (memoryPositions[p].x === gridX && memoryPositions[p].y === gridY) { isCorrectPos = true; break; } } var gridBlock = currentPuzzle.attachAsset('limestone', { anchorX: 0.5, anchorY: 0.5 }); gridBlock.x = gridX; gridBlock.y = gridY; gridBlock.isCorrectMemory = isCorrectPos; currentPuzzle.addChild(gridBlock); puzzleUIElements.push(gridBlock); (function (blockObj) { blockObj.down = function () { playerGuesses++; if (blockObj.isCorrectMemory) { correctGuesses++; blockObj.tint = 0x00FF00; // Green for correct } else { blockObj.tint = 0xFF0000; // Red for wrong } if (playerGuesses === fossilCount) { if (correctGuesses === fossilCount) { solvePuzzle(); } else { resetMemoryPuzzle(); } } }; })(gridBlock); } } } } function resetMemoryPuzzle() { createMemoryPuzzle(currentLevelNumber); } function createLogicPuzzle(levelNumber) { // Logic puzzle: Mathematical sequence var puzzleTitle = new Text2('LOGIC PUZZLE - Complete the sequence!', { size: 60, fill: '#FFD700' }); puzzleTitle.anchor.set(0.5, 0.5); puzzleTitle.x = 1024; puzzleTitle.y = 300; currentPuzzle.addChild(puzzleTitle); puzzleUIElements.push(puzzleTitle); // Generate arithmetic sequence var startNum = Math.floor(Math.random() * 10) + 1; var step = Math.floor(Math.random() * 5) + 2; var sequence = [startNum, startNum + step, startNum + step * 2, startNum + step * 3]; var missingIndex = Math.floor(Math.random() * 4); var correctAnswer = sequence[missingIndex]; // Display sequence with missing number for (var i = 0; i < 4; i++) { var numText; if (i === missingIndex) { numText = new Text2('?', { size: 80, fill: '#FF0000' }); } else { numText = new Text2(String(sequence[i]), { size: 80, fill: '#FFFFFF' }); } numText.anchor.set(0.5, 0.5); numText.x = 600 + i * 150; numText.y = 700; currentPuzzle.addChild(numText); puzzleUIElements.push(numText); } // Create answer options var options = [correctAnswer]; for (var j = 0; j < 3; j++) { var wrongAnswer; do { wrongAnswer = correctAnswer + (Math.floor(Math.random() * 10) - 5); } while (options.indexOf(wrongAnswer) !== -1 || wrongAnswer <= 0); options.push(wrongAnswer); } // Shuffle options for (var k = options.length - 1; k > 0; k--) { var randomIndex = Math.floor(Math.random() * (k + 1)); var temp = options[k]; options[k] = options[randomIndex]; options[randomIndex] = temp; } // Display options for (var o = 0; o < options.length; o++) { var optionButton = currentPuzzle.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); optionButton.x = 500 + o * 200; optionButton.y = 1000; currentPuzzle.addChild(optionButton); puzzleUIElements.push(optionButton); var optionText = new Text2(String(options[o]), { size: 60, fill: '#FFFFFF' }); optionText.anchor.set(0.5, 0.5); optionText.x = optionButton.x; optionText.y = optionButton.y; currentPuzzle.addChild(optionText); puzzleUIElements.push(optionText); (function (answer) { optionButton.down = function () { if (answer === correctAnswer) { solvePuzzle(); } else { resetLogicPuzzle(); } }; })(options[o]); } } function resetLogicPuzzle() { createLogicPuzzle(currentLevelNumber); } function solvePuzzle() { // Award bonus points for solving puzzle var puzzleBonus = 1000 * Math.floor(currentLevelNumber / 15); LK.setScore(LK.getScore() + puzzleBonus); scoreText.setText('Score: ' + LK.getScore()); // Clean up puzzle hideAllPuzzleUI(); currentPuzzle.destroy(); currentPuzzle = null; // Continue to regular level startLevel(currentLevelNumber); } function hideAllPuzzleUI() { for (var i = 0; i < puzzleUIElements.length; i++) { puzzleUIElements[i].destroy(); } puzzleUIElements = []; } 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; // 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); // FEED button to navigate to food section var feedSectionButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); feedSectionButton.x = 1024; feedSectionButton.y = 1000; var feedSectionButtonText = new Text2('FEED', { size: 35, fill: '#FFFFFF' }); feedSectionButtonText.anchor.set(0.5, 0.5); feedSectionButtonText.x = 1024; feedSectionButtonText.y = 1000; // Back button var shopBackButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); shopBackButton.x = 1024; shopBackButton.y = 1150; var shopBackButtonText = new Text2('BACK', { size: 35, fill: '#FFFFFF' }); shopBackButtonText.anchor.set(0.5, 0.5); shopBackButtonText.x = 1024; shopBackButtonText.y = 1120; game.addChild(xrayText); game.addChild(doubleMoneyText); game.addChild(doubleValueText); game.addChild(commonEggText); game.addChild(rareEggText); game.addChild(legendaryEggText); game.addChild(feedSectionButtonText); game.addChild(shopBackButtonText); storeUIElements.push(xrayButton, xrayText, doubleMoneyButton, doubleMoneyText, doubleValueButton, doubleValueText, commonEggButton, commonEggText, commonEggInfoButton, rareEggButton, rareEggText, rareEggInfoButton, legendaryEggButton, legendaryEggText, legendaryEggInfoButton, feedSectionButton, feedSectionButtonText, 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(); } }; // 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'); } }; // FEED button click handler - navigate to food section feedSectionButton.down = function () { showFeedSection(); }; shopBackButton.down = function () { hideShop(); }; } function showFeedSection() { gameState = 'feed'; // Hide all shop UI elements hideAllStoreUI(); // Create feed section display var feedTitle = new Text2('DİNOZOR YİYECEKLERİ', { size: 80, fill: '#FFFFFF' }); feedTitle.anchor.set(0.5, 0.5); feedTitle.x = 1024; feedTitle.y = 200; game.addChild(feedTitle); storeUIElements.push(feedTitle); // Dinosaur Food Items var leafFoodButton = game.attachAsset('purchaseButton', { anchorX: 0.5, anchorY: 0.5 }); leafFoodButton.x = 1024; leafFoodButton.y = 400; var leafFoodText = new Text2('Yaprak Paketi - 250 Coins\n5 adet yaprak (Otçul dinozorlar)', { size: 35, fill: '#FFFFFF' }); leafFoodText.anchor.set(0.5, 0.5); leafFoodText.x = 1024; leafFoodText.y = 400; var meatFoodButton = game.attachAsset('purchaseButton', { anchorX: 0.5, anchorY: 0.5 }); meatFoodButton.x = 1024; meatFoodButton.y = 550; var meatFoodText = new Text2('Et Paketi - 400 Coins\n5 adet et (Etçil dinozorlar)', { size: 35, fill: '#FFFFFF' }); meatFoodText.anchor.set(0.5, 0.5); meatFoodText.x = 1024; meatFoodText.y = 550; var fishFoodButton = game.attachAsset('purchaseButton', { anchorX: 0.5, anchorY: 0.5 }); fishFoodButton.x = 1024; fishFoodButton.y = 700; var fishFoodText = new Text2('Balık Paketi - 300 Coins\n5 adet balık (Balık yiyen dinozorlar)', { size: 35, fill: '#FFFFFF' }); fishFoodText.anchor.set(0.5, 0.5); fishFoodText.x = 1024; fishFoodText.y = 700; // Back to shop button var backToShopButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); backToShopButton.x = 1024; backToShopButton.y = 850; var backToShopButtonText = new Text2('SHOP\'A GERİ DÖN', { size: 35, fill: '#FFFFFF' }); backToShopButtonText.anchor.set(0.5, 0.5); backToShopButton.x = 1024; backToShopButton.y = 850; game.addChild(leafFoodText); game.addChild(meatFoodText); game.addChild(fishFoodText); game.addChild(backToShopButtonText); storeUIElements.push(leafFoodButton, leafFoodText, meatFoodButton, meatFoodText, fishFoodButton, fishFoodText, backToShopButton, backToShopButtonText); // Food purchase handlers leafFoodButton.down = function () { if (playerCoins >= 250) { playerCoins -= 250; storage.playerCoins = playerCoins; // Add 5 leaf food to inventory leafFood += 5; storage.leafFood = leafFood; hideFeedSection(); } }; meatFoodButton.down = function () { if (playerCoins >= 400) { playerCoins -= 400; storage.playerCoins = playerCoins; // Add 5 meat food to inventory meatFood += 5; storage.meatFood = meatFood; hideFeedSection(); } }; fishFoodButton.down = function () { if (playerCoins >= 300) { playerCoins -= 300; storage.playerCoins = playerCoins; // Add 5 fish food to inventory fishFood += 5; storage.fishFood = fishFood; hideFeedSection(); } }; backToShopButton.down = function () { hideFeedSection(); showShop(); }; } function hideFeedSection() { gameState = 'nickname'; // Remove all feed UI elements hideAllStoreUI(); // Restore menu UI elements showAllMenuUI(); coinsText.setText('Coins: ' + playerCoins); } function hideShop() { gameState = 'nickname'; // Remove all shop UI elements hideAllStoreUI(); // Restore menu UI elements showAllMenuUI(); coinsText.setText('Coins: ' + playerCoins); } function showBag() { gameState = 'bag'; // Check hunger status when opening bag checkDinosaurHunger(); // 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 slot only) var maxVomitSlots = 1; var vomitText = new Text2('Select Slots: ' + maxVomitSlots + ' available', { size: 35, fill: '#FFD700' }); vomitText.anchor.set(0.5, 0.5); vomitText.x = 1024; vomitText.y = 280; game.addChild(vomitText); // Add coins display in bag var bagCoinsText = new Text2('Para: ' + playerCoins + ' coin', { size: 35, fill: '#FFD700' }); bagCoinsText.anchor.set(0.5, 0.5); bagCoinsText.x = 1024; bagCoinsText.y = 320; game.addChild(bagCoinsText); // Add food inventory display var foodInventoryText = new Text2('Yiyecekler: Yaprak(' + leafFood + ') Et(' + meatFood + ') Balık(' + fishFood + ')', { size: 30, fill: '#32CD32' }); foodInventoryText.anchor.set(0.5, 0.5); foodInventoryText.x = 1024; foodInventoryText.y = 360; game.addChild(foodInventoryText); bagUIElements.push(vomitText, bagCoinsText, foodInventoryText); // Get selected dinosaurs var selectedDinosaurs = []; if (storage.selectedDinosaurs && Array.isArray(storage.selectedDinosaurs)) { selectedDinosaurs = storage.selectedDinosaurs; } else if (selectedDinosaur) { selectedDinosaurs = [selectedDinosaur]; } // Sort dinosaurs by rarity var chromaticDinos = []; var legendaryDinos = []; var rareDinos = []; var commonDinos = []; for (var i = 0; i < dinosaurCollection.length; i++) { var dino = dinosaurCollection[i]; var rarity = dinosaurRarities[dino]; if (rarity === 'chromatic') { chromaticDinos.push(dino); } else if (rarity === 'legendary') { legendaryDinos.push(dino); } else if (rarity === 'rare') { rareDinos.push(dino); } else { commonDinos.push(dino); } } var allDinos = chromaticDinos.concat(legendaryDinos).concat(rareDinos).concat(commonDinos); // Reorder dinosaurs to show selected ones at the bottom var unselectedDinos = []; var selectedDinosForDisplay = []; for (var k = 0; k < allDinos.length; k++) { if (selectedDinosaurs.indexOf(allDinos[k]) !== -1) { selectedDinosForDisplay.push(allDinos[k]); } else { unselectedDinos.push(allDinos[k]); } } var orderedDinos = unselectedDinos.concat(selectedDinosForDisplay); // Display all dinosaurs - unlimited storage, but limited vomit selection var startY = 350; var itemSpacing = 120; // Increased spacing between dinosaur entries for (var j = 0; j < orderedDinos.length; j++) { var dinoName = orderedDinos[j]; var rarity = dinosaurRarities[dinoName]; var color = '#87CEEB'; // Light blue for common/regular dinosaurs if (rarity === 'chromatic') color = getRandomColor(); // Rainbow for chromatic else 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 * itemSpacing; // Add dinosaur image var dinoImage = new DinosaurImage(dinoName); dinoImage.x = 700; dinoImage.y = startY + j * itemSpacing; dinoImage.scaleX = 0.8; dinoImage.scaleY = 0.8; game.addChild(dinoImage); bagUIElements.push(dinoImage); 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 * itemSpacing; game.addChild(dinoText); // Add hunger status and feeding button var hungerStatus = getHungerStatus(dinoName); var hungerText = getHungerText(hungerStatus); var hungerColor = getHungerColor(hungerStatus); var hungerDisplay = new Text2(hungerText, { size: 25, fill: hungerColor }); hungerDisplay.anchor.set(0.5, 0.5); hungerDisplay.x = 1024; hungerDisplay.y = startY + j * itemSpacing + 30; game.addChild(hungerDisplay); // Add feed button var feedButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); feedButton.x = 1400; feedButton.y = startY + j * itemSpacing; feedButton.scaleX = 0.6; feedButton.scaleY = 0.6; // Get required food type and check availability var diet = dinosaurDiets[dinoName]; var foodText = ''; var hasRequiredFood = false; if (diet === 'leaf') { foodText = 'YAPRAK\n' + leafFood; hasRequiredFood = leafFood > 0; } else if (diet === 'meat') { foodText = 'ET\n' + meatFood; hasRequiredFood = meatFood > 0; } else if (diet === 'fish') { foodText = 'BALIK\n' + fishFood; hasRequiredFood = fishFood > 0; } if (!hasRequiredFood) { feedButton.alpha = 0.5; } var feedButtonText = new Text2(foodText, { size: 20, fill: hasRequiredFood ? '#FFFFFF' : '#888888' }); feedButtonText.anchor.set(0.5, 0.5); feedButtonText.x = 1400; feedButtonText.y = startY + j * itemSpacing; game.addChild(feedButtonText); bagUIElements.push(dinoButton, dinoText, hungerDisplay, feedButton, feedButtonText); // Create closure for feeding (function (dinosaurName, feedingCost) { feedButton.down = function () { if (feedDinosaur(dinosaurName)) { // Refresh bag display to update hunger status and coins hideBag(); showBag(); } }; })(dinoName, feedingCosts[dinoName]); // 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 { // Check if player can select dinosaurs - everyone gets 1 base slot only // If at selection limit, replace the first selected dinosaur if (selectedDinosaurs.length >= maxVomitSlots) { selectedDinosaurs.shift(); // Remove first selected dinosaur } selectedDinosaurs.push(dinosaurName); // Add new selection } // 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(); showBag(); // Refresh to show selected at bottom }; })(dinoName); } // Back button // Delete button var deleteButton = game.attachAsset('deleteButton', { anchorX: 0.5, anchorY: 0.5 }); deleteButton.x = 700; deleteButton.y = startY + orderedDinos.length * itemSpacing + 50; var deleteButtonText = new Text2('DELETE', { size: 35, fill: '#FFFFFF' }); deleteButtonText.anchor.set(0.5, 0.5); deleteButtonText.x = 700; deleteButtonText.y = startY + orderedDinos.length * itemSpacing + 50; game.addChild(deleteButtonText); bagUIElements.push(deleteButton, deleteButtonText); var bagBackButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); bagBackButton.x = 1348; bagBackButton.y = startY + orderedDinos.length * itemSpacing + 50; var bagBackButtonText = new Text2('BACK', { size: 35, fill: '#FFFFFF' }); bagBackButtonText.anchor.set(0.5, 0.5); bagBackButtonText.x = 1348; bagBackButtonText.y = startY + orderedDinos.length * itemSpacing + 50; 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; var itemSpacing = 120; // Increased spacing between dinosaur entries 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 * itemSpacing; 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 * itemSpacing; 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 = startY + allDinos.length * itemSpacing + 50; var confirmDeleteText = new Text2('CONFIRM DELETE', { size: 30, fill: '#FFFFFF' }); confirmDeleteText.anchor.set(0.5, 0.5); confirmDeleteText.x = 700; confirmDeleteText.y = startY + allDinos.length * itemSpacing + 50; 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 = startY + allDinos.length * itemSpacing + 50; var cancelDeleteText = new Text2('CANCEL', { size: 35, fill: '#FFFFFF' }); cancelDeleteText.anchor.set(0.5, 0.5); cancelDeleteText.x = 1348; cancelDeleteText.y = startY + allDinos.length * itemSpacing + 50; 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 (Chromatic)\n'; infoText += '??? ??? ???\n\n'; infoText += 'SPINO - %10\n'; infoText += '?\n\n'; infoText += 'GIGA - %15\n'; infoText += '?\n\n'; infoText += 'Mutasyonlu BARYONYX - %25\n'; infoText += '?\n\n'; infoText += 'Mutasyonlu DIMETRODON - %17\n'; infoText += '?\n\n'; infoText += 'Mutasyonlu PARASAUROLUPHUS - %30\n'; infoText += '?'; // Add animated color-changing question marks for TREX ability var trexQuestionMarks = []; for (var q = 0; q < 3; q++) { var questionMark = new Text2('?', { size: 40, fill: getRandomColor() }); questionMark.anchor.set(0.5, 0.5); questionMark.x = 950 + q * 40; questionMark.y = 450; game.addChild(questionMark); infoUIElements.push(questionMark); trexQuestionMarks.push(questionMark); } // Animate color changes for question marks var colorChangeTimer = LK.setInterval(function () { for (var i = 0; i < trexQuestionMarks.length; i++) { tween(trexQuestionMarks[i], { fill: getRandomColor() }, { duration: 500 }); } }, 600); // Store timer reference to clear it when hiding info screen infoUIElements.colorChangeTimer = colorChangeTimer; 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 getRandomColor() { var colors = ['#FF0000', '#FF7F00', '#FFFF00', '#00FF00', '#0000FF', '#4B0082', '#9400D3']; return colors[Math.floor(Math.random() * colors.length)]; } function hideInfoScreen() { // Clear color change timer if it exists if (infoUIElements.colorChangeTimer) { LK.clearInterval(infoUIElements.colorChangeTimer); infoUIElements.colorChangeTimer = null; } // Remove all info UI elements hideAllInfoUI(); } function hideAllGiftsUI() { for (var i = 0; i < giftsUIElements.length; i++) { giftsUIElements[i].destroy(); } giftsUIElements = []; } function hideAllTradeUI() { for (var i = 0; i < tradeUIElements.length; i++) { tradeUIElements[i].destroy(); } tradeUIElements = []; } function hideAllStockUI() { for (var i = 0; i < stockUIElements.length; i++) { stockUIElements[i].destroy(); } stockUIElements = []; } function checkDailyGift() { var currentDate = new Date(); var today = Math.floor(currentDate.getTime() / (1000 * 60 * 60 * 24)); // Days since epoch var lastDate = storage.lastGiftDate || 0; if (today > lastDate) { // New day - reset gift status only when it's actually a new day storage.dailyGiftClaimed = false; dailyGiftClaimed = false; // Check if it's been more than 1 day - reset streak if so if (today > lastDate + 1) { storage.currentGiftDay = 1; currentGiftDay = 1; } storage.lastGiftDate = today; lastGiftDate = today; } else { // Same day - load existing gift claimed status from storage dailyGiftClaimed = storage.dailyGiftClaimed || false; } } function checkDailyTrades() { var currentDate = new Date(); var today = Math.floor(currentDate.getTime() / (1000 * 60 * 60 * 24)); // Days since epoch var lastDate = storage.lastTradeDate || 0; if (today > lastDate) { // New day - reset trade count storage.dailyTradesLeft = 5; dailyTradesLeft = 5; storage.lastTradeDate = today; lastTradeDate = today; } } function canStartTrade() { checkDailyTrades(); return dailyTradesLeft > 0; } function createTradeOffer(targetPlayer, offeredDinosaurs) { if (!canStartTrade() || offeredDinosaurs.length > 4) { return false; } var tradeOffer = { fromPlayer: playerNickname, toPlayer: targetPlayer, offeredDinosaurs: offeredDinosaurs, requestedDinosaurs: [], status: 'pending' }; storage.currentTradeOffer = tradeOffer; currentTradeOffer = tradeOffer; return true; } function acceptTradeOffer(tradeOffer) { if (!canStartTrade()) { return false; } // Execute trade (mock implementation) dailyTradesLeft--; storage.dailyTradesLeft = dailyTradesLeft; // Clear current offer storage.currentTradeOffer = null; currentTradeOffer = null; return true; } function showGifts() { gameState = 'gifts'; checkDailyGift(); // Hide all menu and game UI elements hideAllMenuUI(); hideAllGameUI(); // Create gifts display var giftsTitle = new Text2('GÜNLÜK HEDİYELER', { size: 80, fill: '#FFFFFF' }); giftsTitle.anchor.set(0.5, 0.5); giftsTitle.x = 1024; giftsTitle.y = 200; game.addChild(giftsTitle); giftsUIElements.push(giftsTitle); // Show weekly gift calendar var weekText = new Text2('Haftalık Döngü - Gün ' + currentGiftDay + '/7', { size: 50, fill: '#FFD700' }); weekText.anchor.set(0.5, 0.5); weekText.x = 1024; weekText.y = 300; game.addChild(weekText); giftsUIElements.push(weekText); // Display all 7 days for (var day = 1; day <= 7; day++) { var dayButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); dayButton.x = 200 + (day - 1) * 240; dayButton.y = 600; var isCurrentDay = day === currentGiftDay; var canClaim = isCurrentDay && !dailyGiftClaimed; var isPastDay = day < currentGiftDay; // Change button color based on status if (isPastDay) { dayButton.alpha = 0.5; // Already claimed } else if (canClaim) { dayButton.tint = 0x32CD32; // Green for claimable } else { dayButton.tint = 0x808080; // Gray for future days } var dayText = new Text2('Gün ' + day + '\n' + dailyGifts[day - 1] + ' Para', { size: 30, fill: canClaim ? '#000000' : '#FFFFFF' }); dayText.anchor.set(0.5, 0.5); dayText.x = 200 + (day - 1) * 240; dayText.y = 600; game.addChild(dayText); var statusText = new Text2(isPastDay ? 'ALındı' : canClaim ? 'AL!' : 'Bekliyor', { size: 25, fill: canClaim ? '#000000' : isPastDay ? '#FFD700' : '#CCCCCC' }); statusText.anchor.set(0.5, 0.5); statusText.x = 200 + (day - 1) * 240; statusText.y = 650; game.addChild(statusText); giftsUIElements.push(dayButton, dayText, statusText); // Add click handler for current day if (canClaim) { (function (giftAmount, dayNum) { dayButton.down = function () { // Claim gift playerCoins += giftAmount; storage.playerCoins = playerCoins; // Mark gift as claimed and save to storage immediately dailyGiftClaimed = true; storage.dailyGiftClaimed = true; // Move to next day, reset to 1 after day 7 if (dayNum >= 7) { storage.currentGiftDay = 1; } else { storage.currentGiftDay = dayNum + 1; } currentGiftDay = storage.currentGiftDay; // Refresh gifts display hideGifts(); showGifts(); }; })(dailyGifts[day - 1], day); } } // Back button var giftsBackButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); giftsBackButton.x = 1024; giftsBackButton.y = 1500; var giftsBackButtonText = new Text2('BACK', { size: 35, fill: '#FFFFFF' }); giftsBackButtonText.anchor.set(0.5, 0.5); giftsBackButtonText.x = 1024; giftsBackButtonText.y = 1500; game.addChild(giftsBackButtonText); giftsUIElements.push(giftsBackButton, giftsBackButtonText); giftsBackButton.down = function () { hideGifts(); }; } function hideGifts() { gameState = 'nickname'; // Remove all gifts UI elements hideAllGiftsUI(); // Restore menu UI elements showAllMenuUI(); coinsText.setText('Coins: ' + playerCoins); } function showTrade() { gameState = 'trade'; // Hide all menu and game UI elements hideAllMenuUI(); hideAllGameUI(); // Create trade display var tradeTitle = new Text2('TİCARET SİSTEMİ', { size: 80, fill: '#FFFFFF' }); tradeTitle.anchor.set(0.5, 0.5); tradeTitle.x = 1024; tradeTitle.y = 200; game.addChild(tradeTitle); tradeUIElements.push(tradeTitle); // Coming soon message var comingSoonText = new Text2('YAKINDA GELİYOR', { size: 80, fill: '#FFD700' }); comingSoonText.anchor.set(0.5, 0.5); comingSoonText.x = 1024; comingSoonText.y = 600; game.addChild(comingSoonText); tradeUIElements.push(comingSoonText); var comingSoonDesc = new Text2('Takas sistemi çok yakında aktif olacak!\nDaha fazla özellik için beklemede kalın.', { size: 50, fill: '#FFFFFF' }); comingSoonDesc.anchor.set(0.5, 0.5); comingSoonDesc.x = 1024; comingSoonDesc.y = 800; game.addChild(comingSoonDesc); tradeUIElements.push(comingSoonDesc); // Back button var tradeBackButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); tradeBackButton.x = 1024; tradeBackButton.y = 1500; var tradeBackButtonText = new Text2('BACK', { size: 35, fill: '#FFFFFF' }); tradeBackButtonText.anchor.set(0.5, 0.5); tradeBackButtonText.x = 1024; tradeBackButtonText.y = 1500; game.addChild(tradeBackButtonText); tradeUIElements.push(tradeBackButton, tradeBackButtonText); tradeBackButton.down = function () { hideTrade(); }; } function showTradeSetup(targetPlayer) { gameState = 'tradeSetup'; // Hide current trade UI hideAllTradeUI(); // Create trade setup display var setupTitle = new Text2('TAKAS KURULUMU: ' + targetPlayer, { size: 70, fill: '#FFFFFF' }); setupTitle.anchor.set(0.5, 0.5); setupTitle.x = 1024; setupTitle.y = 200; game.addChild(setupTitle); tradeUIElements.push(setupTitle); var instructionText = new Text2('En fazla 4 dinozor seçebilirsiniz', { size: 50, fill: '#FFD700' }); instructionText.anchor.set(0.5, 0.5); instructionText.x = 1024; instructionText.y = 280; game.addChild(instructionText); tradeUIElements.push(instructionText); // Track selected dinosaurs for trade var selectedForTrade = []; // Display available dinosaurs var startY = 400; for (var i = 0; i < dinosaurCollection.length; i++) { var dinoName = dinosaurCollection[i]; var rarity = dinosaurRarities[dinoName]; var color = '#87CEEB'; if (rarity === 'chromatic') color = getRandomColor();else if (rarity === 'legendary') color = '#FF0000';else if (rarity === 'rare') color = '#800080';else if (rarity === 'common') color = '#00008B'; var isSelected = selectedForTrade.indexOf(dinoName) !== -1; var displayText = dinoName + ' (' + rarity + ')' + (isSelected ? ' [SEÇİLDİ]' : ''); var dinoButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); dinoButton.x = 1024; dinoButton.y = startY + i * 80; var dinoText = new Text2(displayText, { size: 35, fill: isSelected ? '#32CD32' : color }); dinoText.anchor.set(0.5, 0.5); dinoText.x = 1024; dinoText.y = startY + i * 80; game.addChild(dinoText); tradeUIElements.push(dinoButton, dinoText); // Create closure for selection (function (dinosaurName, textElement) { dinoButton.down = function () { var index = selectedForTrade.indexOf(dinosaurName); if (index === -1) { // Add to selection if under limit if (selectedForTrade.length < 4) { selectedForTrade.push(dinosaurName); textElement.setText(dinosaurName + ' (' + dinosaurRarities[dinosaurName] + ') [SEÇİLDİ]'); textElement.fill = '#32CD32'; } } else { // Remove from selection selectedForTrade.splice(index, 1); var rarity = dinosaurRarities[dinosaurName]; var color = '#87CEEB'; if (rarity === 'chromatic') color = getRandomColor();else if (rarity === 'legendary') color = '#FF0000';else if (rarity === 'rare') color = '#800080';else if (rarity === 'common') color = '#00008B'; textElement.setText(dinosaurName + ' (' + rarity + ')'); textElement.fill = color; } }; })(dinoName, dinoText); } // Send trade request button var sendRequestButton = game.attachAsset('purchaseButton', { anchorX: 0.5, anchorY: 0.5 }); sendRequestButton.x = 700; sendRequestButton.y = 1500; var sendRequestText = new Text2('TAKAS İSTEĞİ GÖNDER', { size: 30, fill: '#FFFFFF' }); sendRequestText.anchor.set(0.5, 0.5); sendRequestText.x = 700; sendRequestText.y = 1500; game.addChild(sendRequestText); tradeUIElements.push(sendRequestButton, sendRequestText); sendRequestButton.down = function () { if (selectedForTrade.length > 0) { createTradeOffer(targetPlayer, selectedForTrade); hideTrade(); showTrade(); // Return to main trade screen } }; // Back button var setupBackButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); setupBackButton.x = 1348; setupBackButton.y = 1500; var setupBackText = new Text2('GERİ', { size: 35, fill: '#FFFFFF' }); setupBackText.anchor.set(0.5, 0.5); setupBackText.x = 1348; setupBackText.y = 1500; game.addChild(setupBackText); tradeUIElements.push(setupBackButton, setupBackText); setupBackButton.down = function () { hideTrade(); showTrade(); // Return to main trade screen }; } function hideTrade() { gameState = 'nickname'; // Remove all trade UI elements hideAllTradeUI(); // Restore menu UI elements showAllMenuUI(); } function showStock() { gameState = 'stock'; // Hide all menu and game UI elements hideAllMenuUI(); hideAllGameUI(); // Create stock display var stockTitle = new Text2('DİNOZOR STOKU', { size: 80, fill: '#FFFFFF' }); stockTitle.anchor.set(0.5, 0.5); stockTitle.x = 1024; stockTitle.y = 200; game.addChild(stockTitle); stockUIElements.push(stockTitle); // Define dinosaur buy prices based on rarity and value (higher than sell prices) var dinosaurBuyPrices = { 'PARASOUROLUPHUS': 1200, 'PYTHEREDON': 1350, 'DIMETRODON': 1500, 'BARYONYX': 3750, 'ALLO': 4500, 'YUTY': 5250, 'SPINO': 12000, 'GIGA': 15000, 'Mutated BARYONYX': 18000, 'Mutated DIMETRODON': 22500, 'Mutated PARASAUROLUPHUS': 27000 }; // Get all purchasable dinosaurs (all except TREX) - ordered by expensive dinosaur hierarchy // SPINO (1st), GIGA (2nd), Mutated DIMETRODON (3rd), Mutated BARYONYX (4th), then others by price var allDinosaurs = ['SPINO', 'GIGA', 'Mutated DIMETRODON', 'Mutated BARYONYX', 'Mutated PARASAUROLUPHUS', 'YUTY', 'ALLO', 'BARYONYX', 'DIMETRODON', 'PYTHEREDON', 'PARASOUROLUPHUS']; // No need to sort as we've manually ordered them by hierarchy // Show current coins var coinsDisplayText = new Text2('Mevcut Para: ' + playerCoins + ' coin', { size: 50, fill: '#FFD700' }); coinsDisplayText.anchor.set(0.5, 0.5); coinsDisplayText.x = 1024; coinsDisplayText.y = 280; game.addChild(coinsDisplayText); stockUIElements.push(coinsDisplayText); // Show instruction var instructionText = new Text2('Satın almak istediğiniz dinozorları seçin (TREX satın alınamaz)', { size: 40, fill: '#CCCCCC' }); instructionText.anchor.set(0.5, 0.5); instructionText.x = 1024; instructionText.y = 340; game.addChild(instructionText); stockUIElements.push(instructionText); // Track selected dinosaurs for buying var selectedForBuying = []; // Display purchasable dinosaurs var startY = 500; var itemSpacing = 120; // Increased spacing between dinosaur entries for (var n = 0; n < allDinosaurs.length; n++) { var dinoName = allDinosaurs[n]; var rarity = dinosaurRarities[dinoName]; var price = dinosaurBuyPrices[dinoName]; // Get rarity color var color = '#87CEEB'; // Light blue for common if (rarity === 'chromatic') color = getRandomColor(); // Rainbow for chromatic else 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 displayText = dinoName + ' (' + rarity + ') - ' + price + ' coin'; var canAfford = playerCoins >= price; var dinoButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); dinoButton.x = 1024; dinoButton.y = startY + n * itemSpacing; // Dim button if can't afford if (!canAfford) { dinoButton.alpha = 0.5; } // Add dinosaur image var dinoImage = new DinosaurImage(dinoName); dinoImage.x = 400; dinoImage.y = startY + n * itemSpacing; dinoImage.scaleX = 0.6; dinoImage.scaleY = 0.6; if (!canAfford) { dinoImage.alpha = 0.5; } game.addChild(dinoImage); stockUIElements.push(dinoImage); var dinoText = new Text2(displayText, { size: 35, fill: canAfford ? color : '#666666' }); dinoText.anchor.set(0.5, 0.5); dinoText.x = 1024; dinoText.y = startY + n * itemSpacing; game.addChild(dinoText); var statusText = new Text2(canAfford ? 'SATIN ALINABIL√¨R' : 'YETERS√¨Z PARA', { size: 25, fill: canAfford ? '#32CD32' : '#FF4444' }); statusText.anchor.set(0.5, 0.5); statusText.x = 1024; statusText.y = startY + n * itemSpacing + 25; game.addChild(statusText); stockUIElements.push(dinoButton, dinoText, statusText); // Create closure for purchase (function (dinosaurName, buyPrice, textElement, buttonElement, statusElement, imageElement) { dinoButton.down = function () { if (playerCoins >= buyPrice) { // Purchase dinosaur playerCoins -= buyPrice; storage.playerCoins = playerCoins; // Add dinosaur to collection dinosaurCollection.push(dinosaurName); storage.dinosaurCollection = dinosaurCollection; // Update display coinsDisplayText.setText('Mevcut Para: ' + playerCoins + ' coin'); // Refresh stock display hideStock(); showStock(); } }; })(dinoName, price, dinoText, dinoButton, statusText, dinoImage); } // Back button centered var stockBackButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); stockBackButton.x = 1024; stockBackButton.y = startY + allDinosaurs.length * itemSpacing + 50; var stockBackButtonText = new Text2('BACK', { size: 35, fill: '#FFFFFF' }); stockBackButtonText.anchor.set(0.5, 0.5); stockBackButtonText.x = 1024; stockBackButtonText.y = startY + allDinosaurs.length * itemSpacing + 50; game.addChild(stockBackButtonText); stockUIElements.push(stockBackButton, stockBackButtonText); // Event handlers stockBackButton.down = function () { hideStock(); }; } function hideStock() { gameState = 'nickname'; // Remove all stock UI elements hideAllStockUI(); // Restore menu UI elements showAllMenuUI(); coinsText.setText('Coins: ' + playerCoins); } function checkDinosaurHunger() { var currentTime = Date.now(); var timePassed = currentTime - lastFeedingCheck; // Check hunger every hour (3600000 ms) if (timePassed >= 3600000) { var hungerIncrease = Math.floor(timePassed / 3600000); // Initialize hunger for new dinosaurs and increase hunger for existing ones for (var i = 0; i < dinosaurCollection.length; i++) { var dinoName = dinosaurCollection[i]; if (!dinosaurHunger[dinoName]) { dinosaurHunger[dinoName] = 0; // New dinosaurs start with 0 hunger } else { dinosaurHunger[dinoName] += hungerIncrease; } } // Update storage without removing any dinosaurs storage.dinosaurCollection = dinosaurCollection; storage.dinosaurHunger = dinosaurHunger; storage.lastFeedingCheck = currentTime; lastFeedingCheck = currentTime; } } function showStarvationNotification(starvedDinosaurs) { gameState = 'starvationNotification'; hideAllMenuUI(); hideAllGameUI(); var notificationTitle = new Text2('DİNOZORLAR AÇLIKTAN ÖLDÜ!', { size: 80, fill: '#FF4444' }); notificationTitle.anchor.set(0.5, 0.5); notificationTitle.x = 1024; notificationTitle.y = 400; game.addChild(notificationTitle); infoUIElements.push(notificationTitle); var starvedText = 'Açlıktan ölen dinozorlar:\n'; for (var i = 0; i < starvedDinosaurs.length; i++) { starvedText += starvedDinosaurs[i] + '\n'; } starvedText += '\nDinozorlarınızı düzenli olarak besleyin!'; var notificationMessage = new Text2(starvedText, { size: 50, fill: '#FFFFFF' }); notificationMessage.anchor.set(0.5, 0.5); notificationMessage.x = 1024; notificationMessage.y = 700; game.addChild(notificationMessage); infoUIElements.push(notificationMessage); var okButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); okButton.x = 1024; okButton.y = 1000; var okButtonText = new Text2('TAMAM', { size: 35, fill: '#FFFFFF' }); okButtonText.anchor.set(0.5, 0.5); okButtonText.x = 1024; okButtonText.y = 1000; game.addChild(okButtonText); infoUIElements.push(okButton, okButtonText); okButton.down = function () { hideInfoScreen(); gameState = 'nickname'; showAllMenuUI(); }; } function feedDinosaur(dinosaurName) { var diet = dinosaurDiets[dinosaurName]; var hasFood = false; // Check if player has the required food type if (diet === 'leaf' && leafFood > 0) { leafFood--; storage.leafFood = leafFood; hasFood = true; } else if (diet === 'meat' && meatFood > 0) { meatFood--; storage.meatFood = meatFood; hasFood = true; } else if (diet === 'fish' && fishFood > 0) { fishFood--; storage.fishFood = fishFood; hasFood = true; } if (hasFood) { // Reset hunger to 0 dinosaurHunger[dinosaurName] = 0; storage.dinosaurHunger = dinosaurHunger; return true; } return false; } function getHungerStatus(dinosaurName) { var hunger = dinosaurHunger[dinosaurName] || 0; if (hunger >= 20) return 'VERY_HUNGRY'; if (hunger >= 12) return 'HUNGRY'; if (hunger >= 6) return 'SOMEWHAT_HUNGRY'; return 'FED'; } function getHungerColor(status) { switch (status) { case 'VERY_HUNGRY': return '#FF0000'; case 'HUNGRY': return '#FF8800'; case 'SOMEWHAT_HUNGRY': return '#FFFF00'; default: return '#00FF00'; } } function getHungerText(status) { switch (status) { case 'VERY_HUNGRY': return 'ÇOK AÇ!'; case 'HUNGRY': return 'AÇ'; case 'SOMEWHAT_HUNGRY': return 'BIRAZ AÇ'; default: return 'TOK'; } } function canDinosaurUseAbilities(dinosaurName) { var hungerStatus = getHungerStatus(dinosaurName); // Dinosaurs can only use abilities when fed (not hungry) return hungerStatus === 'FED'; } function startGame() { if (playerNickname.length === 0) { return; } // Check dinosaur hunger when starting game checkDinosaurHunger(); 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; // Show ability button abilityUseButton.visible = true; abilityUseText.visible = true; // Start from saved level or level 1 if no save exists startLevel(currentLevelNumber); } // 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(); }; tradeButton.down = function (x, y, obj) { if (gameState !== 'nickname') { return; } showTrade(); }; giftsButton.down = function (x, y, obj) { if (gameState !== 'nickname') { return; } showGifts(); }; stockButton.down = function (x, y, obj) { if (gameState !== 'nickname') { return; } showStock(); }; 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)); // Check dinosaur hunger periodically (every 30 seconds in-game) if (levelTimer % 1800 === 0) { checkDinosaurHunger(); } // 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()); } // Update ability button text based on selected dinosaur and level restrictions if (selectedDinosaur) { var buttonText = selectedDinosaur + ' ÖZELLİĞİ'; var canUse = true; // Check if dinosaur is too hungry to use abilities if (!canDinosaurUseAbilities(selectedDinosaur)) { var hungerStatus = getHungerStatus(selectedDinosaur); buttonText = selectedDinosaur + ' (AÇ - BESLEYİN)'; canUse = false; } else if (selectedDinosaur === 'TREX' && currentLevelNumber % 10 !== 0) { buttonText = 'TREX (' + (10 - currentLevelNumber % 10) + ' seviye)'; canUse = false; } else if (selectedDinosaur === 'SPINO' && storage.spinoUsedThisLevel) { buttonText = 'SPINO (kullanıldı)'; canUse = false; } else if (selectedDinosaur === 'GIGA') { buttonText = 'GIGA ÖZELLİĞİ'; } else if (selectedDinosaur === 'Mutated DIMETRODON' && currentLevelNumber % 3 !== 0) { buttonText = 'M.DIMETRODON (' + (3 - currentLevelNumber % 3) + ' seviye)'; canUse = false; } else if (selectedDinosaur === 'Mutated BARYONYX' && currentLevelNumber % 4 !== 0) { buttonText = 'M.BARYONYX (' + (4 - currentLevelNumber % 4) + ' seviye)'; canUse = false; } else if (selectedDinosaur === 'Mutated PARASAUROLUPHUS') { var currentUsage = storage.mutatedParasaurolophusMatches || 0; if ((currentUsage + 1) % 2 !== 0) { buttonText = 'M.PARASAUR (' + (2 - (currentUsage + 1) % 2) + ' kullanım)'; canUse = false; } } abilityUseText.setText(buttonText); abilityUseButton.alpha = canUse ? 1.0 : 0.5; } else { abilityUseText.setText('DİNOZOR SEÇ'); abilityUseButton.alpha = 0.5; } } }; // 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) { // Make blocks with fossils green and animate with tween tween(block, { tint: 0x00FF00 }, { duration: 500, easing: tween.easeOut }); } } } } }; 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 = 524; // Further left with more spacing 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 = 524; 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 = 1524; // Further right with more spacing 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 = 1524; 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) { // Make blocks with fossils green and animate with tween tween(block, { tint: 0x00FF00 }, { duration: 500, easing: tween.easeOut }); } } } } }; // Dinosaur ability use button (shown when game is playing) var abilityUseButton = game.attachAsset('purchaseButton', { anchorX: 0.5, anchorY: 0.5 }); abilityUseButton.x = 1024; // Center bottom abilityUseButton.y = 2500; // Bottom of screen abilityUseButton.visible = false; var abilityUseText = new Text2('DİNOZOR ÖZELLİĞİ', { size: 25, fill: '#FFFFFF' }); abilityUseText.anchor.set(0.5, 0.5); abilityUseText.x = 1024; abilityUseText.y = 2500; abilityUseText.visible = false; game.addChild(abilityUseText); // Track ability button as game UI gameUIElements.push(abilityUseButton, abilityUseText); // Ability use button click handler abilityUseButton.down = function (x, y, obj) { if (gameState === 'playing' && selectedDinosaur && currentLevel) { // Check if dinosaur can use abilities (not too hungry) if (!canDinosaurUseAbilities(selectedDinosaur)) { // Dinosaur is too hungry to use abilities return; } // Use the selected dinosaur's ability if (selectedDinosaur === 'TREX') { // TREX roars and collects all fossils (only works every 10 levels) if (currentLevelNumber % 10 === 0) { // Create roar effect with screen shake animation var roarEffect = LK.getAsset('TREX', { anchorX: 0.5, anchorY: 0.5, scaleX: 3.0, scaleY: 3.0 }); roarEffect.x = 1024; roarEffect.y = 1000; roarEffect.alpha = 0.7; roarEffect.tint = 0xFF4500; // Orange roar effect currentLevel.addChild(roarEffect); // Animate roar effect with tween tween(roarEffect, { scaleX: 5.0, scaleY: 5.0, alpha: 0 }, { duration: 2000, easing: tween.easeOut, onFinish: function onFinish() { roarEffect.destroy(); } }); // Collect all fossils on the level instantly for (var i = 0; i < currentLevel.blocks.length; i++) { var block = currentLevel.blocks[i]; if (block.hasFossil && !block.isCollected) { // Instantly reveal and collect the fossil currentLevel.revealFossil(block.fossilType, block.x, block.y); // Mark block as collected block.isCollected = true; block.alpha = 0; } } } } else if (selectedDinosaur === 'SPINO') { // SPINO tail strike - find a random block and break 3 in line (1 use per level) if (storage.spinoUsedThisLevel) { // Already used this level, do nothing return; } if (currentLevel.blocks.length > 0) { storage.spinoUsedThisLevel = true; // Create visual tail strike effect var tailStrikeEffect = LK.getAsset('SPINO', { anchorX: 0.5, anchorY: 0.5, scaleX: 2.0, scaleY: 2.0 }); tailStrikeEffect.x = 1024; tailStrikeEffect.y = 1000; tailStrikeEffect.alpha = 0.8; tailStrikeEffect.tint = 0x228B22; // Green tail strike effect currentLevel.addChild(tailStrikeEffect); // Animate tail strike effect tween(tailStrikeEffect, { scaleX: 3.5, scaleY: 1.5, alpha: 0 }, { duration: 1000, easing: tween.easeOut, onFinish: function onFinish() { tailStrikeEffect.destroy(); } }); var randomIndex = Math.floor(Math.random() * currentLevel.blocks.length); var block = currentLevel.blocks[randomIndex]; if (!block.isCollected) { var blocksToBreak = [block]; var blocksPerRow = 8; var row = Math.floor(randomIndex / blocksPerRow); var col = randomIndex % blocksPerRow; // Add 2 blocks to the right for (var j = 1; j <= 2; j++) { if (col + j < blocksPerRow) { var blockIndex = row * blocksPerRow + (col + j); if (blockIndex < currentLevel.blocks.length) { var nextBlock = currentLevel.blocks[blockIndex]; if (!nextBlock.isCollected) { blocksToBreak.push(nextBlock); } } } } // Break all blocks for (var k = 0; k < blocksToBreak.length; k++) { blocksToBreak[k].performCollection(); } } } } else if (selectedDinosaur === 'GIGA') { // GIGA breaks all rocks instantly every level // Create visual effect for GIGA ability var gigaEffect = LK.getAsset('GIGA', { anchorX: 0.5, anchorY: 0.5, scaleX: 2.5, scaleY: 2.5 }); gigaEffect.x = 1024; gigaEffect.y = 1000; gigaEffect.alpha = 0.8; gigaEffect.tint = 0x800080; // Purple effect for GIGA currentLevel.addChild(gigaEffect); // Animate GIGA effect with tween tween(gigaEffect, { scaleX: 4.0, scaleY: 4.0, alpha: 0 }, { duration: 1500, easing: tween.easeOut, onFinish: function onFinish() { gigaEffect.destroy(); } }); // Break all rocks instantly for (var i = 0; i < currentLevel.blocks.length; i++) { var block = currentLevel.blocks[i]; if (!block.isCollected) { block.currentHits = block.hitsRequired; // Set hits to required amount block.performCollection(); // Break the block instantly } } } else if (selectedDinosaur === 'Mutated DIMETRODON') { // Mutated DIMETRODON collects 3 most valuable fossils every 3 levels if (currentLevelNumber % 3 === 0) { // Find available 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 fossils var fossilsToCollect = Math.min(3, availableFossils.length); for (var j = 0; j < fossilsToCollect; j++) { availableFossils[j].collectFossil(); } } } else if (selectedDinosaur === 'Mutated BARYONYX') { // Mutated BARYONYX ability every 4 levels - reduce hit requirements for all blocks if (currentLevelNumber % 4 === 0) { for (var i = 0; i < currentLevel.blocks.length; i++) { var block = currentLevel.blocks[i]; if (!block.isCollected) { // Set reduced hit requirements: normal blocks 1 hit, hard blocks 3 hits, ultra hard blocks 6 hits block.hitsRequired = block.blockType === 'ultraHardBlock' ? 6 : block.blockType === 'hardRock' ? 3 : 1; } } } } else if (selectedDinosaur === 'Mutated PARASAUROLUPHUS') { // Mutated PARASAUROLUPHUS ability every 2 matches with reduced hits var currentUsage = storage.mutatedParasaurolophusMatches || 0; currentUsage++; storage.mutatedParasaurolophusMatches = currentUsage; if (currentUsage % 2 === 0) { for (var i = 0; i < currentLevel.blocks.length; i++) { var block = currentLevel.blocks[i]; if (!block.isCollected) { // Set reduced hit requirements: normal blocks 2 hits, hard blocks 4 hits, ultra hard blocks 7 hits block.hitsRequired = block.blockType === 'ultraHardBlock' ? 7 : block.blockType === 'hardRock' ? 4 : 2; } } } } else { // For other dinosaurs with no special button ability, show message or do nothing } } }; // 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 DinosaurImage = Container.expand(function (dinosaurName) {
var self = Container.call(this);
// Main dinosaur body
var dinoBody = self.attachAsset(dinosaurName, {
anchorX: 0.5,
anchorY: 0.5
});
// Add red eyes
var leftEye = self.attachAsset('redEye', {
anchorX: 0.5,
anchorY: 0.5
});
leftEye.x = -30;
leftEye.y = -20;
var rightEye = self.attachAsset('redEye', {
anchorX: 0.5,
anchorY: 0.5
});
rightEye.x = 30;
rightEye.y = -20;
return self;
});
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 collects 1 fossil per click (no level restriction)
self.handlePytheredonCollection();
return;
} else if (selectedDinosaur === 'Mutated DIMETRODON') {
// Mutated DIMETRODON collects 3 most valuable fossils every 3 levels
if (currentLevelNumber % 3 === 0) {
self.handleMutatedDimetrodonCollection();
return;
} else {
// Regular collection on non-3rd levels
// 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 basePoints = self.points + speedBonus;
// Apply upgrade bonus to points if dinosaur is selected and not hungry
var totalPoints = basePoints;
if (selectedDinosaur && canDinosaurUseAbilities(selectedDinosaur)) {
totalPoints = Math.floor(basePoints * getPointsBonus(selectedDinosaur));
}
// Apply 2X MONEY effect if active
if (doubleMoneyLevelsLeft > 0) {
totalPoints *= 2;
}
LK.setScore(LK.getScore() + totalPoints);
scoreText.setText('Score: ' + LK.getScore());
self.animateCollection();
return;
}
} else if (selectedDinosaur === 'DIMETRODON') {
// DIMETRODON collects 2 fossils regardless of rarity (every level)
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 basePoints = self.points + speedBonus;
// Apply upgrade bonus to points if dinosaur is selected
var totalPoints = basePoints;
if (selectedDinosaur) {
totalPoints = Math.floor(basePoints * getPointsBonus(selectedDinosaur));
}
// 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
var fossilsToCollect = 2;
// Add current fossil first
playerInventory.push(self.fossilType);
// Add one more fossil of same type
playerInventory.push(self.fossilType);
storage.playerInventory = playerInventory;
// Award bonus points for dual collection
var basePoints = self.points * fossilsToCollect;
var totalPoints = basePoints;
if (doubleMoneyLevelsLeft > 0) {
totalPoints *= 2;
}
LK.setScore(LK.getScore() + totalPoints);
scoreText.setText('Score: ' + LK.getScore());
self.animateCollection();
};
self.handlePytheredonCollection = function () {
// PYTHEREDON collects 1 fossil per click
playerInventory.push(self.fossilType);
storage.playerInventory = playerInventory;
// Award points for fossil collection
var basePoints = self.points;
var totalPoints = basePoints;
if (selectedDinosaur && canDinosaurUseAbilities(selectedDinosaur)) {
totalPoints = Math.floor(basePoints * getPointsBonus(selectedDinosaur));
}
// Apply 2X MONEY effect if active
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 available 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 fossils
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;
// Get difficulty settings for this level
var difficulty = getLevelDifficulty(levelNumber);
var fossilCount = difficulty.fossilCount;
var blocksPerRow = difficulty.gridWidth;
var rows = difficulty.gridHeight;
var rareChance = difficulty.rareChance;
var fossilTypes = ['fossil1', 'fossil2', 'fossil3'];
// Add rare fossil chance based on level difficulty
if (Math.random() < rareChance) {
fossilTypes.push('rareFossil');
}
self.totalFossils = fossilCount;
// Create limestone blocks grid with scaling difficulty
var startX = 1024 - blocksPerRow * 140 / 2 + 70; // Center the grid
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++) {
// Determine block type - 25% chance for ultra hard block, 30% chance for hard rock, 45% chance for limestone
var random = Math.random();
var blockType;
if (random < 0.25) {
blockType = 'ultraHardBlock';
} else if (random < 0.55) {
blockType = 'hardRock';
} else {
blockType = 'limestone';
}
var block = new LimestoneBlock(blockType);
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 with scaling difficulty
var baseLevelBonus = Math.floor(currentLevelNumber / 10) * 100; // Bonus increases every 10 levels
var timeBonus = Math.max(0, 1000 + baseLevelBonus - 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 < maxLevels) {
// Check if next level is a puzzle level
if (isPuzzleLevel(currentLevelNumber + 1)) {
startPuzzleLevel(currentLevelNumber + 1);
} else {
startLevel(currentLevelNumber + 1);
}
} else {
// Game complete - reset progress
storage.currentLevelNumber = 1;
currentLevelNumber = 1;
LK.showYouWin();
}
}, 2000);
}
};
return self;
});
var LimestoneBlock = Container.expand(function (blockType) {
var self = Container.call(this);
self.blockType = blockType || 'limestone';
// Use tan colored asset for ultra hard blocks
var assetName = self.blockType === 'ultraHardBlock' ? 'ultraHardRock' : self.blockType;
var blockGraphics = self.attachAsset(assetName, {
anchorX: 0.5,
anchorY: 0.5
});
self.hasFossil = false;
self.fossilType = null;
self.isCollected = false;
self.hitsRequired = self.blockType === 'ultraHardBlock' ? 10 : self.blockType === 'hardRock' ? 5 : 3;
self.currentHits = 0;
self.down = function (x, y, obj) {
if (!self.isCollected) {
self.currentHits++;
if (self.currentHits >= self.hitsRequired) {
self.collectBlock();
} else {
// Show visual feedback for partial damage
var damageAlpha = 1 - self.currentHits / self.hitsRequired * 0.6;
blockGraphics.alpha = damageAlpha;
LK.getSound('dig').play();
}
}
};
self.collectBlock = function () {
// All dinosaurs now use normal collection - abilities only work via button press
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 roars and collects all fossils (every 10 levels)
if (currentLevelNumber % 10 === 0) {
// Create roar effect with screen shake animation
var roarEffect = LK.getAsset('TREX', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 3.0,
scaleY: 3.0
});
roarEffect.x = 1024;
roarEffect.y = 1000;
roarEffect.alpha = 0.7;
roarEffect.tint = 0xFF4500; // Orange roar effect
currentLevel.addChild(roarEffect);
// Animate roar effect with tween
tween(roarEffect, {
scaleX: 5.0,
scaleY: 5.0,
alpha: 0
}, {
duration: 2000,
easing: tween.easeOut,
onFinish: function onFinish() {
roarEffect.destroy();
}
});
// Collect all fossils on the level instantly
for (var i = 0; i < currentLevel.blocks.length; i++) {
var block = currentLevel.blocks[i];
if (block.hasFossil && !block.isCollected) {
// Instantly reveal and collect the fossil
currentLevel.revealFossil(block.fossilType, block.x, block.y);
// Mark block as collected
block.isCollected = true;
block.alpha = 0;
}
}
// Break current block normally
self.performCollection();
} else {
// Regular collection for non-10th levels
self.performCollection();
}
};
self.performSpinoCollection = function () {
// SPINO tail strike breaks 3 blocks in a horizontal line (1 use per level)
if (storage.spinoUsedThisLevel === undefined) storage.spinoUsedThisLevel = false;
if (storage.spinoUsedThisLevel) {
// Already used this level
self.performCollection();
return;
}
storage.spinoUsedThisLevel = true;
// Create visual tail strike effect
var tailStrikeEffect = LK.getAsset('SPINO', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2.0,
scaleY: 2.0
});
tailStrikeEffect.x = self.x;
tailStrikeEffect.y = self.y;
tailStrikeEffect.alpha = 0.8;
tailStrikeEffect.tint = 0x228B22; // Green tail strike effect
currentLevel.addChild(tailStrikeEffect);
// Animate tail strike effect
tween(tailStrikeEffect, {
scaleX: 3.5,
scaleY: 1.5,
alpha: 0
}, {
duration: 1000,
easing: tween.easeOut,
onFinish: function onFinish() {
tailStrikeEffect.destroy();
}
});
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: 0x8B7D6B // Desert sand color
});
/****
* Game Code
****/
// Background rotation system - select different background each time
function selectNextBackground() {
var availableBackgrounds = [0, 1, 2, 3]; // 4 different backgrounds
// Remove last shown background from available options
if (lastBackgroundIndex !== -1) {
var lastIndex = availableBackgrounds.indexOf(lastBackgroundIndex);
if (lastIndex !== -1) {
availableBackgrounds.splice(lastIndex, 1);
}
}
// Select random background from remaining options
currentBackgroundIndex = availableBackgrounds[Math.floor(Math.random() * availableBackgrounds.length)];
// Save current selection as last shown
storage.lastBackgroundIndex = currentBackgroundIndex;
lastBackgroundIndex = currentBackgroundIndex;
}
// Create dynamic backgrounds based on selection
function createBackground(backgroundIndex) {
if (backgroundIndex === 0) {
// 1. Current arid desert with gold and dinosaur bones
var desertBackground = game.attachAsset('excavationSite', {
anchorX: 0.5,
anchorY: 0.5
});
desertBackground.x = 1024;
desertBackground.y = 1366;
desertBackground.alpha = 0.3;
desertBackground.tint = 0xD2B48C; // Sandy brown color
// Add scattered dinosaur bones and gold pieces
for (var i = 0; i < 8; i++) {
var bone = LK.getAsset('fossil2', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.7,
scaleY: 0.7
});
bone.x = 200 + Math.random() * 1648;
bone.y = 1500 + Math.random() * 1000;
bone.alpha = 0.4;
bone.rotation = Math.random() * Math.PI * 2;
game.addChild(bone);
}
// Add scattered gold pieces
for (var j = 0; j < 6; j++) {
var gold = LK.getAsset('rareFossil', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.5,
scaleY: 0.5
});
gold.x = 300 + Math.random() * 1448;
gold.y = 1600 + Math.random() * 900;
gold.alpha = 0.6;
gold.tint = 0xFFD700; // Golden color
game.addChild(gold);
}
} else if (backgroundIndex === 1) {
// 2. Swampy forest with Spinosaurus and Sarcosuchus fossils
var swampBackground = game.attachAsset('excavationSite', {
anchorX: 0.5,
anchorY: 0.5
});
swampBackground.x = 1024;
swampBackground.y = 1366;
swampBackground.alpha = 0.3;
swampBackground.tint = 0x228B22; // Forest green color
// Add shore trees along the edges using limestone blocks
for (var t = 0; t < 10; t++) {
var tree = LK.getAsset('limestone', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.6,
scaleY: 1.5
});
// Place trees along the shore (top and bottom edges)
if (t < 5) {
// Top shore trees
tree.x = 200 + t * 300;
tree.y = 800 + Math.random() * 200;
} else {
// Bottom shore trees
tree.x = 200 + (t - 5) * 300;
tree.y = 2300 + Math.random() * 200;
}
tree.alpha = 0.4;
tree.tint = 0x8B4513; // Brown color for tree trunks
game.addChild(tree);
}
// Add SPINO fossils scattered around
for (var s = 0; s < 4; s++) {
var spinoFossil = LK.getAsset('SPINO', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.8,
scaleY: 0.8
});
spinoFossil.x = 300 + Math.random() * 1448;
spinoFossil.y = 1600 + Math.random() * 800;
spinoFossil.alpha = 0.3;
spinoFossil.rotation = Math.random() * Math.PI * 2;
game.addChild(spinoFossil);
}
// Add crocodile-like fossils (using BARYONYX as substitute for Sarcosuchus)
for (var c = 0; c < 3; c++) {
var crocFossil = LK.getAsset('BARYONYX', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.6,
scaleY: 0.6
});
crocFossil.x = 400 + Math.random() * 1248;
crocFossil.y = 1700 + Math.random() * 700;
crocFossil.alpha = 0.3;
crocFossil.rotation = Math.random() * Math.PI * 2;
game.addChild(crocFossil);
}
} else if (backgroundIndex === 2) {
// 3. Snowy mountain with GIGA and Argentavis fossils (white background)
var snowyBackground = game.attachAsset('excavationSite', {
anchorX: 0.5,
anchorY: 0.5
});
snowyBackground.x = 1024;
snowyBackground.y = 1366;
snowyBackground.alpha = 0.3;
snowyBackground.tint = 0xFFFFFF; // White color for snowy mountain
// Add GIGA fossils scattered around
for (var g = 0; g < 3; g++) {
var gigaFossil = LK.getAsset('GIGA', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.8,
scaleY: 0.8
});
gigaFossil.x = 300 + Math.random() * 1448;
gigaFossil.y = 1600 + Math.random() * 800;
gigaFossil.alpha = 0.3;
gigaFossil.rotation = Math.random() * Math.PI * 2;
game.addChild(gigaFossil);
}
// Add Argentavis fossils (using YUTY as substitute for Argentavis)
for (var a = 0; a < 2; a++) {
var argentavisFossil = LK.getAsset('YUTY', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.6,
scaleY: 0.6
});
argentavisFossil.x = 400 + Math.random() * 1248;
argentavisFossil.y = 1700 + Math.random() * 700;
argentavisFossil.alpha = 0.3;
argentavisFossil.rotation = Math.random() * Math.PI * 2;
game.addChild(argentavisFossil);
}
// Add snow patches using limestone blocks
for (var s = 0; s < 8; s++) {
var snowPatch = LK.getAsset('limestone', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.2,
scaleY: 1.2
});
snowPatch.x = 200 + Math.random() * 1648;
snowPatch.y = 1500 + Math.random() * 1000;
snowPatch.alpha = 0.4;
snowPatch.tint = 0xF0F8FF; // Alice blue for snow patches
snowPatch.rotation = Math.random() * Math.PI * 2;
game.addChild(snowPatch);
}
} else if (backgroundIndex === 3) {
// 4. Ocean floor with Megalodon and Mosasaurus fossils (light blue background)
var oceanBackground = game.attachAsset('excavationSite', {
anchorX: 0.5,
anchorY: 0.5
});
oceanBackground.x = 1024;
oceanBackground.y = 1366;
oceanBackground.alpha = 0.3;
oceanBackground.tint = 0x87CEEB; // Light blue color for ocean
// Add Megalodon fossils (using TREX as substitute for Megalodon)
for (var m = 0; m < 2; m++) {
var megalodonFossil = LK.getAsset('TREX', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.0,
scaleY: 1.0
});
megalodonFossil.x = 300 + Math.random() * 1448;
megalodonFossil.y = 1600 + Math.random() * 800;
megalodonFossil.alpha = 0.3;
megalodonFossil.rotation = Math.random() * Math.PI * 2;
game.addChild(megalodonFossil);
}
// Add Mosasaurus fossils (using SPINO as substitute for Mosasaurus)
for (var mo = 0; mo < 3; mo++) {
var mosasaurusFossil = LK.getAsset('SPINO', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.9,
scaleY: 0.9
});
mosasaurusFossil.x = 400 + Math.random() * 1248;
mosasaurusFossil.y = 1700 + Math.random() * 700;
mosasaurusFossil.alpha = 0.3;
mosasaurusFossil.rotation = Math.random() * Math.PI * 2;
game.addChild(mosasaurusFossil);
}
// Add coral formations using fossil shapes
for (var c = 0; c < 6; c++) {
var coral = LK.getAsset('fossil3', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.8,
scaleY: 0.8
});
coral.x = 200 + Math.random() * 1648;
coral.y = 1500 + Math.random() * 1000;
coral.alpha = 0.4;
coral.tint = 0xFF7F50; // Coral color
coral.rotation = Math.random() * Math.PI * 2;
game.addChild(coral);
}
}
}
// Select and create background
selectNextBackground();
createBackground(currentBackgroundIndex);
// Dinosaur images with red eyes and different skin colors
var gameState = 'nickname'; // 'nickname', 'playing'
var playerNickname = storage.playerNickname || '';
var alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
var currentLetterIndex = 0;
var currentLevelNumber = storage.currentLevelNumber || 1;
var maxLevels = 200;
var currentLevel = null;
var levelTimer = 0;
var leaderboardTexts = [];
// Player data storage - Load persistent data from storage
var playerCoins = storage.playerCoins || 0;
var playerInventory = storage.playerInventory || [];
var dinosaurCollection = storage.dinosaurCollection || [];
var selectedDinosaur = storage.selectedDinosaur || null;
// Dinosaur hunger system - Load persistent data
var dinosaurHunger = storage.dinosaurHunger || {};
var lastFeedingCheck = storage.lastFeedingCheck || Date.now();
// Food inventory - Load persistent data
var leafFood = storage.leafFood || 0;
var meatFood = storage.meatFood || 0;
var fishFood = storage.fishFood || 0;
// Dinosaur diet mapping based on real-life diets
var dinosaurDiets = {
'PARASOUROLUPHUS': 'leaf',
// Herbivore - ate plants, leaves
'PYTHEREDON': 'meat',
// Carnivore - small predator
'DIMETRODON': 'meat',
// Carnivore - apex predator of its time
'BARYONYX': 'fish',
// Piscivore - fish eater with crocodile-like snout
'ALLO': 'meat',
// Carnivore - large predator
'YUTY': 'meat',
// Carnivore - feathered tyrannosaur
'TREX': 'meat',
// Carnivore - apex predator
'SPINO': 'fish',
// Piscivore - semi-aquatic fish eater
'GIGA': 'meat',
// Carnivore - massive predator
'Mutated BARYONYX': 'fish',
// Piscivore - enhanced fish eater
'Mutated DIMETRODON': 'meat',
// Carnivore - enhanced predator
'Mutated PARASAUROLUPHUS': 'leaf' // Herbivore - enhanced plant eater
};
var feedingCosts = {
'PARASOUROLUPHUS': 50,
'PYTHEREDON': 75,
'DIMETRODON': 100,
'BARYONYX': 200,
'ALLO': 300,
'YUTY': 400,
'TREX': 800,
'SPINO': 600,
'GIGA': 700,
'Mutated BARYONYX': 500,
'Mutated DIMETRODON': 600,
'Mutated PARASAUROLUPHUS': 550
};
// Ensure storage is properly initialized
storage.playerCoins = playerCoins;
storage.playerInventory = playerInventory;
storage.dinosaurCollection = dinosaurCollection;
storage.selectedDinosaur = selectedDinosaur;
storage.dinosaurHunger = dinosaurHunger;
storage.lastFeedingCheck = lastFeedingCheck;
// Background rotation system - track last shown background
var lastBackgroundIndex = storage.lastBackgroundIndex || -1;
var currentBackgroundIndex = 0;
// Load persistent gamepass purchases
var xrayLevelsLeft = storage.xrayLevelsLeft || 0;
var doubleMoneyLevelsLeft = storage.doubleMoneyLevelsLeft || 0;
var doubleValueActive = storage.doubleValueActive || false;
var doubleSpawnChanceActive = storage.doubleSpawnChanceActive || false;
// Load persistent +1 SELECT gamepass purchases
// Note: passPurchases is already loaded from storage in the showBag function
// Daily gifts system - Load persistent data
var lastGiftDate = storage.lastGiftDate || 0;
var currentGiftDay = storage.currentGiftDay || 1;
var dailyGifts = [1000, 2000, 4000, 8000, 10000, 12000, 16000]; // 7 days of gifts
var dailyGiftClaimed = storage.dailyGiftClaimed || false;
// Trade system - Load persistent data
var dailyTradesLeft = storage.dailyTradesLeft || 5; // 5 trades per day
var lastTradeDate = storage.lastTradeDate || 0;
var currentTradeOffer = storage.currentTradeOffer || null;
var tradeRequestsReceived = storage.tradeRequestsReceived || [];
var activePlayers = ['Player1', 'Player2', 'Player3', 'Player4', 'Player5']; // Mock active players
// Puzzle and difficulty system
var puzzleLevels = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]; // Puzzle every 10 levels
var currentPuzzle = null;
var puzzleUIElements = [];
function isPuzzleLevel(levelNumber) {
return puzzleLevels.indexOf(levelNumber) !== -1;
}
function getLevelDifficulty(levelNumber) {
// Calculate difficulty scaling: more fossils, less time, harder patterns
var baseFossils = 3;
var bonusFossils = Math.floor(levelNumber / 20); // +1 fossil every 20 levels
var totalFossils = Math.min(baseFossils + bonusFossils, 10); // Max 10 fossils
var baseBlocks = 48; // 8x6 grid
var bonusBlocks = Math.floor(levelNumber / 25) * 8; // +8 blocks every 25 levels
var totalBlocks = Math.min(baseBlocks + bonusBlocks, 80); // Max 80 blocks (10x8 grid)
var rareChance = Math.min(0.05 + levelNumber * 0.002, 0.25); // Increase rare fossil chance, max 25%
return {
fossilCount: totalFossils,
blockCount: totalBlocks,
rareChance: rareChance,
gridWidth: Math.min(8 + Math.floor(bonusBlocks / 8), 10),
gridHeight: Math.min(6 + Math.floor(bonusBlocks / 16), 8)
};
}
// Stock system - Load persistent data (coming soon)
var stockUIElements = [];
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': 'chromatic',
'SPINO': 'legendary',
'GIGA': 'legendary',
'Mutated BARYONYX': 'legendary',
'Mutated DIMETRODON': 'legendary',
'Mutated PARASAUROLUPHUS': 'legendary'
};
// Dinosaur abilities - Original characteristics restored
var dinosaurAbilities = {
'PARASOUROLUPHUS': 'slow_dig',
// Very slow digging, takes more time to break blocks
'PYTHEREDON': 'limited_fossil',
// Can only collect 1 fossil per level regardless of upgrades
'DIMETRODON': 'dual_fossil',
// Collects 2 fossils regardless of rarity
'BARYONYX': 'speed_dig',
// 20% faster digging speed
'YUTY': 'fast_dig',
// 70% faster digging speed
'ALLO': 'medium_speed_dig',
// 40% faster digging speed
'TREX': 'roar_collector',
// Roars every 10 levels and collects all fossils
'SPINO': 'line_breaker',
// Tail strike breaks 3 blocks in horizontal line, 1 use per level
'GIGA': 'super_miner',
// Double mining speed
'Mutated BARYONYX': 'ultra_fast_dig',
// 90% faster digging speed
'Mutated DIMETRODON': 'value_collector',
// Collects 3 most valuable fossils per level
'Mutated PARASAUROLUPHUS': 'improved_slow_dig'
// Faster than regular PARASAUROLUPHUS but still slower than others
};
// 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);
// Add dinosaur image
var dinoImage = new DinosaurImage(dinosaurName);
dinoImage.x = 1024;
dinoImage.y = 900;
dinoImage.scaleX = 2;
dinoImage.scaleY = 2;
game.addChild(dinoImage);
infoUIElements.push(dinoImage);
var dinosaurMessage = new Text2(dinosaurName, {
size: 60,
fill: '#32CD32'
});
dinosaurMessage.anchor.set(0.5, 0.5);
dinosaurMessage.x = 1024;
dinosaurMessage.y = 1100;
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 = [];
var giftsUIElements = [];
var tradeUIElements = [];
var stockUIElements = [];
// 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 = 650;
storeButton.y = 1300;
var storeButtonText = new Text2('STORE', {
size: 35,
fill: '#FFFFFF'
});
storeButtonText.anchor.set(0.5, 0.5);
storeButtonText.x = 650;
storeButtonText.y = 1300;
var sellButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
sellButton.x = 1398;
sellButton.y = 1300;
var sellButtonText = new Text2('SELL', {
size: 35,
fill: '#FFFFFF'
});
sellButtonText.anchor.set(0.5, 0.5);
sellButtonText.x = 1398;
sellButtonText.y = 1300;
var shopButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
shopButton.x = 1024;
shopButton.y = 1550;
var shopButtonText = new Text2('SHOP', {
size: 35,
fill: '#FFFFFF'
});
shopButtonText.anchor.set(0.5, 0.5);
shopButtonText.x = 1024;
shopButtonText.y = 1550;
var bagButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
bagButton.x = 1024;
bagButton.y = 1650;
var bagButtonText = new Text2('BAG', {
size: 35,
fill: '#FFFFFF'
});
bagButtonText.anchor.set(0.5, 0.5);
bagButtonText.x = 1024;
bagButtonText.y = 1650;
var tradeButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
tradeButton.x = 650;
tradeButton.y = 1750;
var tradeButtonText = new Text2('TRADE', {
size: 35,
fill: '#FFFFFF'
});
tradeButtonText.anchor.set(0.5, 0.5);
tradeButtonText.x = 650;
tradeButtonText.y = 1750;
var giftsButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
giftsButton.x = 1398;
giftsButton.y = 1750;
var giftsButtonText = new Text2('GIFTS', {
size: 35,
fill: '#FFFFFF'
});
giftsButtonText.anchor.set(0.5, 0.5);
giftsButtonText.x = 1398;
giftsButtonText.y = 1750;
var stockButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
stockButton.x = 1024;
stockButton.y = 1850;
var stockButtonText = new Text2('STOCK', {
size: 35,
fill: '#FFFFFF'
});
stockButtonText.anchor.set(0.5, 0.5);
stockButtonText.x = 1024;
stockButtonText.y = 1850;
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(tradeButton);
game.addChild(tradeButtonText);
game.addChild(giftsButton);
game.addChild(giftsButtonText);
game.addChild(stockButton);
game.addChild(stockButtonText);
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, tradeButton, tradeButtonText, giftsButton, giftsButtonText, stockButton, stockButtonText, 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 currentLetter = alphabet[currentLetterIndex];
var displayText = 'Enter Nickname: ' + playerNickname + currentLetter;
nicknameText.setText(displayText);
// Update instruction text to show current letter selection
instructionText.setText('Current Letter: ' + currentLetter + ' - Use arrows to select, ADD to add, DELETE to remove');
}
function startLevel(levelNumber) {
// Clean up previous level
if (currentLevel) {
currentLevel.destroy();
}
currentLevelNumber = levelNumber;
storage.currentLevelNumber = currentLevelNumber;
levelTimer = 0;
// Reset SPINO usage for new level
storage.spinoUsedThisLevel = false;
// No special ability resets needed for original abilities
// Create new level
currentLevel = new Level(levelNumber);
currentLevel.createLevel();
game.addChild(currentLevel);
levelText.setText('Level: ' + levelNumber + '/' + maxLevels);
}
function startPuzzleLevel(levelNumber) {
// Clean up previous level
if (currentLevel) {
currentLevel.destroy();
}
if (currentPuzzle) {
currentPuzzle.destroy();
}
currentLevelNumber = levelNumber;
storage.currentLevelNumber = currentLevelNumber;
levelTimer = 0;
levelText.setText('Level: ' + levelNumber + ' (PUZZLE)');
// Create dinosaur trivia puzzle
createPuzzle(0, levelNumber);
}
function createPuzzle(puzzleType, levelNumber) {
currentPuzzle = new Container();
game.addChild(currentPuzzle);
// All puzzles are now dinosaur trivia questions
createDinosaurTriviaPuzzle(levelNumber);
}
function createDinosaurTriviaPuzzle(levelNumber) {
// Create trivia questions with increasing difficulty based on level
var triviaQuestions = [
// Levels 10-30: Basic questions
{
question: "En güçlü theropod hangisidir?",
answers: ["Tyrannosaurus Rex", "Velociraptor", "Compsognathus"],
correct: 0,
minLevel: 10
}, {
question: "En büyük sauropod hangisidir?",
answers: ["Diplodocus", "Argentinasaurus", "Brachiosaurus"],
correct: 1,
minLevel: 10
}, {
question: "En hızlı dinozor hangisidir?",
answers: ["Triceratops", "Ornithomimus", "Stegosaurus"],
correct: 1,
minLevel: 20
},
// Levels 40-70: Intermediate questions
{
question: "Spinosaurus'un beslenme türü nedir?",
answers: ["Otçul", "Balık yiyen", "Et yiyen"],
correct: 1,
minLevel: 40
}, {
question: "En büyük uçan dinozor hangisidir?",
answers: ["Pteranodon", "Quetzalcoatlus", "Archaeopteryx"],
correct: 1,
minLevel: 50
}, {
question: "Triceratops kaç boynuzludur?",
answers: ["İki", "Üç", "Dört"],
correct: 1,
minLevel: 60
},
// Levels 80-120: Advanced questions
{
question: "Carnotaurus'un özel özelliği nedir?",
answers: ["Boynuzları", "Kanatları", "Uzun kuyruğu"],
correct: 0,
minLevel: 80
}, {
question: "En küçük bilinen dinozor hangisidir?",
answers: ["Microraptor", "Compsognathus", "Epidexipteryx"],
correct: 0,
minLevel: 100
}, {
question: "Therizinosaurus'un beslenme türü nedir?",
answers: ["Et yiyen", "Otçul", "Her şey yiyen"],
correct: 1,
minLevel: 110
},
// Levels 130-200: Expert questions
{
question: "Dracorex'in anlamı nedir?",
answers: ["Ejder Kralı", "Büyük Avcı", "Hızlı Koşucu"],
correct: 0,
minLevel: 130
}, {
question: "En uzun boyunlu dinozor hangisidir?",
answers: ["Mamenchisaurus", "Supersaurus", "Giraffatitan"],
correct: 0,
minLevel: 150
}, {
question: "Parasaurolophus'un özel özelliği nedir?",
answers: ["Ses çıkarması", "Zehirli dişleri", "Renkli tüyleri"],
correct: 0,
minLevel: 170
}];
// Filter questions appropriate for current level
var availableQuestions = [];
for (var i = 0; i < triviaQuestions.length; i++) {
if (levelNumber >= triviaQuestions[i].minLevel) {
availableQuestions.push(triviaQuestions[i]);
}
}
// Select random question from available ones
var selectedQuestion = availableQuestions[Math.floor(Math.random() * availableQuestions.length)];
// Create puzzle title
var puzzleTitle = new Text2('DİNOZOR BİLGİ YARIŞMASI', {
size: 60,
fill: '#FFD700'
});
puzzleTitle.anchor.set(0.5, 0.5);
puzzleTitle.x = 1024;
puzzleTitle.y = 300;
currentPuzzle.addChild(puzzleTitle);
puzzleUIElements.push(puzzleTitle);
// Display question
var questionText = new Text2(selectedQuestion.question, {
size: 50,
fill: '#FFFFFF'
});
questionText.anchor.set(0.5, 0.5);
questionText.x = 1024;
questionText.y = 600;
currentPuzzle.addChild(questionText);
puzzleUIElements.push(questionText);
// Create answer buttons
for (var a = 0; a < 3; a++) {
var answerButton = currentPuzzle.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
answerButton.x = 1024;
answerButton.y = 900 + a * 150;
currentPuzzle.addChild(answerButton);
puzzleUIElements.push(answerButton);
var answerText = new Text2(selectedQuestion.answers[a], {
size: 40,
fill: '#FFFFFF'
});
answerText.anchor.set(0.5, 0.5);
answerText.x = 1024;
answerText.y = 900 + a * 150;
currentPuzzle.addChild(answerText);
puzzleUIElements.push(answerText);
// Add click handler with closure
(function (answerIndex, correctIndex) {
answerButton.down = function () {
if (answerIndex === correctIndex) {
solvePuzzle();
} else {
resetTriviaPuzzle();
}
};
})(a, selectedQuestion.correct);
}
}
function resetTriviaPuzzle() {
// Reset puzzle on wrong answer
createDinosaurTriviaPuzzle(currentLevelNumber);
}
function createSequencePuzzle(levelNumber) {
// Sequence puzzle: Click fossils in correct order
var puzzleTitle = new Text2('SEQUENCE PUZZLE - Click fossils in order!', {
size: 60,
fill: '#FFD700'
});
puzzleTitle.anchor.set(0.5, 0.5);
puzzleTitle.x = 1024;
puzzleTitle.y = 300;
currentPuzzle.addChild(puzzleTitle);
puzzleUIElements.push(puzzleTitle);
var sequenceLength = Math.min(3 + Math.floor(levelNumber / 30), 8); // Longer sequences for higher levels
var correctSequence = [];
var playerSequence = [];
var fossils = [];
// Create sequence of fossils
for (var i = 0; i < sequenceLength; i++) {
var fossil = currentPuzzle.attachAsset('fossil' + (i % 3 + 1), {
anchorX: 0.5,
anchorY: 0.5
});
fossil.x = 300 + i * 150;
fossil.y = 800;
fossil.sequenceNumber = i + 1;
fossils.push(fossil);
correctSequence.push(i);
puzzleUIElements.push(fossil);
var numberText = new Text2(String(i + 1), {
size: 40,
fill: '#FFFFFF'
});
numberText.anchor.set(0.5, 0.5);
numberText.x = fossil.x;
numberText.y = fossil.y - 80;
currentPuzzle.addChild(numberText);
puzzleUIElements.push(numberText);
// Add click handler
(function (index, fossilObj) {
fossilObj.down = function () {
playerSequence.push(index);
fossilObj.alpha = 0.5;
if (playerSequence.length === sequenceLength) {
checkSequence();
}
};
})(i, fossil);
}
function checkSequence() {
var correct = true;
for (var i = 0; i < sequenceLength; i++) {
if (playerSequence[i] !== correctSequence[i]) {
correct = false;
break;
}
}
if (correct) {
solvePuzzle();
} else {
resetSequencePuzzle();
}
}
function resetSequencePuzzle() {
playerSequence = [];
for (var i = 0; i < fossils.length; i++) {
fossils[i].alpha = 1;
}
}
}
function createPatternPuzzle(levelNumber) {
// Pattern puzzle: Complete the fossil pattern
var puzzleTitle = new Text2('PATTERN PUZZLE - Complete the pattern!', {
size: 60,
fill: '#FFD700'
});
puzzleTitle.anchor.set(0.5, 0.5);
puzzleTitle.x = 1024;
puzzleTitle.y = 300;
currentPuzzle.addChild(puzzleTitle);
puzzleUIElements.push(puzzleTitle);
var gridSize = Math.min(3 + Math.floor(levelNumber / 50), 5); // Larger grids for higher levels
var pattern = [];
var playerPattern = [];
// Generate pattern
for (var i = 0; i < gridSize * gridSize; i++) {
pattern.push(Math.random() > 0.5 ? 1 : 0);
}
// Show pattern briefly, then hide half of it
for (var row = 0; row < gridSize; row++) {
for (var col = 0; col < gridSize; col++) {
var index = row * gridSize + col;
var shouldShow = pattern[index] === 1;
var isHidden = (row + col) % 2 === 1; // Checkerboard hiding pattern
var fossil = null;
if (shouldShow && !isHidden) {
fossil = currentPuzzle.attachAsset('fossil1', {
anchorX: 0.5,
anchorY: 0.5
});
} else if (shouldShow && isHidden) {
fossil = currentPuzzle.attachAsset('limestone', {
anchorX: 0.5,
anchorY: 0.5
});
fossil.isHiddenPattern = true;
fossil.correctPattern = true;
} else if (isHidden) {
fossil = currentPuzzle.attachAsset('limestone', {
anchorX: 0.5,
anchorY: 0.5
});
fossil.isHiddenPattern = true;
fossil.correctPattern = false;
}
if (fossil) {
fossil.x = 700 + col * 100;
fossil.y = 600 + row * 100;
fossil.gridIndex = index;
puzzleUIElements.push(fossil);
if (fossil.isHiddenPattern) {
(function (fossilObj) {
fossilObj.down = function () {
if (fossilObj.correctPattern) {
fossilObj.destroy();
var correctFossil = currentPuzzle.attachAsset('fossil1', {
anchorX: 0.5,
anchorY: 0.5
});
correctFossil.x = fossilObj.x;
correctFossil.y = fossilObj.y;
currentPuzzle.addChild(correctFossil);
checkPatternComplete();
} else {
resetPatternPuzzle();
}
};
})(fossil);
}
}
}
}
}
function checkPatternComplete() {
// Simple check - if we get here from correct clicks, puzzle is solved
solvePuzzle();
}
function resetPatternPuzzle() {
// Reset puzzle on wrong click
createPatternPuzzle(currentLevelNumber);
}
function createMemoryPuzzle(levelNumber) {
// Memory puzzle: Remember fossil locations
var puzzleTitle = new Text2('MEMORY PUZZLE - Remember the fossil locations!', {
size: 60,
fill: '#FFD700'
});
puzzleTitle.anchor.set(0.5, 0.5);
puzzleTitle.x = 1024;
puzzleTitle.y = 300;
currentPuzzle.addChild(puzzleTitle);
puzzleUIElements.push(puzzleTitle);
var fossilCount = Math.min(3 + Math.floor(levelNumber / 40), 6);
var memoryPositions = [];
var revealedFossils = [];
// Generate random positions
for (var i = 0; i < fossilCount; i++) {
var pos = {
x: 400 + Math.floor(Math.random() * 5) * 150,
y: 600 + Math.floor(Math.random() * 3) * 150
};
memoryPositions.push(pos);
var fossil = currentPuzzle.attachAsset('fossil' + (i % 3 + 1), {
anchorX: 0.5,
anchorY: 0.5
});
fossil.x = pos.x;
fossil.y = pos.y;
fossil.memoryIndex = i;
currentPuzzle.addChild(fossil);
revealedFossils.push(fossil);
puzzleUIElements.push(fossil);
}
// Hide fossils after showing them briefly
LK.setTimeout(function () {
for (var i = 0; i < revealedFossils.length; i++) {
revealedFossils[i].alpha = 0;
}
createMemoryGrid();
}, 2000);
function createMemoryGrid() {
var playerGuesses = 0;
var correctGuesses = 0;
for (var row = 0; row < 3; row++) {
for (var col = 0; col < 5; col++) {
var gridX = 400 + col * 150;
var gridY = 600 + row * 150;
var isCorrectPos = false;
for (var p = 0; p < memoryPositions.length; p++) {
if (memoryPositions[p].x === gridX && memoryPositions[p].y === gridY) {
isCorrectPos = true;
break;
}
}
var gridBlock = currentPuzzle.attachAsset('limestone', {
anchorX: 0.5,
anchorY: 0.5
});
gridBlock.x = gridX;
gridBlock.y = gridY;
gridBlock.isCorrectMemory = isCorrectPos;
currentPuzzle.addChild(gridBlock);
puzzleUIElements.push(gridBlock);
(function (blockObj) {
blockObj.down = function () {
playerGuesses++;
if (blockObj.isCorrectMemory) {
correctGuesses++;
blockObj.tint = 0x00FF00; // Green for correct
} else {
blockObj.tint = 0xFF0000; // Red for wrong
}
if (playerGuesses === fossilCount) {
if (correctGuesses === fossilCount) {
solvePuzzle();
} else {
resetMemoryPuzzle();
}
}
};
})(gridBlock);
}
}
}
}
function resetMemoryPuzzle() {
createMemoryPuzzle(currentLevelNumber);
}
function createLogicPuzzle(levelNumber) {
// Logic puzzle: Mathematical sequence
var puzzleTitle = new Text2('LOGIC PUZZLE - Complete the sequence!', {
size: 60,
fill: '#FFD700'
});
puzzleTitle.anchor.set(0.5, 0.5);
puzzleTitle.x = 1024;
puzzleTitle.y = 300;
currentPuzzle.addChild(puzzleTitle);
puzzleUIElements.push(puzzleTitle);
// Generate arithmetic sequence
var startNum = Math.floor(Math.random() * 10) + 1;
var step = Math.floor(Math.random() * 5) + 2;
var sequence = [startNum, startNum + step, startNum + step * 2, startNum + step * 3];
var missingIndex = Math.floor(Math.random() * 4);
var correctAnswer = sequence[missingIndex];
// Display sequence with missing number
for (var i = 0; i < 4; i++) {
var numText;
if (i === missingIndex) {
numText = new Text2('?', {
size: 80,
fill: '#FF0000'
});
} else {
numText = new Text2(String(sequence[i]), {
size: 80,
fill: '#FFFFFF'
});
}
numText.anchor.set(0.5, 0.5);
numText.x = 600 + i * 150;
numText.y = 700;
currentPuzzle.addChild(numText);
puzzleUIElements.push(numText);
}
// Create answer options
var options = [correctAnswer];
for (var j = 0; j < 3; j++) {
var wrongAnswer;
do {
wrongAnswer = correctAnswer + (Math.floor(Math.random() * 10) - 5);
} while (options.indexOf(wrongAnswer) !== -1 || wrongAnswer <= 0);
options.push(wrongAnswer);
}
// Shuffle options
for (var k = options.length - 1; k > 0; k--) {
var randomIndex = Math.floor(Math.random() * (k + 1));
var temp = options[k];
options[k] = options[randomIndex];
options[randomIndex] = temp;
}
// Display options
for (var o = 0; o < options.length; o++) {
var optionButton = currentPuzzle.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
optionButton.x = 500 + o * 200;
optionButton.y = 1000;
currentPuzzle.addChild(optionButton);
puzzleUIElements.push(optionButton);
var optionText = new Text2(String(options[o]), {
size: 60,
fill: '#FFFFFF'
});
optionText.anchor.set(0.5, 0.5);
optionText.x = optionButton.x;
optionText.y = optionButton.y;
currentPuzzle.addChild(optionText);
puzzleUIElements.push(optionText);
(function (answer) {
optionButton.down = function () {
if (answer === correctAnswer) {
solvePuzzle();
} else {
resetLogicPuzzle();
}
};
})(options[o]);
}
}
function resetLogicPuzzle() {
createLogicPuzzle(currentLevelNumber);
}
function solvePuzzle() {
// Award bonus points for solving puzzle
var puzzleBonus = 1000 * Math.floor(currentLevelNumber / 15);
LK.setScore(LK.getScore() + puzzleBonus);
scoreText.setText('Score: ' + LK.getScore());
// Clean up puzzle
hideAllPuzzleUI();
currentPuzzle.destroy();
currentPuzzle = null;
// Continue to regular level
startLevel(currentLevelNumber);
}
function hideAllPuzzleUI() {
for (var i = 0; i < puzzleUIElements.length; i++) {
puzzleUIElements[i].destroy();
}
puzzleUIElements = [];
}
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;
// 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);
// FEED button to navigate to food section
var feedSectionButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
feedSectionButton.x = 1024;
feedSectionButton.y = 1000;
var feedSectionButtonText = new Text2('FEED', {
size: 35,
fill: '#FFFFFF'
});
feedSectionButtonText.anchor.set(0.5, 0.5);
feedSectionButtonText.x = 1024;
feedSectionButtonText.y = 1000;
// Back button
var shopBackButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
shopBackButton.x = 1024;
shopBackButton.y = 1150;
var shopBackButtonText = new Text2('BACK', {
size: 35,
fill: '#FFFFFF'
});
shopBackButtonText.anchor.set(0.5, 0.5);
shopBackButtonText.x = 1024;
shopBackButtonText.y = 1120;
game.addChild(xrayText);
game.addChild(doubleMoneyText);
game.addChild(doubleValueText);
game.addChild(commonEggText);
game.addChild(rareEggText);
game.addChild(legendaryEggText);
game.addChild(feedSectionButtonText);
game.addChild(shopBackButtonText);
storeUIElements.push(xrayButton, xrayText, doubleMoneyButton, doubleMoneyText, doubleValueButton, doubleValueText, commonEggButton, commonEggText, commonEggInfoButton, rareEggButton, rareEggText, rareEggInfoButton, legendaryEggButton, legendaryEggText, legendaryEggInfoButton, feedSectionButton, feedSectionButtonText, 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();
}
};
// 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');
}
};
// FEED button click handler - navigate to food section
feedSectionButton.down = function () {
showFeedSection();
};
shopBackButton.down = function () {
hideShop();
};
}
function showFeedSection() {
gameState = 'feed';
// Hide all shop UI elements
hideAllStoreUI();
// Create feed section display
var feedTitle = new Text2('DİNOZOR YİYECEKLERİ', {
size: 80,
fill: '#FFFFFF'
});
feedTitle.anchor.set(0.5, 0.5);
feedTitle.x = 1024;
feedTitle.y = 200;
game.addChild(feedTitle);
storeUIElements.push(feedTitle);
// Dinosaur Food Items
var leafFoodButton = game.attachAsset('purchaseButton', {
anchorX: 0.5,
anchorY: 0.5
});
leafFoodButton.x = 1024;
leafFoodButton.y = 400;
var leafFoodText = new Text2('Yaprak Paketi - 250 Coins\n5 adet yaprak (Otçul dinozorlar)', {
size: 35,
fill: '#FFFFFF'
});
leafFoodText.anchor.set(0.5, 0.5);
leafFoodText.x = 1024;
leafFoodText.y = 400;
var meatFoodButton = game.attachAsset('purchaseButton', {
anchorX: 0.5,
anchorY: 0.5
});
meatFoodButton.x = 1024;
meatFoodButton.y = 550;
var meatFoodText = new Text2('Et Paketi - 400 Coins\n5 adet et (Etçil dinozorlar)', {
size: 35,
fill: '#FFFFFF'
});
meatFoodText.anchor.set(0.5, 0.5);
meatFoodText.x = 1024;
meatFoodText.y = 550;
var fishFoodButton = game.attachAsset('purchaseButton', {
anchorX: 0.5,
anchorY: 0.5
});
fishFoodButton.x = 1024;
fishFoodButton.y = 700;
var fishFoodText = new Text2('Balık Paketi - 300 Coins\n5 adet balık (Balık yiyen dinozorlar)', {
size: 35,
fill: '#FFFFFF'
});
fishFoodText.anchor.set(0.5, 0.5);
fishFoodText.x = 1024;
fishFoodText.y = 700;
// Back to shop button
var backToShopButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
backToShopButton.x = 1024;
backToShopButton.y = 850;
var backToShopButtonText = new Text2('SHOP\'A GERİ DÖN', {
size: 35,
fill: '#FFFFFF'
});
backToShopButtonText.anchor.set(0.5, 0.5);
backToShopButton.x = 1024;
backToShopButton.y = 850;
game.addChild(leafFoodText);
game.addChild(meatFoodText);
game.addChild(fishFoodText);
game.addChild(backToShopButtonText);
storeUIElements.push(leafFoodButton, leafFoodText, meatFoodButton, meatFoodText, fishFoodButton, fishFoodText, backToShopButton, backToShopButtonText);
// Food purchase handlers
leafFoodButton.down = function () {
if (playerCoins >= 250) {
playerCoins -= 250;
storage.playerCoins = playerCoins;
// Add 5 leaf food to inventory
leafFood += 5;
storage.leafFood = leafFood;
hideFeedSection();
}
};
meatFoodButton.down = function () {
if (playerCoins >= 400) {
playerCoins -= 400;
storage.playerCoins = playerCoins;
// Add 5 meat food to inventory
meatFood += 5;
storage.meatFood = meatFood;
hideFeedSection();
}
};
fishFoodButton.down = function () {
if (playerCoins >= 300) {
playerCoins -= 300;
storage.playerCoins = playerCoins;
// Add 5 fish food to inventory
fishFood += 5;
storage.fishFood = fishFood;
hideFeedSection();
}
};
backToShopButton.down = function () {
hideFeedSection();
showShop();
};
}
function hideFeedSection() {
gameState = 'nickname';
// Remove all feed UI elements
hideAllStoreUI();
// Restore menu UI elements
showAllMenuUI();
coinsText.setText('Coins: ' + playerCoins);
}
function hideShop() {
gameState = 'nickname';
// Remove all shop UI elements
hideAllStoreUI();
// Restore menu UI elements
showAllMenuUI();
coinsText.setText('Coins: ' + playerCoins);
}
function showBag() {
gameState = 'bag';
// Check hunger status when opening bag
checkDinosaurHunger();
// 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 slot only)
var maxVomitSlots = 1;
var vomitText = new Text2('Select Slots: ' + maxVomitSlots + ' available', {
size: 35,
fill: '#FFD700'
});
vomitText.anchor.set(0.5, 0.5);
vomitText.x = 1024;
vomitText.y = 280;
game.addChild(vomitText);
// Add coins display in bag
var bagCoinsText = new Text2('Para: ' + playerCoins + ' coin', {
size: 35,
fill: '#FFD700'
});
bagCoinsText.anchor.set(0.5, 0.5);
bagCoinsText.x = 1024;
bagCoinsText.y = 320;
game.addChild(bagCoinsText);
// Add food inventory display
var foodInventoryText = new Text2('Yiyecekler: Yaprak(' + leafFood + ') Et(' + meatFood + ') Balık(' + fishFood + ')', {
size: 30,
fill: '#32CD32'
});
foodInventoryText.anchor.set(0.5, 0.5);
foodInventoryText.x = 1024;
foodInventoryText.y = 360;
game.addChild(foodInventoryText);
bagUIElements.push(vomitText, bagCoinsText, foodInventoryText);
// Get selected dinosaurs
var selectedDinosaurs = [];
if (storage.selectedDinosaurs && Array.isArray(storage.selectedDinosaurs)) {
selectedDinosaurs = storage.selectedDinosaurs;
} else if (selectedDinosaur) {
selectedDinosaurs = [selectedDinosaur];
}
// Sort dinosaurs by rarity
var chromaticDinos = [];
var legendaryDinos = [];
var rareDinos = [];
var commonDinos = [];
for (var i = 0; i < dinosaurCollection.length; i++) {
var dino = dinosaurCollection[i];
var rarity = dinosaurRarities[dino];
if (rarity === 'chromatic') {
chromaticDinos.push(dino);
} else if (rarity === 'legendary') {
legendaryDinos.push(dino);
} else if (rarity === 'rare') {
rareDinos.push(dino);
} else {
commonDinos.push(dino);
}
}
var allDinos = chromaticDinos.concat(legendaryDinos).concat(rareDinos).concat(commonDinos);
// Reorder dinosaurs to show selected ones at the bottom
var unselectedDinos = [];
var selectedDinosForDisplay = [];
for (var k = 0; k < allDinos.length; k++) {
if (selectedDinosaurs.indexOf(allDinos[k]) !== -1) {
selectedDinosForDisplay.push(allDinos[k]);
} else {
unselectedDinos.push(allDinos[k]);
}
}
var orderedDinos = unselectedDinos.concat(selectedDinosForDisplay);
// Display all dinosaurs - unlimited storage, but limited vomit selection
var startY = 350;
var itemSpacing = 120; // Increased spacing between dinosaur entries
for (var j = 0; j < orderedDinos.length; j++) {
var dinoName = orderedDinos[j];
var rarity = dinosaurRarities[dinoName];
var color = '#87CEEB'; // Light blue for common/regular dinosaurs
if (rarity === 'chromatic') color = getRandomColor(); // Rainbow for chromatic
else 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 * itemSpacing;
// Add dinosaur image
var dinoImage = new DinosaurImage(dinoName);
dinoImage.x = 700;
dinoImage.y = startY + j * itemSpacing;
dinoImage.scaleX = 0.8;
dinoImage.scaleY = 0.8;
game.addChild(dinoImage);
bagUIElements.push(dinoImage);
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 * itemSpacing;
game.addChild(dinoText);
// Add hunger status and feeding button
var hungerStatus = getHungerStatus(dinoName);
var hungerText = getHungerText(hungerStatus);
var hungerColor = getHungerColor(hungerStatus);
var hungerDisplay = new Text2(hungerText, {
size: 25,
fill: hungerColor
});
hungerDisplay.anchor.set(0.5, 0.5);
hungerDisplay.x = 1024;
hungerDisplay.y = startY + j * itemSpacing + 30;
game.addChild(hungerDisplay);
// Add feed button
var feedButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
feedButton.x = 1400;
feedButton.y = startY + j * itemSpacing;
feedButton.scaleX = 0.6;
feedButton.scaleY = 0.6;
// Get required food type and check availability
var diet = dinosaurDiets[dinoName];
var foodText = '';
var hasRequiredFood = false;
if (diet === 'leaf') {
foodText = 'YAPRAK\n' + leafFood;
hasRequiredFood = leafFood > 0;
} else if (diet === 'meat') {
foodText = 'ET\n' + meatFood;
hasRequiredFood = meatFood > 0;
} else if (diet === 'fish') {
foodText = 'BALIK\n' + fishFood;
hasRequiredFood = fishFood > 0;
}
if (!hasRequiredFood) {
feedButton.alpha = 0.5;
}
var feedButtonText = new Text2(foodText, {
size: 20,
fill: hasRequiredFood ? '#FFFFFF' : '#888888'
});
feedButtonText.anchor.set(0.5, 0.5);
feedButtonText.x = 1400;
feedButtonText.y = startY + j * itemSpacing;
game.addChild(feedButtonText);
bagUIElements.push(dinoButton, dinoText, hungerDisplay, feedButton, feedButtonText);
// Create closure for feeding
(function (dinosaurName, feedingCost) {
feedButton.down = function () {
if (feedDinosaur(dinosaurName)) {
// Refresh bag display to update hunger status and coins
hideBag();
showBag();
}
};
})(dinoName, feedingCosts[dinoName]);
// 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 {
// Check if player can select dinosaurs - everyone gets 1 base slot only
// If at selection limit, replace the first selected dinosaur
if (selectedDinosaurs.length >= maxVomitSlots) {
selectedDinosaurs.shift(); // Remove first selected dinosaur
}
selectedDinosaurs.push(dinosaurName); // Add new selection
}
// 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();
showBag(); // Refresh to show selected at bottom
};
})(dinoName);
}
// Back button
// Delete button
var deleteButton = game.attachAsset('deleteButton', {
anchorX: 0.5,
anchorY: 0.5
});
deleteButton.x = 700;
deleteButton.y = startY + orderedDinos.length * itemSpacing + 50;
var deleteButtonText = new Text2('DELETE', {
size: 35,
fill: '#FFFFFF'
});
deleteButtonText.anchor.set(0.5, 0.5);
deleteButtonText.x = 700;
deleteButtonText.y = startY + orderedDinos.length * itemSpacing + 50;
game.addChild(deleteButtonText);
bagUIElements.push(deleteButton, deleteButtonText);
var bagBackButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
bagBackButton.x = 1348;
bagBackButton.y = startY + orderedDinos.length * itemSpacing + 50;
var bagBackButtonText = new Text2('BACK', {
size: 35,
fill: '#FFFFFF'
});
bagBackButtonText.anchor.set(0.5, 0.5);
bagBackButtonText.x = 1348;
bagBackButtonText.y = startY + orderedDinos.length * itemSpacing + 50;
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;
var itemSpacing = 120; // Increased spacing between dinosaur entries
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 * itemSpacing;
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 * itemSpacing;
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 = startY + allDinos.length * itemSpacing + 50;
var confirmDeleteText = new Text2('CONFIRM DELETE', {
size: 30,
fill: '#FFFFFF'
});
confirmDeleteText.anchor.set(0.5, 0.5);
confirmDeleteText.x = 700;
confirmDeleteText.y = startY + allDinos.length * itemSpacing + 50;
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 = startY + allDinos.length * itemSpacing + 50;
var cancelDeleteText = new Text2('CANCEL', {
size: 35,
fill: '#FFFFFF'
});
cancelDeleteText.anchor.set(0.5, 0.5);
cancelDeleteText.x = 1348;
cancelDeleteText.y = startY + allDinos.length * itemSpacing + 50;
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 (Chromatic)\n';
infoText += '??? ??? ???\n\n';
infoText += 'SPINO - %10\n';
infoText += '?\n\n';
infoText += 'GIGA - %15\n';
infoText += '?\n\n';
infoText += 'Mutasyonlu BARYONYX - %25\n';
infoText += '?\n\n';
infoText += 'Mutasyonlu DIMETRODON - %17\n';
infoText += '?\n\n';
infoText += 'Mutasyonlu PARASAUROLUPHUS - %30\n';
infoText += '?';
// Add animated color-changing question marks for TREX ability
var trexQuestionMarks = [];
for (var q = 0; q < 3; q++) {
var questionMark = new Text2('?', {
size: 40,
fill: getRandomColor()
});
questionMark.anchor.set(0.5, 0.5);
questionMark.x = 950 + q * 40;
questionMark.y = 450;
game.addChild(questionMark);
infoUIElements.push(questionMark);
trexQuestionMarks.push(questionMark);
}
// Animate color changes for question marks
var colorChangeTimer = LK.setInterval(function () {
for (var i = 0; i < trexQuestionMarks.length; i++) {
tween(trexQuestionMarks[i], {
fill: getRandomColor()
}, {
duration: 500
});
}
}, 600);
// Store timer reference to clear it when hiding info screen
infoUIElements.colorChangeTimer = colorChangeTimer;
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 getRandomColor() {
var colors = ['#FF0000', '#FF7F00', '#FFFF00', '#00FF00', '#0000FF', '#4B0082', '#9400D3'];
return colors[Math.floor(Math.random() * colors.length)];
}
function hideInfoScreen() {
// Clear color change timer if it exists
if (infoUIElements.colorChangeTimer) {
LK.clearInterval(infoUIElements.colorChangeTimer);
infoUIElements.colorChangeTimer = null;
}
// Remove all info UI elements
hideAllInfoUI();
}
function hideAllGiftsUI() {
for (var i = 0; i < giftsUIElements.length; i++) {
giftsUIElements[i].destroy();
}
giftsUIElements = [];
}
function hideAllTradeUI() {
for (var i = 0; i < tradeUIElements.length; i++) {
tradeUIElements[i].destroy();
}
tradeUIElements = [];
}
function hideAllStockUI() {
for (var i = 0; i < stockUIElements.length; i++) {
stockUIElements[i].destroy();
}
stockUIElements = [];
}
function checkDailyGift() {
var currentDate = new Date();
var today = Math.floor(currentDate.getTime() / (1000 * 60 * 60 * 24)); // Days since epoch
var lastDate = storage.lastGiftDate || 0;
if (today > lastDate) {
// New day - reset gift status only when it's actually a new day
storage.dailyGiftClaimed = false;
dailyGiftClaimed = false;
// Check if it's been more than 1 day - reset streak if so
if (today > lastDate + 1) {
storage.currentGiftDay = 1;
currentGiftDay = 1;
}
storage.lastGiftDate = today;
lastGiftDate = today;
} else {
// Same day - load existing gift claimed status from storage
dailyGiftClaimed = storage.dailyGiftClaimed || false;
}
}
function checkDailyTrades() {
var currentDate = new Date();
var today = Math.floor(currentDate.getTime() / (1000 * 60 * 60 * 24)); // Days since epoch
var lastDate = storage.lastTradeDate || 0;
if (today > lastDate) {
// New day - reset trade count
storage.dailyTradesLeft = 5;
dailyTradesLeft = 5;
storage.lastTradeDate = today;
lastTradeDate = today;
}
}
function canStartTrade() {
checkDailyTrades();
return dailyTradesLeft > 0;
}
function createTradeOffer(targetPlayer, offeredDinosaurs) {
if (!canStartTrade() || offeredDinosaurs.length > 4) {
return false;
}
var tradeOffer = {
fromPlayer: playerNickname,
toPlayer: targetPlayer,
offeredDinosaurs: offeredDinosaurs,
requestedDinosaurs: [],
status: 'pending'
};
storage.currentTradeOffer = tradeOffer;
currentTradeOffer = tradeOffer;
return true;
}
function acceptTradeOffer(tradeOffer) {
if (!canStartTrade()) {
return false;
}
// Execute trade (mock implementation)
dailyTradesLeft--;
storage.dailyTradesLeft = dailyTradesLeft;
// Clear current offer
storage.currentTradeOffer = null;
currentTradeOffer = null;
return true;
}
function showGifts() {
gameState = 'gifts';
checkDailyGift();
// Hide all menu and game UI elements
hideAllMenuUI();
hideAllGameUI();
// Create gifts display
var giftsTitle = new Text2('GÜNLÜK HEDİYELER', {
size: 80,
fill: '#FFFFFF'
});
giftsTitle.anchor.set(0.5, 0.5);
giftsTitle.x = 1024;
giftsTitle.y = 200;
game.addChild(giftsTitle);
giftsUIElements.push(giftsTitle);
// Show weekly gift calendar
var weekText = new Text2('Haftalık Döngü - Gün ' + currentGiftDay + '/7', {
size: 50,
fill: '#FFD700'
});
weekText.anchor.set(0.5, 0.5);
weekText.x = 1024;
weekText.y = 300;
game.addChild(weekText);
giftsUIElements.push(weekText);
// Display all 7 days
for (var day = 1; day <= 7; day++) {
var dayButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
dayButton.x = 200 + (day - 1) * 240;
dayButton.y = 600;
var isCurrentDay = day === currentGiftDay;
var canClaim = isCurrentDay && !dailyGiftClaimed;
var isPastDay = day < currentGiftDay;
// Change button color based on status
if (isPastDay) {
dayButton.alpha = 0.5; // Already claimed
} else if (canClaim) {
dayButton.tint = 0x32CD32; // Green for claimable
} else {
dayButton.tint = 0x808080; // Gray for future days
}
var dayText = new Text2('Gün ' + day + '\n' + dailyGifts[day - 1] + ' Para', {
size: 30,
fill: canClaim ? '#000000' : '#FFFFFF'
});
dayText.anchor.set(0.5, 0.5);
dayText.x = 200 + (day - 1) * 240;
dayText.y = 600;
game.addChild(dayText);
var statusText = new Text2(isPastDay ? 'ALındı' : canClaim ? 'AL!' : 'Bekliyor', {
size: 25,
fill: canClaim ? '#000000' : isPastDay ? '#FFD700' : '#CCCCCC'
});
statusText.anchor.set(0.5, 0.5);
statusText.x = 200 + (day - 1) * 240;
statusText.y = 650;
game.addChild(statusText);
giftsUIElements.push(dayButton, dayText, statusText);
// Add click handler for current day
if (canClaim) {
(function (giftAmount, dayNum) {
dayButton.down = function () {
// Claim gift
playerCoins += giftAmount;
storage.playerCoins = playerCoins;
// Mark gift as claimed and save to storage immediately
dailyGiftClaimed = true;
storage.dailyGiftClaimed = true;
// Move to next day, reset to 1 after day 7
if (dayNum >= 7) {
storage.currentGiftDay = 1;
} else {
storage.currentGiftDay = dayNum + 1;
}
currentGiftDay = storage.currentGiftDay;
// Refresh gifts display
hideGifts();
showGifts();
};
})(dailyGifts[day - 1], day);
}
}
// Back button
var giftsBackButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
giftsBackButton.x = 1024;
giftsBackButton.y = 1500;
var giftsBackButtonText = new Text2('BACK', {
size: 35,
fill: '#FFFFFF'
});
giftsBackButtonText.anchor.set(0.5, 0.5);
giftsBackButtonText.x = 1024;
giftsBackButtonText.y = 1500;
game.addChild(giftsBackButtonText);
giftsUIElements.push(giftsBackButton, giftsBackButtonText);
giftsBackButton.down = function () {
hideGifts();
};
}
function hideGifts() {
gameState = 'nickname';
// Remove all gifts UI elements
hideAllGiftsUI();
// Restore menu UI elements
showAllMenuUI();
coinsText.setText('Coins: ' + playerCoins);
}
function showTrade() {
gameState = 'trade';
// Hide all menu and game UI elements
hideAllMenuUI();
hideAllGameUI();
// Create trade display
var tradeTitle = new Text2('TİCARET SİSTEMİ', {
size: 80,
fill: '#FFFFFF'
});
tradeTitle.anchor.set(0.5, 0.5);
tradeTitle.x = 1024;
tradeTitle.y = 200;
game.addChild(tradeTitle);
tradeUIElements.push(tradeTitle);
// Coming soon message
var comingSoonText = new Text2('YAKINDA GELİYOR', {
size: 80,
fill: '#FFD700'
});
comingSoonText.anchor.set(0.5, 0.5);
comingSoonText.x = 1024;
comingSoonText.y = 600;
game.addChild(comingSoonText);
tradeUIElements.push(comingSoonText);
var comingSoonDesc = new Text2('Takas sistemi çok yakında aktif olacak!\nDaha fazla özellik için beklemede kalın.', {
size: 50,
fill: '#FFFFFF'
});
comingSoonDesc.anchor.set(0.5, 0.5);
comingSoonDesc.x = 1024;
comingSoonDesc.y = 800;
game.addChild(comingSoonDesc);
tradeUIElements.push(comingSoonDesc);
// Back button
var tradeBackButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
tradeBackButton.x = 1024;
tradeBackButton.y = 1500;
var tradeBackButtonText = new Text2('BACK', {
size: 35,
fill: '#FFFFFF'
});
tradeBackButtonText.anchor.set(0.5, 0.5);
tradeBackButtonText.x = 1024;
tradeBackButtonText.y = 1500;
game.addChild(tradeBackButtonText);
tradeUIElements.push(tradeBackButton, tradeBackButtonText);
tradeBackButton.down = function () {
hideTrade();
};
}
function showTradeSetup(targetPlayer) {
gameState = 'tradeSetup';
// Hide current trade UI
hideAllTradeUI();
// Create trade setup display
var setupTitle = new Text2('TAKAS KURULUMU: ' + targetPlayer, {
size: 70,
fill: '#FFFFFF'
});
setupTitle.anchor.set(0.5, 0.5);
setupTitle.x = 1024;
setupTitle.y = 200;
game.addChild(setupTitle);
tradeUIElements.push(setupTitle);
var instructionText = new Text2('En fazla 4 dinozor seçebilirsiniz', {
size: 50,
fill: '#FFD700'
});
instructionText.anchor.set(0.5, 0.5);
instructionText.x = 1024;
instructionText.y = 280;
game.addChild(instructionText);
tradeUIElements.push(instructionText);
// Track selected dinosaurs for trade
var selectedForTrade = [];
// Display available dinosaurs
var startY = 400;
for (var i = 0; i < dinosaurCollection.length; i++) {
var dinoName = dinosaurCollection[i];
var rarity = dinosaurRarities[dinoName];
var color = '#87CEEB';
if (rarity === 'chromatic') color = getRandomColor();else if (rarity === 'legendary') color = '#FF0000';else if (rarity === 'rare') color = '#800080';else if (rarity === 'common') color = '#00008B';
var isSelected = selectedForTrade.indexOf(dinoName) !== -1;
var displayText = dinoName + ' (' + rarity + ')' + (isSelected ? ' [SEÇİLDİ]' : '');
var dinoButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
dinoButton.x = 1024;
dinoButton.y = startY + i * 80;
var dinoText = new Text2(displayText, {
size: 35,
fill: isSelected ? '#32CD32' : color
});
dinoText.anchor.set(0.5, 0.5);
dinoText.x = 1024;
dinoText.y = startY + i * 80;
game.addChild(dinoText);
tradeUIElements.push(dinoButton, dinoText);
// Create closure for selection
(function (dinosaurName, textElement) {
dinoButton.down = function () {
var index = selectedForTrade.indexOf(dinosaurName);
if (index === -1) {
// Add to selection if under limit
if (selectedForTrade.length < 4) {
selectedForTrade.push(dinosaurName);
textElement.setText(dinosaurName + ' (' + dinosaurRarities[dinosaurName] + ') [SEÇİLDİ]');
textElement.fill = '#32CD32';
}
} else {
// Remove from selection
selectedForTrade.splice(index, 1);
var rarity = dinosaurRarities[dinosaurName];
var color = '#87CEEB';
if (rarity === 'chromatic') color = getRandomColor();else if (rarity === 'legendary') color = '#FF0000';else if (rarity === 'rare') color = '#800080';else if (rarity === 'common') color = '#00008B';
textElement.setText(dinosaurName + ' (' + rarity + ')');
textElement.fill = color;
}
};
})(dinoName, dinoText);
}
// Send trade request button
var sendRequestButton = game.attachAsset('purchaseButton', {
anchorX: 0.5,
anchorY: 0.5
});
sendRequestButton.x = 700;
sendRequestButton.y = 1500;
var sendRequestText = new Text2('TAKAS İSTEĞİ GÖNDER', {
size: 30,
fill: '#FFFFFF'
});
sendRequestText.anchor.set(0.5, 0.5);
sendRequestText.x = 700;
sendRequestText.y = 1500;
game.addChild(sendRequestText);
tradeUIElements.push(sendRequestButton, sendRequestText);
sendRequestButton.down = function () {
if (selectedForTrade.length > 0) {
createTradeOffer(targetPlayer, selectedForTrade);
hideTrade();
showTrade(); // Return to main trade screen
}
};
// Back button
var setupBackButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
setupBackButton.x = 1348;
setupBackButton.y = 1500;
var setupBackText = new Text2('GERİ', {
size: 35,
fill: '#FFFFFF'
});
setupBackText.anchor.set(0.5, 0.5);
setupBackText.x = 1348;
setupBackText.y = 1500;
game.addChild(setupBackText);
tradeUIElements.push(setupBackButton, setupBackText);
setupBackButton.down = function () {
hideTrade();
showTrade(); // Return to main trade screen
};
}
function hideTrade() {
gameState = 'nickname';
// Remove all trade UI elements
hideAllTradeUI();
// Restore menu UI elements
showAllMenuUI();
}
function showStock() {
gameState = 'stock';
// Hide all menu and game UI elements
hideAllMenuUI();
hideAllGameUI();
// Create stock display
var stockTitle = new Text2('DİNOZOR STOKU', {
size: 80,
fill: '#FFFFFF'
});
stockTitle.anchor.set(0.5, 0.5);
stockTitle.x = 1024;
stockTitle.y = 200;
game.addChild(stockTitle);
stockUIElements.push(stockTitle);
// Define dinosaur buy prices based on rarity and value (higher than sell prices)
var dinosaurBuyPrices = {
'PARASOUROLUPHUS': 1200,
'PYTHEREDON': 1350,
'DIMETRODON': 1500,
'BARYONYX': 3750,
'ALLO': 4500,
'YUTY': 5250,
'SPINO': 12000,
'GIGA': 15000,
'Mutated BARYONYX': 18000,
'Mutated DIMETRODON': 22500,
'Mutated PARASAUROLUPHUS': 27000
};
// Get all purchasable dinosaurs (all except TREX) - ordered by expensive dinosaur hierarchy
// SPINO (1st), GIGA (2nd), Mutated DIMETRODON (3rd), Mutated BARYONYX (4th), then others by price
var allDinosaurs = ['SPINO', 'GIGA', 'Mutated DIMETRODON', 'Mutated BARYONYX', 'Mutated PARASAUROLUPHUS', 'YUTY', 'ALLO', 'BARYONYX', 'DIMETRODON', 'PYTHEREDON', 'PARASOUROLUPHUS'];
// No need to sort as we've manually ordered them by hierarchy
// Show current coins
var coinsDisplayText = new Text2('Mevcut Para: ' + playerCoins + ' coin', {
size: 50,
fill: '#FFD700'
});
coinsDisplayText.anchor.set(0.5, 0.5);
coinsDisplayText.x = 1024;
coinsDisplayText.y = 280;
game.addChild(coinsDisplayText);
stockUIElements.push(coinsDisplayText);
// Show instruction
var instructionText = new Text2('Satın almak istediğiniz dinozorları seçin (TREX satın alınamaz)', {
size: 40,
fill: '#CCCCCC'
});
instructionText.anchor.set(0.5, 0.5);
instructionText.x = 1024;
instructionText.y = 340;
game.addChild(instructionText);
stockUIElements.push(instructionText);
// Track selected dinosaurs for buying
var selectedForBuying = [];
// Display purchasable dinosaurs
var startY = 500;
var itemSpacing = 120; // Increased spacing between dinosaur entries
for (var n = 0; n < allDinosaurs.length; n++) {
var dinoName = allDinosaurs[n];
var rarity = dinosaurRarities[dinoName];
var price = dinosaurBuyPrices[dinoName];
// Get rarity color
var color = '#87CEEB'; // Light blue for common
if (rarity === 'chromatic') color = getRandomColor(); // Rainbow for chromatic
else 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 displayText = dinoName + ' (' + rarity + ') - ' + price + ' coin';
var canAfford = playerCoins >= price;
var dinoButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
dinoButton.x = 1024;
dinoButton.y = startY + n * itemSpacing;
// Dim button if can't afford
if (!canAfford) {
dinoButton.alpha = 0.5;
}
// Add dinosaur image
var dinoImage = new DinosaurImage(dinoName);
dinoImage.x = 400;
dinoImage.y = startY + n * itemSpacing;
dinoImage.scaleX = 0.6;
dinoImage.scaleY = 0.6;
if (!canAfford) {
dinoImage.alpha = 0.5;
}
game.addChild(dinoImage);
stockUIElements.push(dinoImage);
var dinoText = new Text2(displayText, {
size: 35,
fill: canAfford ? color : '#666666'
});
dinoText.anchor.set(0.5, 0.5);
dinoText.x = 1024;
dinoText.y = startY + n * itemSpacing;
game.addChild(dinoText);
var statusText = new Text2(canAfford ? 'SATIN ALINABILìR' : 'YETERSìZ PARA', {
size: 25,
fill: canAfford ? '#32CD32' : '#FF4444'
});
statusText.anchor.set(0.5, 0.5);
statusText.x = 1024;
statusText.y = startY + n * itemSpacing + 25;
game.addChild(statusText);
stockUIElements.push(dinoButton, dinoText, statusText);
// Create closure for purchase
(function (dinosaurName, buyPrice, textElement, buttonElement, statusElement, imageElement) {
dinoButton.down = function () {
if (playerCoins >= buyPrice) {
// Purchase dinosaur
playerCoins -= buyPrice;
storage.playerCoins = playerCoins;
// Add dinosaur to collection
dinosaurCollection.push(dinosaurName);
storage.dinosaurCollection = dinosaurCollection;
// Update display
coinsDisplayText.setText('Mevcut Para: ' + playerCoins + ' coin');
// Refresh stock display
hideStock();
showStock();
}
};
})(dinoName, price, dinoText, dinoButton, statusText, dinoImage);
}
// Back button centered
var stockBackButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
stockBackButton.x = 1024;
stockBackButton.y = startY + allDinosaurs.length * itemSpacing + 50;
var stockBackButtonText = new Text2('BACK', {
size: 35,
fill: '#FFFFFF'
});
stockBackButtonText.anchor.set(0.5, 0.5);
stockBackButtonText.x = 1024;
stockBackButtonText.y = startY + allDinosaurs.length * itemSpacing + 50;
game.addChild(stockBackButtonText);
stockUIElements.push(stockBackButton, stockBackButtonText);
// Event handlers
stockBackButton.down = function () {
hideStock();
};
}
function hideStock() {
gameState = 'nickname';
// Remove all stock UI elements
hideAllStockUI();
// Restore menu UI elements
showAllMenuUI();
coinsText.setText('Coins: ' + playerCoins);
}
function checkDinosaurHunger() {
var currentTime = Date.now();
var timePassed = currentTime - lastFeedingCheck;
// Check hunger every hour (3600000 ms)
if (timePassed >= 3600000) {
var hungerIncrease = Math.floor(timePassed / 3600000);
// Initialize hunger for new dinosaurs and increase hunger for existing ones
for (var i = 0; i < dinosaurCollection.length; i++) {
var dinoName = dinosaurCollection[i];
if (!dinosaurHunger[dinoName]) {
dinosaurHunger[dinoName] = 0; // New dinosaurs start with 0 hunger
} else {
dinosaurHunger[dinoName] += hungerIncrease;
}
}
// Update storage without removing any dinosaurs
storage.dinosaurCollection = dinosaurCollection;
storage.dinosaurHunger = dinosaurHunger;
storage.lastFeedingCheck = currentTime;
lastFeedingCheck = currentTime;
}
}
function showStarvationNotification(starvedDinosaurs) {
gameState = 'starvationNotification';
hideAllMenuUI();
hideAllGameUI();
var notificationTitle = new Text2('DİNOZORLAR AÇLIKTAN ÖLDÜ!', {
size: 80,
fill: '#FF4444'
});
notificationTitle.anchor.set(0.5, 0.5);
notificationTitle.x = 1024;
notificationTitle.y = 400;
game.addChild(notificationTitle);
infoUIElements.push(notificationTitle);
var starvedText = 'Açlıktan ölen dinozorlar:\n';
for (var i = 0; i < starvedDinosaurs.length; i++) {
starvedText += starvedDinosaurs[i] + '\n';
}
starvedText += '\nDinozorlarınızı düzenli olarak besleyin!';
var notificationMessage = new Text2(starvedText, {
size: 50,
fill: '#FFFFFF'
});
notificationMessage.anchor.set(0.5, 0.5);
notificationMessage.x = 1024;
notificationMessage.y = 700;
game.addChild(notificationMessage);
infoUIElements.push(notificationMessage);
var okButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
okButton.x = 1024;
okButton.y = 1000;
var okButtonText = new Text2('TAMAM', {
size: 35,
fill: '#FFFFFF'
});
okButtonText.anchor.set(0.5, 0.5);
okButtonText.x = 1024;
okButtonText.y = 1000;
game.addChild(okButtonText);
infoUIElements.push(okButton, okButtonText);
okButton.down = function () {
hideInfoScreen();
gameState = 'nickname';
showAllMenuUI();
};
}
function feedDinosaur(dinosaurName) {
var diet = dinosaurDiets[dinosaurName];
var hasFood = false;
// Check if player has the required food type
if (diet === 'leaf' && leafFood > 0) {
leafFood--;
storage.leafFood = leafFood;
hasFood = true;
} else if (diet === 'meat' && meatFood > 0) {
meatFood--;
storage.meatFood = meatFood;
hasFood = true;
} else if (diet === 'fish' && fishFood > 0) {
fishFood--;
storage.fishFood = fishFood;
hasFood = true;
}
if (hasFood) {
// Reset hunger to 0
dinosaurHunger[dinosaurName] = 0;
storage.dinosaurHunger = dinosaurHunger;
return true;
}
return false;
}
function getHungerStatus(dinosaurName) {
var hunger = dinosaurHunger[dinosaurName] || 0;
if (hunger >= 20) return 'VERY_HUNGRY';
if (hunger >= 12) return 'HUNGRY';
if (hunger >= 6) return 'SOMEWHAT_HUNGRY';
return 'FED';
}
function getHungerColor(status) {
switch (status) {
case 'VERY_HUNGRY':
return '#FF0000';
case 'HUNGRY':
return '#FF8800';
case 'SOMEWHAT_HUNGRY':
return '#FFFF00';
default:
return '#00FF00';
}
}
function getHungerText(status) {
switch (status) {
case 'VERY_HUNGRY':
return 'ÇOK AÇ!';
case 'HUNGRY':
return 'AÇ';
case 'SOMEWHAT_HUNGRY':
return 'BIRAZ AÇ';
default:
return 'TOK';
}
}
function canDinosaurUseAbilities(dinosaurName) {
var hungerStatus = getHungerStatus(dinosaurName);
// Dinosaurs can only use abilities when fed (not hungry)
return hungerStatus === 'FED';
}
function startGame() {
if (playerNickname.length === 0) {
return;
}
// Check dinosaur hunger when starting game
checkDinosaurHunger();
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;
// Show ability button
abilityUseButton.visible = true;
abilityUseText.visible = true;
// Start from saved level or level 1 if no save exists
startLevel(currentLevelNumber);
}
// 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();
};
tradeButton.down = function (x, y, obj) {
if (gameState !== 'nickname') {
return;
}
showTrade();
};
giftsButton.down = function (x, y, obj) {
if (gameState !== 'nickname') {
return;
}
showGifts();
};
stockButton.down = function (x, y, obj) {
if (gameState !== 'nickname') {
return;
}
showStock();
};
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));
// Check dinosaur hunger periodically (every 30 seconds in-game)
if (levelTimer % 1800 === 0) {
checkDinosaurHunger();
}
// 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());
}
// Update ability button text based on selected dinosaur and level restrictions
if (selectedDinosaur) {
var buttonText = selectedDinosaur + ' ÖZELLİĞİ';
var canUse = true;
// Check if dinosaur is too hungry to use abilities
if (!canDinosaurUseAbilities(selectedDinosaur)) {
var hungerStatus = getHungerStatus(selectedDinosaur);
buttonText = selectedDinosaur + ' (AÇ - BESLEYİN)';
canUse = false;
} else if (selectedDinosaur === 'TREX' && currentLevelNumber % 10 !== 0) {
buttonText = 'TREX (' + (10 - currentLevelNumber % 10) + ' seviye)';
canUse = false;
} else if (selectedDinosaur === 'SPINO' && storage.spinoUsedThisLevel) {
buttonText = 'SPINO (kullanıldı)';
canUse = false;
} else if (selectedDinosaur === 'GIGA') {
buttonText = 'GIGA ÖZELLİĞİ';
} else if (selectedDinosaur === 'Mutated DIMETRODON' && currentLevelNumber % 3 !== 0) {
buttonText = 'M.DIMETRODON (' + (3 - currentLevelNumber % 3) + ' seviye)';
canUse = false;
} else if (selectedDinosaur === 'Mutated BARYONYX' && currentLevelNumber % 4 !== 0) {
buttonText = 'M.BARYONYX (' + (4 - currentLevelNumber % 4) + ' seviye)';
canUse = false;
} else if (selectedDinosaur === 'Mutated PARASAUROLUPHUS') {
var currentUsage = storage.mutatedParasaurolophusMatches || 0;
if ((currentUsage + 1) % 2 !== 0) {
buttonText = 'M.PARASAUR (' + (2 - (currentUsage + 1) % 2) + ' kullanım)';
canUse = false;
}
}
abilityUseText.setText(buttonText);
abilityUseButton.alpha = canUse ? 1.0 : 0.5;
} else {
abilityUseText.setText('DİNOZOR SEÇ');
abilityUseButton.alpha = 0.5;
}
}
};
// 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) {
// Make blocks with fossils green and animate with tween
tween(block, {
tint: 0x00FF00
}, {
duration: 500,
easing: tween.easeOut
});
}
}
}
}
};
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 = 524; // Further left with more spacing
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 = 524;
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 = 1524; // Further right with more spacing
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 = 1524;
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) {
// Make blocks with fossils green and animate with tween
tween(block, {
tint: 0x00FF00
}, {
duration: 500,
easing: tween.easeOut
});
}
}
}
}
};
// Dinosaur ability use button (shown when game is playing)
var abilityUseButton = game.attachAsset('purchaseButton', {
anchorX: 0.5,
anchorY: 0.5
});
abilityUseButton.x = 1024; // Center bottom
abilityUseButton.y = 2500; // Bottom of screen
abilityUseButton.visible = false;
var abilityUseText = new Text2('DİNOZOR ÖZELLİĞİ', {
size: 25,
fill: '#FFFFFF'
});
abilityUseText.anchor.set(0.5, 0.5);
abilityUseText.x = 1024;
abilityUseText.y = 2500;
abilityUseText.visible = false;
game.addChild(abilityUseText);
// Track ability button as game UI
gameUIElements.push(abilityUseButton, abilityUseText);
// Ability use button click handler
abilityUseButton.down = function (x, y, obj) {
if (gameState === 'playing' && selectedDinosaur && currentLevel) {
// Check if dinosaur can use abilities (not too hungry)
if (!canDinosaurUseAbilities(selectedDinosaur)) {
// Dinosaur is too hungry to use abilities
return;
}
// Use the selected dinosaur's ability
if (selectedDinosaur === 'TREX') {
// TREX roars and collects all fossils (only works every 10 levels)
if (currentLevelNumber % 10 === 0) {
// Create roar effect with screen shake animation
var roarEffect = LK.getAsset('TREX', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 3.0,
scaleY: 3.0
});
roarEffect.x = 1024;
roarEffect.y = 1000;
roarEffect.alpha = 0.7;
roarEffect.tint = 0xFF4500; // Orange roar effect
currentLevel.addChild(roarEffect);
// Animate roar effect with tween
tween(roarEffect, {
scaleX: 5.0,
scaleY: 5.0,
alpha: 0
}, {
duration: 2000,
easing: tween.easeOut,
onFinish: function onFinish() {
roarEffect.destroy();
}
});
// Collect all fossils on the level instantly
for (var i = 0; i < currentLevel.blocks.length; i++) {
var block = currentLevel.blocks[i];
if (block.hasFossil && !block.isCollected) {
// Instantly reveal and collect the fossil
currentLevel.revealFossil(block.fossilType, block.x, block.y);
// Mark block as collected
block.isCollected = true;
block.alpha = 0;
}
}
}
} else if (selectedDinosaur === 'SPINO') {
// SPINO tail strike - find a random block and break 3 in line (1 use per level)
if (storage.spinoUsedThisLevel) {
// Already used this level, do nothing
return;
}
if (currentLevel.blocks.length > 0) {
storage.spinoUsedThisLevel = true;
// Create visual tail strike effect
var tailStrikeEffect = LK.getAsset('SPINO', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2.0,
scaleY: 2.0
});
tailStrikeEffect.x = 1024;
tailStrikeEffect.y = 1000;
tailStrikeEffect.alpha = 0.8;
tailStrikeEffect.tint = 0x228B22; // Green tail strike effect
currentLevel.addChild(tailStrikeEffect);
// Animate tail strike effect
tween(tailStrikeEffect, {
scaleX: 3.5,
scaleY: 1.5,
alpha: 0
}, {
duration: 1000,
easing: tween.easeOut,
onFinish: function onFinish() {
tailStrikeEffect.destroy();
}
});
var randomIndex = Math.floor(Math.random() * currentLevel.blocks.length);
var block = currentLevel.blocks[randomIndex];
if (!block.isCollected) {
var blocksToBreak = [block];
var blocksPerRow = 8;
var row = Math.floor(randomIndex / blocksPerRow);
var col = randomIndex % blocksPerRow;
// Add 2 blocks to the right
for (var j = 1; j <= 2; j++) {
if (col + j < blocksPerRow) {
var blockIndex = row * blocksPerRow + (col + j);
if (blockIndex < currentLevel.blocks.length) {
var nextBlock = currentLevel.blocks[blockIndex];
if (!nextBlock.isCollected) {
blocksToBreak.push(nextBlock);
}
}
}
}
// Break all blocks
for (var k = 0; k < blocksToBreak.length; k++) {
blocksToBreak[k].performCollection();
}
}
}
} else if (selectedDinosaur === 'GIGA') {
// GIGA breaks all rocks instantly every level
// Create visual effect for GIGA ability
var gigaEffect = LK.getAsset('GIGA', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2.5,
scaleY: 2.5
});
gigaEffect.x = 1024;
gigaEffect.y = 1000;
gigaEffect.alpha = 0.8;
gigaEffect.tint = 0x800080; // Purple effect for GIGA
currentLevel.addChild(gigaEffect);
// Animate GIGA effect with tween
tween(gigaEffect, {
scaleX: 4.0,
scaleY: 4.0,
alpha: 0
}, {
duration: 1500,
easing: tween.easeOut,
onFinish: function onFinish() {
gigaEffect.destroy();
}
});
// Break all rocks instantly
for (var i = 0; i < currentLevel.blocks.length; i++) {
var block = currentLevel.blocks[i];
if (!block.isCollected) {
block.currentHits = block.hitsRequired; // Set hits to required amount
block.performCollection(); // Break the block instantly
}
}
} else if (selectedDinosaur === 'Mutated DIMETRODON') {
// Mutated DIMETRODON collects 3 most valuable fossils every 3 levels
if (currentLevelNumber % 3 === 0) {
// Find available 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 fossils
var fossilsToCollect = Math.min(3, availableFossils.length);
for (var j = 0; j < fossilsToCollect; j++) {
availableFossils[j].collectFossil();
}
}
} else if (selectedDinosaur === 'Mutated BARYONYX') {
// Mutated BARYONYX ability every 4 levels - reduce hit requirements for all blocks
if (currentLevelNumber % 4 === 0) {
for (var i = 0; i < currentLevel.blocks.length; i++) {
var block = currentLevel.blocks[i];
if (!block.isCollected) {
// Set reduced hit requirements: normal blocks 1 hit, hard blocks 3 hits, ultra hard blocks 6 hits
block.hitsRequired = block.blockType === 'ultraHardBlock' ? 6 : block.blockType === 'hardRock' ? 3 : 1;
}
}
}
} else if (selectedDinosaur === 'Mutated PARASAUROLUPHUS') {
// Mutated PARASAUROLUPHUS ability every 2 matches with reduced hits
var currentUsage = storage.mutatedParasaurolophusMatches || 0;
currentUsage++;
storage.mutatedParasaurolophusMatches = currentUsage;
if (currentUsage % 2 === 0) {
for (var i = 0; i < currentLevel.blocks.length; i++) {
var block = currentLevel.blocks[i];
if (!block.isCollected) {
// Set reduced hit requirements: normal blocks 2 hits, hard blocks 4 hits, ultra hard blocks 7 hits
block.hitsRequired = block.blockType === 'ultraHardBlock' ? 7 : block.blockType === 'hardRock' ? 4 : 2;
}
}
}
} else {
// For other dinosaurs with no special button ability, show message or do nothing
}
}
};
// 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');