/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var ActionButton = Container.expand(function (text, action) { var self = Container.call(this); self.action = action; var buttonBg = self.attachAsset('buttonBg', { anchorX: 0.5, anchorY: 0.5 }); var buttonText = new Text2(text, { size: 40, fill: 0xFFFFFF }); buttonText.anchor.set(0.5, 0.5); self.addChild(buttonText); self.down = function (x, y, obj) { if (self.action === 'advance' && gameState === 'waitingForAdvance') { advanceRound(); } }; return self; }); var BetButton = Container.expand(function (amount) { var self = Container.call(this); self.betAmount = amount; var buttonBg = self.attachAsset('betButtonBg', { anchorX: 0.5, anchorY: 0.5 }); var buttonText = new Text2(amount + " Gold", { size: 42, fill: 0xFFFFFF }); buttonText.anchor.set(0.5, 0.5); self.addChild(buttonText); self.down = function (x, y, obj) { if (gameState === 'betting' && playerGold >= self.betAmount) { placeBet(self.betAmount); } }; return self; }); var GodCard = Container.expand(function (godName, godIndex) { var self = Container.call(this); self.godName = godName; self.godIndex = godIndex; self.isEliminated = false; self.isSelected = false; var cardBg = self.attachAsset('godCard', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.3, scaleY: 1.3 }); // Add god image based on god name var godImageMap = { 'Zeus': 'zeuscard', 'Thor': 'thorcard', 'Ra': 'racard', 'Odin': 'odincard', 'Ares': 'arescard', 'Loki': 'lokicard', 'Anubis': 'anubiscard', 'Poseidon': 'poseidoncard' }; var godImage = self.attachAsset(godImageMap[godName], { anchorX: 0.5, anchorY: 0.5 }); godImage.x = 0; godImage.y = -20; godImage.width = 260; godImage.height = 260; var nameText = new Text2(godName, { size: 64, fill: 0xFFFFFF }); nameText.anchor.set(0.5, 0.5); nameText.x = 0; nameText.y = -120; self.addChild(nameText); var statusText = new Text2("ACTIVE", { size: 44, fill: 0x00FF00 }); statusText.anchor.set(0.5, 0.5); statusText.x = 0; statusText.y = 120; self.addChild(statusText); self.cardBg = cardBg; self.nameText = nameText; self.statusText = statusText; self.setSelected = function (selected) { self.isSelected = selected; if (selected) { self.removeChild(cardBg); cardBg = self.attachAsset('selectedGodCard', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.3, scaleY: 1.3 }); self.cardBg = cardBg; self.statusText.setText("CHOSEN"); self.statusText.fill = "#ffff00"; } }; self.eliminate = function () { self.isEliminated = true; self.removeChild(self.cardBg); self.cardBg = self.attachAsset('eliminatedGodCard', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.3, scaleY: 1.3 }); self.statusText.setText("ELIMINATED"); self.statusText.fill = "#ff0000"; self.nameText.fill = "#888888"; }; self.down = function (x, y, obj) { if (!self.isEliminated && gameState === 'selectGod') { selectGod(self.godIndex); } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x1a1a2e }); /**** * Game Code ****/ var godNames = ['Zeus', 'Thor', 'Ra', 'Odin', 'Ares', 'Loki', 'Anubis', 'Poseidon']; var gods = []; var playerGold = 100; var selectedGodIndex = -1; var currentBet = 0; var currentRound = 0; var gameState = 'selectGod'; // selectGod, betting, waitingForAdvance, gameOver var survivingGods = [0, 1, 2, 3, 4, 5, 6, 7]; var hasBetThisTournament = false; var initialBetAmount = 0; // UI Elements var goldText = new Text2('Gold: ' + playerGold, { size: 60, fill: 0xFFD700 }); goldText.anchor.set(0.5, 0); LK.gui.top.addChild(goldText); var instructionText = new Text2('Choose your divine champion!', { size: 48, fill: 0xFFFFFF }); instructionText.anchor.set(0.5, 0.5); instructionText.x = 2048 / 2; instructionText.y = 300; game.addChild(instructionText); var roundText = new Text2('Tournament Selection', { size: 52, fill: 0xFFAA00 }); roundText.anchor.set(0.5, 0); roundText.x = 2048 / 2; roundText.y = 150; game.addChild(roundText); // Create god cards for (var i = 0; i < 8; i++) { var god = new GodCard(godNames[i], i); var row = Math.floor(i / 4); var col = i % 4; god.x = 400 + col * 400; god.y = 700 + row * 600; gods.push(god); game.addChild(god); } // Bet buttons var betButtons = []; var betAmounts = [5, 10, 30]; for (var i = 0; i < betAmounts.length; i++) { var betButton = new BetButton(betAmounts[i]); betButton.x = 512 + i * 400; betButton.y = 1800; betButtons.push(betButton); game.addChild(betButton); } // Advance button var advanceButton = new ActionButton('Advance Round', 'advance'); advanceButton.x = 2048 / 2; advanceButton.y = 2000; game.addChild(advanceButton); // Hide betting elements initially for (var i = 0; i < betButtons.length; i++) { betButtons[i].visible = false; } advanceButton.visible = false; function updateGoldDisplay() { goldText.setText('Gold: ' + playerGold); } function selectGod(godIndex) { if (selectedGodIndex !== -1) { gods[selectedGodIndex].setSelected(false); } selectedGodIndex = godIndex; gods[godIndex].setSelected(true); if (!hasBetThisTournament) { gameState = 'betting'; instructionText.setText('Place your bet on ' + godNames[godIndex] + '!'); roundText.setText('Round 1 Betting'); // Show betting buttons for (var i = 0; i < betButtons.length; i++) { betButtons[i].visible = true; } } else { gameState = 'waitingForAdvance'; instructionText.setText('Champion selected: ' + godNames[godIndex]); advanceButton.visible = true; } } function placeBet(amount) { if (playerGold >= amount) { currentBet = amount; initialBetAmount = amount; playerGold -= amount; hasBetThisTournament = true; updateGoldDisplay(); gameState = 'waitingForAdvance'; instructionText.setText('Bet placed: ' + amount + ' gold on ' + godNames[selectedGodIndex]); // Hide betting buttons, show advance button for (var i = 0; i < betButtons.length; i++) { betButtons[i].visible = false; } advanceButton.visible = true; LK.getSound('betPlaced').play(); } } function advanceRound() { currentRound++; var godsToEliminate; var remainingCount; if (currentRound === 1) { godsToEliminate = 2; remainingCount = 6; roundText.setText('Round 1 Results - 6 Gods Remain'); } else if (currentRound === 2) { godsToEliminate = 2; remainingCount = 4; roundText.setText('Round 2 Results - 4 Gods Remain'); } else if (currentRound === 3) { godsToEliminate = 3; remainingCount = 1; roundText.setText('Final Round - Champion Crowned!'); } // Randomly eliminate gods var tempSurviving = survivingGods.slice(); var eliminated = []; for (var i = 0; i < godsToEliminate; i++) { var randomIndex = Math.floor(Math.random() * tempSurviving.length); var eliminatedGod = tempSurviving[randomIndex]; eliminated.push(eliminatedGod); tempSurviving.splice(randomIndex, 1); gods[eliminatedGod].eliminate(); } survivingGods = tempSurviving; // Check if player's god survived var playerGodSurvived = survivingGods.indexOf(selectedGodIndex) !== -1; if (playerGodSurvived) { if (currentRound < 3) { // God survived, earn 2 gold playerGold += 2; updateGoldDisplay(); instructionText.setText(godNames[selectedGodIndex] + ' survived! +2 gold earned!'); LK.getSound('roundWin').play(); // Set up next round LK.setTimeout(function () { gameState = 'waitingForAdvance'; instructionText.setText('Round ' + (currentRound + 1) + ' begins!'); roundText.setText('Round ' + (currentRound + 1) + ' - Tournament Continues'); advanceButton.visible = true; }, 2000); } else { // God won the tournament! var championBonus = initialBetAmount * 3; playerGold += 2 + championBonus; // 2 for surviving + 3x bet multiplier updateGoldDisplay(); instructionText.setText(godNames[selectedGodIndex] + ' is the CHAMPION! +' + (2 + championBonus) + ' gold earned!'); LK.getSound('champion').play(); // Start new tournament LK.setTimeout(function () { startNewTournament(); }, 3000); } } else { // God was eliminated LK.getSound('godEliminated').play(); instructionText.setText(godNames[selectedGodIndex] + ' was eliminated!'); // Start new tournament LK.setTimeout(function () { startNewTournament(); }, 2000); } } function startNewTournament() { if (playerGold <= 0) { LK.showGameOver(); return; } // Reset tournament state currentRound = 0; selectedGodIndex = -1; hasBetThisTournament = false; initialBetAmount = 0; survivingGods = [0, 1, 2, 3, 4, 5, 6, 7]; gameState = 'selectGod'; // Reset all gods for (var i = 0; i < gods.length; i++) { gods[i].removeChild(gods[i].cardBg); gods[i].cardBg = gods[i].attachAsset('godCard', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.3, scaleY: 1.3 }); // Move cardBg to back so god image stays visible gods[i].setChildIndex(gods[i].cardBg, 0); gods[i].isEliminated = false; gods[i].isSelected = false; gods[i].statusText.setText("ACTIVE"); gods[i].statusText.fill = 0x00FF00; gods[i].nameText.fill = 0xFFFFFF; } // Reset UI instructionText.setText('Choose your divine champion!'); roundText.setText('Tournament Selection'); advanceButton.visible = false; for (var i = 0; i < betButtons.length; i++) { betButtons[i].visible = false; } } // Start background music LK.playMusic('royalgodbattle'); game.update = function () { // Check for game over condition if (playerGold <= 0 && gameState !== 'gameOver') { gameState = 'gameOver'; instructionText.setText('Out of gold! Game Over!'); LK.setTimeout(function () { LK.showGameOver(); }, 1000); } // Update bet button availability for (var i = 0; i < betButtons.length; i++) { if (betButtons[i].visible) { if (playerGold >= betButtons[i].betAmount) { betButtons[i].alpha = 1.0; } else { betButtons[i].alpha = 0.5; } } } };
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var ActionButton = Container.expand(function (text, action) {
var self = Container.call(this);
self.action = action;
var buttonBg = self.attachAsset('buttonBg', {
anchorX: 0.5,
anchorY: 0.5
});
var buttonText = new Text2(text, {
size: 40,
fill: 0xFFFFFF
});
buttonText.anchor.set(0.5, 0.5);
self.addChild(buttonText);
self.down = function (x, y, obj) {
if (self.action === 'advance' && gameState === 'waitingForAdvance') {
advanceRound();
}
};
return self;
});
var BetButton = Container.expand(function (amount) {
var self = Container.call(this);
self.betAmount = amount;
var buttonBg = self.attachAsset('betButtonBg', {
anchorX: 0.5,
anchorY: 0.5
});
var buttonText = new Text2(amount + " Gold", {
size: 42,
fill: 0xFFFFFF
});
buttonText.anchor.set(0.5, 0.5);
self.addChild(buttonText);
self.down = function (x, y, obj) {
if (gameState === 'betting' && playerGold >= self.betAmount) {
placeBet(self.betAmount);
}
};
return self;
});
var GodCard = Container.expand(function (godName, godIndex) {
var self = Container.call(this);
self.godName = godName;
self.godIndex = godIndex;
self.isEliminated = false;
self.isSelected = false;
var cardBg = self.attachAsset('godCard', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.3,
scaleY: 1.3
});
// Add god image based on god name
var godImageMap = {
'Zeus': 'zeuscard',
'Thor': 'thorcard',
'Ra': 'racard',
'Odin': 'odincard',
'Ares': 'arescard',
'Loki': 'lokicard',
'Anubis': 'anubiscard',
'Poseidon': 'poseidoncard'
};
var godImage = self.attachAsset(godImageMap[godName], {
anchorX: 0.5,
anchorY: 0.5
});
godImage.x = 0;
godImage.y = -20;
godImage.width = 260;
godImage.height = 260;
var nameText = new Text2(godName, {
size: 64,
fill: 0xFFFFFF
});
nameText.anchor.set(0.5, 0.5);
nameText.x = 0;
nameText.y = -120;
self.addChild(nameText);
var statusText = new Text2("ACTIVE", {
size: 44,
fill: 0x00FF00
});
statusText.anchor.set(0.5, 0.5);
statusText.x = 0;
statusText.y = 120;
self.addChild(statusText);
self.cardBg = cardBg;
self.nameText = nameText;
self.statusText = statusText;
self.setSelected = function (selected) {
self.isSelected = selected;
if (selected) {
self.removeChild(cardBg);
cardBg = self.attachAsset('selectedGodCard', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.3,
scaleY: 1.3
});
self.cardBg = cardBg;
self.statusText.setText("CHOSEN");
self.statusText.fill = "#ffff00";
}
};
self.eliminate = function () {
self.isEliminated = true;
self.removeChild(self.cardBg);
self.cardBg = self.attachAsset('eliminatedGodCard', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.3,
scaleY: 1.3
});
self.statusText.setText("ELIMINATED");
self.statusText.fill = "#ff0000";
self.nameText.fill = "#888888";
};
self.down = function (x, y, obj) {
if (!self.isEliminated && gameState === 'selectGod') {
selectGod(self.godIndex);
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x1a1a2e
});
/****
* Game Code
****/
var godNames = ['Zeus', 'Thor', 'Ra', 'Odin', 'Ares', 'Loki', 'Anubis', 'Poseidon'];
var gods = [];
var playerGold = 100;
var selectedGodIndex = -1;
var currentBet = 0;
var currentRound = 0;
var gameState = 'selectGod'; // selectGod, betting, waitingForAdvance, gameOver
var survivingGods = [0, 1, 2, 3, 4, 5, 6, 7];
var hasBetThisTournament = false;
var initialBetAmount = 0;
// UI Elements
var goldText = new Text2('Gold: ' + playerGold, {
size: 60,
fill: 0xFFD700
});
goldText.anchor.set(0.5, 0);
LK.gui.top.addChild(goldText);
var instructionText = new Text2('Choose your divine champion!', {
size: 48,
fill: 0xFFFFFF
});
instructionText.anchor.set(0.5, 0.5);
instructionText.x = 2048 / 2;
instructionText.y = 300;
game.addChild(instructionText);
var roundText = new Text2('Tournament Selection', {
size: 52,
fill: 0xFFAA00
});
roundText.anchor.set(0.5, 0);
roundText.x = 2048 / 2;
roundText.y = 150;
game.addChild(roundText);
// Create god cards
for (var i = 0; i < 8; i++) {
var god = new GodCard(godNames[i], i);
var row = Math.floor(i / 4);
var col = i % 4;
god.x = 400 + col * 400;
god.y = 700 + row * 600;
gods.push(god);
game.addChild(god);
}
// Bet buttons
var betButtons = [];
var betAmounts = [5, 10, 30];
for (var i = 0; i < betAmounts.length; i++) {
var betButton = new BetButton(betAmounts[i]);
betButton.x = 512 + i * 400;
betButton.y = 1800;
betButtons.push(betButton);
game.addChild(betButton);
}
// Advance button
var advanceButton = new ActionButton('Advance Round', 'advance');
advanceButton.x = 2048 / 2;
advanceButton.y = 2000;
game.addChild(advanceButton);
// Hide betting elements initially
for (var i = 0; i < betButtons.length; i++) {
betButtons[i].visible = false;
}
advanceButton.visible = false;
function updateGoldDisplay() {
goldText.setText('Gold: ' + playerGold);
}
function selectGod(godIndex) {
if (selectedGodIndex !== -1) {
gods[selectedGodIndex].setSelected(false);
}
selectedGodIndex = godIndex;
gods[godIndex].setSelected(true);
if (!hasBetThisTournament) {
gameState = 'betting';
instructionText.setText('Place your bet on ' + godNames[godIndex] + '!');
roundText.setText('Round 1 Betting');
// Show betting buttons
for (var i = 0; i < betButtons.length; i++) {
betButtons[i].visible = true;
}
} else {
gameState = 'waitingForAdvance';
instructionText.setText('Champion selected: ' + godNames[godIndex]);
advanceButton.visible = true;
}
}
function placeBet(amount) {
if (playerGold >= amount) {
currentBet = amount;
initialBetAmount = amount;
playerGold -= amount;
hasBetThisTournament = true;
updateGoldDisplay();
gameState = 'waitingForAdvance';
instructionText.setText('Bet placed: ' + amount + ' gold on ' + godNames[selectedGodIndex]);
// Hide betting buttons, show advance button
for (var i = 0; i < betButtons.length; i++) {
betButtons[i].visible = false;
}
advanceButton.visible = true;
LK.getSound('betPlaced').play();
}
}
function advanceRound() {
currentRound++;
var godsToEliminate;
var remainingCount;
if (currentRound === 1) {
godsToEliminate = 2;
remainingCount = 6;
roundText.setText('Round 1 Results - 6 Gods Remain');
} else if (currentRound === 2) {
godsToEliminate = 2;
remainingCount = 4;
roundText.setText('Round 2 Results - 4 Gods Remain');
} else if (currentRound === 3) {
godsToEliminate = 3;
remainingCount = 1;
roundText.setText('Final Round - Champion Crowned!');
}
// Randomly eliminate gods
var tempSurviving = survivingGods.slice();
var eliminated = [];
for (var i = 0; i < godsToEliminate; i++) {
var randomIndex = Math.floor(Math.random() * tempSurviving.length);
var eliminatedGod = tempSurviving[randomIndex];
eliminated.push(eliminatedGod);
tempSurviving.splice(randomIndex, 1);
gods[eliminatedGod].eliminate();
}
survivingGods = tempSurviving;
// Check if player's god survived
var playerGodSurvived = survivingGods.indexOf(selectedGodIndex) !== -1;
if (playerGodSurvived) {
if (currentRound < 3) {
// God survived, earn 2 gold
playerGold += 2;
updateGoldDisplay();
instructionText.setText(godNames[selectedGodIndex] + ' survived! +2 gold earned!');
LK.getSound('roundWin').play();
// Set up next round
LK.setTimeout(function () {
gameState = 'waitingForAdvance';
instructionText.setText('Round ' + (currentRound + 1) + ' begins!');
roundText.setText('Round ' + (currentRound + 1) + ' - Tournament Continues');
advanceButton.visible = true;
}, 2000);
} else {
// God won the tournament!
var championBonus = initialBetAmount * 3;
playerGold += 2 + championBonus; // 2 for surviving + 3x bet multiplier
updateGoldDisplay();
instructionText.setText(godNames[selectedGodIndex] + ' is the CHAMPION! +' + (2 + championBonus) + ' gold earned!');
LK.getSound('champion').play();
// Start new tournament
LK.setTimeout(function () {
startNewTournament();
}, 3000);
}
} else {
// God was eliminated
LK.getSound('godEliminated').play();
instructionText.setText(godNames[selectedGodIndex] + ' was eliminated!');
// Start new tournament
LK.setTimeout(function () {
startNewTournament();
}, 2000);
}
}
function startNewTournament() {
if (playerGold <= 0) {
LK.showGameOver();
return;
}
// Reset tournament state
currentRound = 0;
selectedGodIndex = -1;
hasBetThisTournament = false;
initialBetAmount = 0;
survivingGods = [0, 1, 2, 3, 4, 5, 6, 7];
gameState = 'selectGod';
// Reset all gods
for (var i = 0; i < gods.length; i++) {
gods[i].removeChild(gods[i].cardBg);
gods[i].cardBg = gods[i].attachAsset('godCard', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.3,
scaleY: 1.3
});
// Move cardBg to back so god image stays visible
gods[i].setChildIndex(gods[i].cardBg, 0);
gods[i].isEliminated = false;
gods[i].isSelected = false;
gods[i].statusText.setText("ACTIVE");
gods[i].statusText.fill = 0x00FF00;
gods[i].nameText.fill = 0xFFFFFF;
}
// Reset UI
instructionText.setText('Choose your divine champion!');
roundText.setText('Tournament Selection');
advanceButton.visible = false;
for (var i = 0; i < betButtons.length; i++) {
betButtons[i].visible = false;
}
}
// Start background music
LK.playMusic('royalgodbattle');
game.update = function () {
// Check for game over condition
if (playerGold <= 0 && gameState !== 'gameOver') {
gameState = 'gameOver';
instructionText.setText('Out of gold! Game Over!');
LK.setTimeout(function () {
LK.showGameOver();
}, 1000);
}
// Update bet button availability
for (var i = 0; i < betButtons.length; i++) {
if (betButtons[i].visible) {
if (playerGold >= betButtons[i].betAmount) {
betButtons[i].alpha = 1.0;
} else {
betButtons[i].alpha = 0.5;
}
}
}
};
poseidon card. In-Game asset. 2d. High contrast. No shadows
zeus card. In-Game asset. 2d. High contrast. No shadows
egypt god ra card. In-Game asset. 2d. High contrast. No shadows
loki god card. In-Game asset. 2d. High contrast. No shadows
viking god card. In-Game asset. 2d. High contrast. No shadows
anubis god card. In-Game asset. 2d. High contrast. No shadows
ares god card. In-Game asset. 2d. High contrast. No shadows
odin god card. In-Game asset. 2d. High contrast. No shadows