/**** * Plugins ****/ var storage = LK.import("@upit/storage.v1"); var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var BreedingPair = Container.expand(function (monster1Type, monster2Type) { var self = Container.call(this); self.monster1Type = monster1Type; self.monster2Type = monster2Type; var button = self.attachAsset('breedButton', { anchorX: 0.5, anchorY: 0.5 }); var breedText = new Text2("Breed", { size: 24, fill: 0xFFFFFF }); breedText.anchor.set(0.5, 0.5); breedText.y = -10; self.addChild(breedText); var pairText = new Text2(monster1Type + " + " + monster2Type, { size: 16, fill: 0xFFFFFF }); pairText.anchor.set(0.5, 0.5); pairText.y = 10; self.addChild(pairText); self.down = function (x, y, obj) { attemptBreeding(self.monster1Type, self.monster2Type); }; return self; }); var Monster = Container.expand(function (monsterType) { var self = Container.call(this); self.monsterType = monsterType || 'Rectertik'; var assetName = getAssetNameForMonster(self.monsterType); var monsterGraphics = self.attachAsset(assetName, { anchorX: 0.5, anchorY: 0.5 }); // Add type label var typeText = new Text2(self.monsterType, { size: 24, fill: 0x000000 }); typeText.anchor.set(0.5, 0.5); typeText.y = 80; self.addChild(typeText); self.down = function (x, y, obj) { // Visual feedback on tap LK.effects.flashObject(self, 0xFFFFFF, 200); // Play monster sound var soundName = getMonsterSoundName(self.monsterType); LK.getSound(soundName).play(); // Start dancing animation self.startDancing(); }; self.startDancing = function () { // Initialize dance counter if not exists if (self.danceCount === undefined) { self.danceCount = 0; } // Stop dancing if we've already danced twice if (self.danceCount >= 2) { self.danceCount = 0; // Reset counter for next time return; } // Increment dance counter self.danceCount++; // Stop any existing tweens tween.stop(monsterGraphics); tween.stop(self); // Dance sequence: bounce up and down while rotating tween(monsterGraphics, { rotation: Math.PI / 8 }, { duration: 200, easing: tween.easeInOut }); tween(self, { scaleX: 1.2, scaleY: 1.2 }, { duration: 200, easing: tween.easeOut, onFinish: function onFinish() { tween(monsterGraphics, { rotation: -Math.PI / 8 }, { duration: 200, easing: tween.easeInOut }); tween(self, { scaleX: 0.8, scaleY: 1.3 }, { duration: 200, easing: tween.easeInOut, onFinish: function onFinish() { tween(monsterGraphics, { rotation: 0 }, { duration: 200, easing: tween.easeInOut }); tween(self, { scaleX: 1, scaleY: 1 }, { duration: 200, easing: tween.bounceOut, onFinish: function onFinish() { // Call startDancing again to play the dance a second time self.startDancing(); } }); } }); } }); }; return self; }); var ShopItem = Container.expand(function (monsterType, price, currency) { var self = Container.call(this); self.monsterType = monsterType; self.price = price; self.currency = currency; var button = self.attachAsset('button', { anchorX: 0.5, anchorY: 0.5 }); var nameText = new Text2(monsterType, { size: 28, fill: 0x000000 }); nameText.anchor.set(0.5, 0.5); nameText.y = -15; self.addChild(nameText); var priceText = new Text2(price + " " + currency, { size: 24, fill: 0xFFD700 }); priceText.anchor.set(0.5, 0.5); priceText.y = 15; self.addChild(priceText); self.down = function (x, y, obj) { purchaseMonster(self.monsterType, self.price, self.currency); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x1A237E }); /**** * Game Code ****/ // Add background var bg = game.attachAsset('Bg', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2, scaleX: 2048 / 500, scaleY: 2732 / 1000 }); // Game data - can optionally be saved var gameData = { coins: 100, diamonds: 5, emeralds: 10, monsters: ["Rectertik"], monsterCounts: {} }; // Save/Load functions function saveProgress() { storage.coins = gameData.coins; storage.diamonds = gameData.diamonds; storage.emeralds = gameData.emeralds; storage.monsters = gameData.monsters; storage.monsterCounts = gameData.monsterCounts; LK.effects.flashScreen(0x00FF00, 300); } function loadProgress() { if (storage.coins !== undefined) { gameData.coins = storage.coins; gameData.diamonds = storage.diamonds; gameData.emeralds = storage.emeralds || 10; gameData.monsters = storage.monsters || ["Rectertik"]; gameData.monsterCounts = storage.monsterCounts || {}; updateCurrency(); refreshCollection(); LK.effects.flashScreen(0x0000FF, 300); } else { LK.effects.flashScreen(0xFF0000, 300); } } function deleteProgress() { // Reset storage by setting to default values instead of undefined storage.coins = 100; storage.diamonds = 5; storage.emeralds = 10; storage.monsters = ["Rectertik"]; storage.monsterCounts = {}; gameData = { coins: 100, diamonds: 5, emeralds: 10, //{emeralds_reset} monsters: ["Rectertik"], monsterCounts: {} }; updateCurrency(); refreshCollection(); LK.effects.flashScreen(0xFF0000, 300); } function getAssetNameForMonster(monsterType) { // Remove spaces and handle special cases var assetName = monsterType.replace(/\s+/g, ''); return assetName; } function getMonsterSoundName(monsterType) { // Map monster types to their sound names if (monsterType.indexOf('Rectertik') !== -1) { return 'rectertikSound'; } else if (monsterType.indexOf('Antilla') !== -1) { return 'antillaSound'; } else if (monsterType.indexOf('Shapana') !== -1) { return 'shapanaSound'; } else if (monsterType.indexOf('Zingting') !== -1) { return 'zingtingSound'; } else if (monsterType.indexOf('Sunna') !== -1) { return 'sunnasound'; } // Default fallback return 'rectertikSound'; } var currentView = 'collection'; // 'collection', 'shop', 'breeding' var collectionMonsters = []; var shopItems = []; var breedingPairs = []; // UI Elements var coinText = new Text2('Coins: ' + gameData.coins, { size: 36, fill: 0xFFD700 }); coinText.anchor.set(0, 0); coinText.x = 120; coinText.y = 50; LK.gui.topLeft.addChild(coinText); var diamondText = new Text2('Diamonds: ' + gameData.diamonds, { size: 36, fill: 0x00BCD4 }); diamondText.anchor.set(0, 0); diamondText.x = 120; diamondText.y = 100; LK.gui.topLeft.addChild(diamondText); var emeraldText = new Text2('Emeralds: ' + gameData.emeralds, { size: 36, fill: 0x00FF7F }); emeraldText.anchor.set(0, 0); emeraldText.x = 120; emeraldText.y = 150; LK.gui.topLeft.addChild(emeraldText); // Save/Load/Delete buttons var saveBtn = new Text2('Save', { size: 28, fill: 0x00FF00 }); saveBtn.anchor.set(0.5, 0); saveBtn.x = 2048 / 6; saveBtn.y = 200; game.addChild(saveBtn); var loadBtn = new Text2('Load', { size: 28, fill: 0x0000FF }); loadBtn.anchor.set(0.5, 0); loadBtn.x = 2048 / 3; loadBtn.y = 200; game.addChild(loadBtn); var deleteBtn = new Text2('Delete', { size: 28, fill: 0xFF0000 }); deleteBtn.anchor.set(0.5, 0); deleteBtn.x = 5 * 2048 / 6; deleteBtn.y = 200; game.addChild(deleteBtn); // Navigation buttons var collectionBtn = new Text2('Collection', { size: 32, fill: 0x000000 }); collectionBtn.anchor.set(0.5, 0); collectionBtn.x = 2048 / 4; collectionBtn.y = 150; game.addChild(collectionBtn); var shopBtn = new Text2('Shop', { size: 32, fill: 0x000000 }); shopBtn.anchor.set(0.5, 0); shopBtn.x = 2048 / 2; shopBtn.y = 150; game.addChild(shopBtn); var breedingBtn = new Text2('Breeding', { size: 32, fill: 0x000000 }); breedingBtn.anchor.set(0.5, 0); breedingBtn.x = 3 * 2048 / 4; breedingBtn.y = 150; game.addChild(breedingBtn); // Shop data var shopData = [{ type: 'Rectertik', price: 50, currency: 'coins' }, { type: 'Antilla', price: 100, currency: 'coins' }, { type: 'Rare Rectertik', price: 5, currency: 'diamonds' }, { type: 'Rare Antilla', price: 10, currency: 'diamonds' }, { type: 'Shapana', price: 500, currency: 'coins' }, { type: 'Epic Rectertik', price: 25, currency: 'diamonds' }, { type: 'Epic Antilla', price: 25, currency: 'diamonds' }, { type: 'Rare Shapana', price: 25, currency: 'diamonds' }, { type: 'Epic Shapana', price: 25, currency: 'diamonds' }, { type: 'Zingting', price: 25, currency: 'diamonds' }, { type: 'Rare Zingting', price: 25, currency: 'diamonds' }, { type: 'Epic Zingting', price: 25, currency: 'diamonds' }, { type: 'Sunna', price: 50, currency: 'emeralds' }]; function updateCurrency() { coinText.setText('Coins: ' + gameData.coins); diamondText.setText('Diamonds: ' + gameData.diamonds); emeraldText.setText('Emeralds: ' + gameData.emeralds); } function purchaseMonster(monsterType, price, currency) { if (currency === 'coins' && gameData.coins >= price) { gameData.coins -= price; addMonster(monsterType); updateCurrency(); LK.effects.flashScreen(0x00FF00, 300); } else if (currency === 'diamonds' && gameData.diamonds >= price) { gameData.diamonds -= price; addMonster(monsterType); updateCurrency(); LK.effects.flashScreen(0x00FF00, 300); } else if (currency === 'emeralds' && gameData.emeralds >= price) { gameData.emeralds -= price; addMonster(monsterType); updateCurrency(); LK.effects.flashScreen(0x00FF00, 300); } else { LK.effects.flashScreen(0xFF0000, 300); } } function addMonster(monsterType) { gameData.monsterCounts[monsterType] = (gameData.monsterCounts[monsterType] || 0) + 1; if (gameData.monsters.indexOf(monsterType) === -1) { gameData.monsters.push(monsterType); } refreshCollection(); } function attemptBreeding(monster1Type, monster2Type) { // Check if player has both monsters if (gameData.monsterCounts[monster1Type] > 0 && gameData.monsterCounts[monster2Type] > 0) { var result = getBreedingResult(monster1Type, monster2Type); if (result) { addMonster(result); LK.effects.flashScreen(0x00FF00, 500); } } else { LK.effects.flashScreen(0xFF0000, 300); } } function getBreedingResult(monster1, monster2) { // Shapana = any Rectertik form + any Antilla form if (isRectertikForm(monster1) && isAntillaForm(monster2) || isAntillaForm(monster1) && isRectertikForm(monster2)) { return 'Shapana'; } // Zingting = any Antilla form + another Antilla form if (isAntillaForm(monster1) && isAntillaForm(monster2)) { return 'Zingting'; } return null; } function isRectertikForm(monsterType) { return monsterType.indexOf('Rectertik') !== -1; } function isAntillaForm(monsterType) { return monsterType.indexOf('Antilla') !== -1; } function clearView() { for (var i = collectionMonsters.length - 1; i >= 0; i--) { collectionMonsters[i].destroy(); } collectionMonsters = []; for (var j = shopItems.length - 1; j >= 0; j--) { shopItems[j].destroy(); } shopItems = []; for (var k = breedingPairs.length - 1; k >= 0; k--) { breedingPairs[k].destroy(); } breedingPairs = []; } function showCollection() { clearView(); currentView = 'collection'; var yPos = 300; var xPos = 200; var monstersPerRow = 4; var currentRow = 0; for (var i = 0; i < gameData.monsters.length; i++) { var monsterType = gameData.monsters[i]; var count = gameData.monsterCounts[monsterType]; if (count > 0) { var monster = new Monster(monsterType); monster.x = xPos + currentRow * 400; monster.y = yPos; game.addChild(monster); collectionMonsters.push(monster); // Add count text var countText = new Text2('x' + count, { size: 20, fill: 0x000000 }); countText.anchor.set(0.5, 0.5); countText.x = monster.x + 60; countText.y = monster.y - 60; game.addChild(countText); collectionMonsters.push(countText); currentRow++; if (currentRow >= monstersPerRow) { currentRow = 0; yPos += 200; } } } } function showShop() { clearView(); currentView = 'shop'; var yPos = 300; var xPos = 2048 / 2; for (var i = 0; i < shopData.length; i++) { var item = shopData[i]; var shopItem = new ShopItem(item.type, item.price, item.currency); shopItem.x = xPos; shopItem.y = yPos + i * 100; game.addChild(shopItem); shopItems.push(shopItem); } } function showBreeding() { clearView(); currentView = 'breeding'; var yPos = 300; var xPos = 2048 / 2; // Show available breeding combinations var combinations = [{ monster1: 'Rectertik', monster2: 'Antilla', result: 'Shapana' }, { monster1: 'Rare Rectertik', monster2: 'Antilla', result: 'Shapana' }, { monster1: 'Rectertik', monster2: 'Rare Antilla', result: 'Shapana' }, { monster1: 'Antilla', monster2: 'Antilla', result: 'Zingting' }, { monster1: 'Rare Antilla', monster2: 'Antilla', result: 'Zingting' }]; for (var i = 0; i < combinations.length; i++) { var combo = combinations[i]; var breedPair = new BreedingPair(combo.monster1, combo.monster2); breedPair.x = xPos; breedPair.y = yPos + i * 80; game.addChild(breedPair); breedingPairs.push(breedPair); } } function refreshCollection() { if (currentView === 'collection') { showCollection(); } } // Navigation event handlers game.down = function (x, y, obj) { // Use x, y directly as they are already in the correct coordinate space // Check navigation buttons if (y >= 150 && y <= 182) { if (x >= 2048 / 4 - 100 && x <= 2048 / 4 + 100) { showCollection(); } else if (x >= 2048 / 2 - 50 && x <= 2048 / 2 + 50) { showShop(); } else if (x >= 3 * 2048 / 4 - 100 && x <= 3 * 2048 / 4 + 100) { showBreeding(); } } // Check save/load/delete buttons if (y >= 200 && y <= 228) { if (x >= 2048 / 6 - 50 && x <= 2048 / 6 + 50) { saveProgress(); } else if (x >= 2048 / 3 - 50 && x <= 2048 / 3 + 50) { loadProgress(); } else if (x >= 5 * 2048 / 6 - 50 && x <= 5 * 2048 / 6 + 50) { deleteProgress(); } } }; // Timer for passive income generation var incomeTimer = LK.setInterval(function () { var totalMonsters = 0; for (var monsterType in gameData.monsterCounts) { totalMonsters += gameData.monsterCounts[monsterType]; } if (totalMonsters > 0) { var coinsToAdd = totalMonsters * 0.5; var diamondsToAdd = totalMonsters * 0.5; var emeraldsToAdd = totalMonsters * 0.5; gameData.coins = Math.floor((gameData.coins || 0) + coinsToAdd); gameData.diamonds = Math.floor((gameData.diamonds || 0) + diamondsToAdd); gameData.emeralds = Math.floor((gameData.emeralds || 0) + emeraldsToAdd); updateCurrency(); } }, 1000); // Initialize with collection view showCollection();
/****
* Plugins
****/
var storage = LK.import("@upit/storage.v1");
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var BreedingPair = Container.expand(function (monster1Type, monster2Type) {
var self = Container.call(this);
self.monster1Type = monster1Type;
self.monster2Type = monster2Type;
var button = self.attachAsset('breedButton', {
anchorX: 0.5,
anchorY: 0.5
});
var breedText = new Text2("Breed", {
size: 24,
fill: 0xFFFFFF
});
breedText.anchor.set(0.5, 0.5);
breedText.y = -10;
self.addChild(breedText);
var pairText = new Text2(monster1Type + " + " + monster2Type, {
size: 16,
fill: 0xFFFFFF
});
pairText.anchor.set(0.5, 0.5);
pairText.y = 10;
self.addChild(pairText);
self.down = function (x, y, obj) {
attemptBreeding(self.monster1Type, self.monster2Type);
};
return self;
});
var Monster = Container.expand(function (monsterType) {
var self = Container.call(this);
self.monsterType = monsterType || 'Rectertik';
var assetName = getAssetNameForMonster(self.monsterType);
var monsterGraphics = self.attachAsset(assetName, {
anchorX: 0.5,
anchorY: 0.5
});
// Add type label
var typeText = new Text2(self.monsterType, {
size: 24,
fill: 0x000000
});
typeText.anchor.set(0.5, 0.5);
typeText.y = 80;
self.addChild(typeText);
self.down = function (x, y, obj) {
// Visual feedback on tap
LK.effects.flashObject(self, 0xFFFFFF, 200);
// Play monster sound
var soundName = getMonsterSoundName(self.monsterType);
LK.getSound(soundName).play();
// Start dancing animation
self.startDancing();
};
self.startDancing = function () {
// Initialize dance counter if not exists
if (self.danceCount === undefined) {
self.danceCount = 0;
}
// Stop dancing if we've already danced twice
if (self.danceCount >= 2) {
self.danceCount = 0; // Reset counter for next time
return;
}
// Increment dance counter
self.danceCount++;
// Stop any existing tweens
tween.stop(monsterGraphics);
tween.stop(self);
// Dance sequence: bounce up and down while rotating
tween(monsterGraphics, {
rotation: Math.PI / 8
}, {
duration: 200,
easing: tween.easeInOut
});
tween(self, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 200,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(monsterGraphics, {
rotation: -Math.PI / 8
}, {
duration: 200,
easing: tween.easeInOut
});
tween(self, {
scaleX: 0.8,
scaleY: 1.3
}, {
duration: 200,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(monsterGraphics, {
rotation: 0
}, {
duration: 200,
easing: tween.easeInOut
});
tween(self, {
scaleX: 1,
scaleY: 1
}, {
duration: 200,
easing: tween.bounceOut,
onFinish: function onFinish() {
// Call startDancing again to play the dance a second time
self.startDancing();
}
});
}
});
}
});
};
return self;
});
var ShopItem = Container.expand(function (monsterType, price, currency) {
var self = Container.call(this);
self.monsterType = monsterType;
self.price = price;
self.currency = currency;
var button = self.attachAsset('button', {
anchorX: 0.5,
anchorY: 0.5
});
var nameText = new Text2(monsterType, {
size: 28,
fill: 0x000000
});
nameText.anchor.set(0.5, 0.5);
nameText.y = -15;
self.addChild(nameText);
var priceText = new Text2(price + " " + currency, {
size: 24,
fill: 0xFFD700
});
priceText.anchor.set(0.5, 0.5);
priceText.y = 15;
self.addChild(priceText);
self.down = function (x, y, obj) {
purchaseMonster(self.monsterType, self.price, self.currency);
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x1A237E
});
/****
* Game Code
****/
// Add background
var bg = game.attachAsset('Bg', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2,
scaleX: 2048 / 500,
scaleY: 2732 / 1000
});
// Game data - can optionally be saved
var gameData = {
coins: 100,
diamonds: 5,
emeralds: 10,
monsters: ["Rectertik"],
monsterCounts: {}
};
// Save/Load functions
function saveProgress() {
storage.coins = gameData.coins;
storage.diamonds = gameData.diamonds;
storage.emeralds = gameData.emeralds;
storage.monsters = gameData.monsters;
storage.monsterCounts = gameData.monsterCounts;
LK.effects.flashScreen(0x00FF00, 300);
}
function loadProgress() {
if (storage.coins !== undefined) {
gameData.coins = storage.coins;
gameData.diamonds = storage.diamonds;
gameData.emeralds = storage.emeralds || 10;
gameData.monsters = storage.monsters || ["Rectertik"];
gameData.monsterCounts = storage.monsterCounts || {};
updateCurrency();
refreshCollection();
LK.effects.flashScreen(0x0000FF, 300);
} else {
LK.effects.flashScreen(0xFF0000, 300);
}
}
function deleteProgress() {
// Reset storage by setting to default values instead of undefined
storage.coins = 100;
storage.diamonds = 5;
storage.emeralds = 10;
storage.monsters = ["Rectertik"];
storage.monsterCounts = {};
gameData = {
coins: 100,
diamonds: 5,
emeralds: 10,
//{emeralds_reset}
monsters: ["Rectertik"],
monsterCounts: {}
};
updateCurrency();
refreshCollection();
LK.effects.flashScreen(0xFF0000, 300);
}
function getAssetNameForMonster(monsterType) {
// Remove spaces and handle special cases
var assetName = monsterType.replace(/\s+/g, '');
return assetName;
}
function getMonsterSoundName(monsterType) {
// Map monster types to their sound names
if (monsterType.indexOf('Rectertik') !== -1) {
return 'rectertikSound';
} else if (monsterType.indexOf('Antilla') !== -1) {
return 'antillaSound';
} else if (monsterType.indexOf('Shapana') !== -1) {
return 'shapanaSound';
} else if (monsterType.indexOf('Zingting') !== -1) {
return 'zingtingSound';
} else if (monsterType.indexOf('Sunna') !== -1) {
return 'sunnasound';
}
// Default fallback
return 'rectertikSound';
}
var currentView = 'collection'; // 'collection', 'shop', 'breeding'
var collectionMonsters = [];
var shopItems = [];
var breedingPairs = [];
// UI Elements
var coinText = new Text2('Coins: ' + gameData.coins, {
size: 36,
fill: 0xFFD700
});
coinText.anchor.set(0, 0);
coinText.x = 120;
coinText.y = 50;
LK.gui.topLeft.addChild(coinText);
var diamondText = new Text2('Diamonds: ' + gameData.diamonds, {
size: 36,
fill: 0x00BCD4
});
diamondText.anchor.set(0, 0);
diamondText.x = 120;
diamondText.y = 100;
LK.gui.topLeft.addChild(diamondText);
var emeraldText = new Text2('Emeralds: ' + gameData.emeralds, {
size: 36,
fill: 0x00FF7F
});
emeraldText.anchor.set(0, 0);
emeraldText.x = 120;
emeraldText.y = 150;
LK.gui.topLeft.addChild(emeraldText);
// Save/Load/Delete buttons
var saveBtn = new Text2('Save', {
size: 28,
fill: 0x00FF00
});
saveBtn.anchor.set(0.5, 0);
saveBtn.x = 2048 / 6;
saveBtn.y = 200;
game.addChild(saveBtn);
var loadBtn = new Text2('Load', {
size: 28,
fill: 0x0000FF
});
loadBtn.anchor.set(0.5, 0);
loadBtn.x = 2048 / 3;
loadBtn.y = 200;
game.addChild(loadBtn);
var deleteBtn = new Text2('Delete', {
size: 28,
fill: 0xFF0000
});
deleteBtn.anchor.set(0.5, 0);
deleteBtn.x = 5 * 2048 / 6;
deleteBtn.y = 200;
game.addChild(deleteBtn);
// Navigation buttons
var collectionBtn = new Text2('Collection', {
size: 32,
fill: 0x000000
});
collectionBtn.anchor.set(0.5, 0);
collectionBtn.x = 2048 / 4;
collectionBtn.y = 150;
game.addChild(collectionBtn);
var shopBtn = new Text2('Shop', {
size: 32,
fill: 0x000000
});
shopBtn.anchor.set(0.5, 0);
shopBtn.x = 2048 / 2;
shopBtn.y = 150;
game.addChild(shopBtn);
var breedingBtn = new Text2('Breeding', {
size: 32,
fill: 0x000000
});
breedingBtn.anchor.set(0.5, 0);
breedingBtn.x = 3 * 2048 / 4;
breedingBtn.y = 150;
game.addChild(breedingBtn);
// Shop data
var shopData = [{
type: 'Rectertik',
price: 50,
currency: 'coins'
}, {
type: 'Antilla',
price: 100,
currency: 'coins'
}, {
type: 'Rare Rectertik',
price: 5,
currency: 'diamonds'
}, {
type: 'Rare Antilla',
price: 10,
currency: 'diamonds'
}, {
type: 'Shapana',
price: 500,
currency: 'coins'
}, {
type: 'Epic Rectertik',
price: 25,
currency: 'diamonds'
}, {
type: 'Epic Antilla',
price: 25,
currency: 'diamonds'
}, {
type: 'Rare Shapana',
price: 25,
currency: 'diamonds'
}, {
type: 'Epic Shapana',
price: 25,
currency: 'diamonds'
}, {
type: 'Zingting',
price: 25,
currency: 'diamonds'
}, {
type: 'Rare Zingting',
price: 25,
currency: 'diamonds'
}, {
type: 'Epic Zingting',
price: 25,
currency: 'diamonds'
}, {
type: 'Sunna',
price: 50,
currency: 'emeralds'
}];
function updateCurrency() {
coinText.setText('Coins: ' + gameData.coins);
diamondText.setText('Diamonds: ' + gameData.diamonds);
emeraldText.setText('Emeralds: ' + gameData.emeralds);
}
function purchaseMonster(monsterType, price, currency) {
if (currency === 'coins' && gameData.coins >= price) {
gameData.coins -= price;
addMonster(monsterType);
updateCurrency();
LK.effects.flashScreen(0x00FF00, 300);
} else if (currency === 'diamonds' && gameData.diamonds >= price) {
gameData.diamonds -= price;
addMonster(monsterType);
updateCurrency();
LK.effects.flashScreen(0x00FF00, 300);
} else if (currency === 'emeralds' && gameData.emeralds >= price) {
gameData.emeralds -= price;
addMonster(monsterType);
updateCurrency();
LK.effects.flashScreen(0x00FF00, 300);
} else {
LK.effects.flashScreen(0xFF0000, 300);
}
}
function addMonster(monsterType) {
gameData.monsterCounts[monsterType] = (gameData.monsterCounts[monsterType] || 0) + 1;
if (gameData.monsters.indexOf(monsterType) === -1) {
gameData.monsters.push(monsterType);
}
refreshCollection();
}
function attemptBreeding(monster1Type, monster2Type) {
// Check if player has both monsters
if (gameData.monsterCounts[monster1Type] > 0 && gameData.monsterCounts[monster2Type] > 0) {
var result = getBreedingResult(monster1Type, monster2Type);
if (result) {
addMonster(result);
LK.effects.flashScreen(0x00FF00, 500);
}
} else {
LK.effects.flashScreen(0xFF0000, 300);
}
}
function getBreedingResult(monster1, monster2) {
// Shapana = any Rectertik form + any Antilla form
if (isRectertikForm(monster1) && isAntillaForm(monster2) || isAntillaForm(monster1) && isRectertikForm(monster2)) {
return 'Shapana';
}
// Zingting = any Antilla form + another Antilla form
if (isAntillaForm(monster1) && isAntillaForm(monster2)) {
return 'Zingting';
}
return null;
}
function isRectertikForm(monsterType) {
return monsterType.indexOf('Rectertik') !== -1;
}
function isAntillaForm(monsterType) {
return monsterType.indexOf('Antilla') !== -1;
}
function clearView() {
for (var i = collectionMonsters.length - 1; i >= 0; i--) {
collectionMonsters[i].destroy();
}
collectionMonsters = [];
for (var j = shopItems.length - 1; j >= 0; j--) {
shopItems[j].destroy();
}
shopItems = [];
for (var k = breedingPairs.length - 1; k >= 0; k--) {
breedingPairs[k].destroy();
}
breedingPairs = [];
}
function showCollection() {
clearView();
currentView = 'collection';
var yPos = 300;
var xPos = 200;
var monstersPerRow = 4;
var currentRow = 0;
for (var i = 0; i < gameData.monsters.length; i++) {
var monsterType = gameData.monsters[i];
var count = gameData.monsterCounts[monsterType];
if (count > 0) {
var monster = new Monster(monsterType);
monster.x = xPos + currentRow * 400;
monster.y = yPos;
game.addChild(monster);
collectionMonsters.push(monster);
// Add count text
var countText = new Text2('x' + count, {
size: 20,
fill: 0x000000
});
countText.anchor.set(0.5, 0.5);
countText.x = monster.x + 60;
countText.y = monster.y - 60;
game.addChild(countText);
collectionMonsters.push(countText);
currentRow++;
if (currentRow >= monstersPerRow) {
currentRow = 0;
yPos += 200;
}
}
}
}
function showShop() {
clearView();
currentView = 'shop';
var yPos = 300;
var xPos = 2048 / 2;
for (var i = 0; i < shopData.length; i++) {
var item = shopData[i];
var shopItem = new ShopItem(item.type, item.price, item.currency);
shopItem.x = xPos;
shopItem.y = yPos + i * 100;
game.addChild(shopItem);
shopItems.push(shopItem);
}
}
function showBreeding() {
clearView();
currentView = 'breeding';
var yPos = 300;
var xPos = 2048 / 2;
// Show available breeding combinations
var combinations = [{
monster1: 'Rectertik',
monster2: 'Antilla',
result: 'Shapana'
}, {
monster1: 'Rare Rectertik',
monster2: 'Antilla',
result: 'Shapana'
}, {
monster1: 'Rectertik',
monster2: 'Rare Antilla',
result: 'Shapana'
}, {
monster1: 'Antilla',
monster2: 'Antilla',
result: 'Zingting'
}, {
monster1: 'Rare Antilla',
monster2: 'Antilla',
result: 'Zingting'
}];
for (var i = 0; i < combinations.length; i++) {
var combo = combinations[i];
var breedPair = new BreedingPair(combo.monster1, combo.monster2);
breedPair.x = xPos;
breedPair.y = yPos + i * 80;
game.addChild(breedPair);
breedingPairs.push(breedPair);
}
}
function refreshCollection() {
if (currentView === 'collection') {
showCollection();
}
}
// Navigation event handlers
game.down = function (x, y, obj) {
// Use x, y directly as they are already in the correct coordinate space
// Check navigation buttons
if (y >= 150 && y <= 182) {
if (x >= 2048 / 4 - 100 && x <= 2048 / 4 + 100) {
showCollection();
} else if (x >= 2048 / 2 - 50 && x <= 2048 / 2 + 50) {
showShop();
} else if (x >= 3 * 2048 / 4 - 100 && x <= 3 * 2048 / 4 + 100) {
showBreeding();
}
}
// Check save/load/delete buttons
if (y >= 200 && y <= 228) {
if (x >= 2048 / 6 - 50 && x <= 2048 / 6 + 50) {
saveProgress();
} else if (x >= 2048 / 3 - 50 && x <= 2048 / 3 + 50) {
loadProgress();
} else if (x >= 5 * 2048 / 6 - 50 && x <= 5 * 2048 / 6 + 50) {
deleteProgress();
}
}
};
// Timer for passive income generation
var incomeTimer = LK.setInterval(function () {
var totalMonsters = 0;
for (var monsterType in gameData.monsterCounts) {
totalMonsters += gameData.monsterCounts[monsterType];
}
if (totalMonsters > 0) {
var coinsToAdd = totalMonsters * 0.5;
var diamondsToAdd = totalMonsters * 0.5;
var emeraldsToAdd = totalMonsters * 0.5;
gameData.coins = Math.floor((gameData.coins || 0) + coinsToAdd);
gameData.diamonds = Math.floor((gameData.diamonds || 0) + diamondsToAdd);
gameData.emeralds = Math.floor((gameData.emeralds || 0) + emeraldsToAdd);
updateCurrency();
}
}, 1000);
// Initialize with collection view
showCollection();
Ant. In-Game asset. 2d. High contrast. No shadows
Tick bug. In-Game asset. 2d. High contrast. No shadows
Tick bug with blue square on shell. In-Game asset. 2d. High contrast. No shadows
Electricity with eye. In-Game asset. 2d. High contrast. No shadows
X shape electricity. In-Game asset. 2d. High contrast. No shadows
Shapes bg. In-Game asset. 2d. High contrast. No shadows
Crop to circle
Crop to shape of a tick bug