User prompt
rebalance enemy skill attacks and add enemy types
User prompt
Rebalance skills and finalize features
User prompt
result text is blocked, move it down
User prompt
Skills with large amounts of coins should have a higher potential power. and a low minimum
User prompt
Coins are now inside skill buttons, move coin results lower down
User prompt
Still cannot tell difference between enemy and player coins, coins overlap text. Add P for player coins and E for enemy coins
User prompt
doesnt seem to work, redo ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
I cannt tell difference between enemy and player coins Add player and enemy columns
User prompt
Enemy Turn plan is blocked by other text. make sound effects and difference between enemy and player coins ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Theres a problem, when you select skills text appears on top of skill button, but skill button is below a card, making it hard to read
User prompt
Make it so that even if coin fails post clash win minimum power number still deals damage and battle text is blocked
User prompt
Cannot read outcome, revamp button and card locations
User prompt
Revamp skill names, powers, numbers, and visuals ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Expand Skill buttons to let skill buttons actually cover up the text
User prompt
Make assets more appealing. Balance skills and rename skills. Make it so that after someone wins a clash they roll their own skill coins again, one coin = one attack, meaning if a enemy wins and has 3 coins, each coin is 1 attack, and if all three coins are successful a strong attack is dealt. Also add live numbers ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Show enemy’s planned skill, add enemy skills and minimum power and max power
User prompt
show skill’s max clash power and minimum power, as well as clash numbers during fight
User prompt
Make 3 classes player can choose from before fighting, then assign the 6 already made skills to each 2 skill slot for class. Make spearman, samurai, and knife master
User prompt
Two skills are overlapping space them. Add hp system to vary from 80-100. Add up to 6 skills a player can obtain in the 2 skill slots
User prompt
Refine hp and skill button assests to make them more visually appealing
User prompt
Make the text easier to see and make the game clash combat slower ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Redo Coin logic. a skill should itself contain coins to roll, not a skill plus coins to roll.
User prompt
make assests larger
Code edit (1 edits merged)
Please save this source code
User prompt
Coin Clash Combat
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var AttackButton = Container.expand(function (text) { var self = Container.call(this); var buttonBg = self.attachAsset('attackButton', { anchorX: 0.5, anchorY: 0.5 }); var buttonText = new Text2(text, { size: 60, fill: '#000000' }); buttonText.anchor.set(0.5, 0.5); buttonText.x = 0; buttonText.y = 0; self.addChild(buttonText); self.setText = function (newText) { buttonText.setText(newText); }; self.down = function (x, y, obj) { if (gameState === 'ready') { performBattle(); } }; return self; }); var ClassButton = Container.expand(function (className, description, skills) { var self = Container.call(this); var buttonBg = self.attachAsset('classButton', { anchorX: 0.5, anchorY: 0.5 }); var classText = new Text2(className, { size: 50, fill: '#000000' }); classText.anchor.set(0.5, 0.5); classText.x = 0; classText.y = -30; self.addChild(classText); var descText = new Text2(description, { size: 30, fill: '#000000' }); descText.anchor.set(0.5, 0.5); descText.x = 0; descText.y = 30; self.addChild(descText); self.className = className; self.skills = skills; self.down = function (x, y, obj) { if (gameState === 'selectClass') { selectedClass = self; startGame(); } }; return self; }); var CoinButton = Container.expand(function (coinCount) { var self = Container.call(this); var buttonBg = self.attachAsset('coinButton', { anchorX: 0.5, anchorY: 0.5 }); var coinText = new Text2(coinCount.toString(), { size: 80, fill: '#000000' }); coinText.anchor.set(0.5, 0.5); coinText.x = 0; coinText.y = 0; self.addChild(coinText); self.coinCount = coinCount; self.down = function (x, y, obj) { if (gameState === 'selectCoins') { selectedCoins = self.coinCount; gameState = 'ready'; readyButton.alpha = 1; } }; return self; }); var EnemyCard = Container.expand(function () { var self = Container.call(this); var cardBg = self.attachAsset('enemyCard', { anchorX: 0.5, anchorY: 0.5 }); var nameText = new Text2('ENEMY', { size: 60, fill: '#000000' }); nameText.anchor.set(0.5, 0.5); nameText.x = 0; nameText.y = -140; self.addChild(nameText); var healthBorder = self.attachAsset('healthBarBorder', { anchorX: 0.5, anchorY: 0.5 }); healthBorder.x = 0; healthBorder.y = -60; var healthBg = self.attachAsset('healthBarBg', { anchorX: 0.5, anchorY: 0.5 }); healthBg.x = 0; healthBg.y = -60; var healthBar = self.attachAsset('healthBar', { anchorX: 0.5, anchorY: 0.5 }); healthBar.x = 0; healthBar.y = -60; var healthText = new Text2('100/100', { size: 48, fill: '#000000' }); healthText.anchor.set(0.5, 0.5); healthText.x = 0; healthText.y = -60; self.addChild(healthText); self.updateHealth = function (current, max) { healthText.setText(current + '/' + max); var healthPercent = current / max; healthBar.scaleX = healthPercent; healthBar.x = -250 + 250 * healthPercent; }; return self; }); var FlippingCoin = Container.expand(function () { var self = Container.call(this); var coinGraphic = self.attachAsset('coin', { anchorX: 0.5, anchorY: 0.5 }); self.isFlipping = false; self.result = null; self.flip = function (callback) { self.isFlipping = true; self.result = Math.random() < 0.5 ? 'heads' : 'tails'; LK.getSound('coinFlip').play(); tween(coinGraphic, { rotation: Math.PI * 4 }, { duration: 2000, easing: tween.easeOut, onFinish: function onFinish() { self.isFlipping = false; if (self.result === 'heads') { coinGraphic.tint = 0x27ae60; } else { coinGraphic.tint = 0xe74c3c; } if (callback) callback(self.result); } }); }; return self; }); var PlayerCard = Container.expand(function () { var self = Container.call(this); var cardBg = self.attachAsset('playerCard', { anchorX: 0.5, anchorY: 0.5 }); var nameText = new Text2('PLAYER', { size: 60, fill: '#000000' }); nameText.anchor.set(0.5, 0.5); nameText.x = 0; nameText.y = -140; self.addChild(nameText); var healthBorder = self.attachAsset('healthBarBorder', { anchorX: 0.5, anchorY: 0.5 }); healthBorder.x = 0; healthBorder.y = -60; var healthBg = self.attachAsset('healthBarBg', { anchorX: 0.5, anchorY: 0.5 }); healthBg.x = 0; healthBg.y = -60; var healthBar = self.attachAsset('healthBar', { anchorX: 0.5, anchorY: 0.5 }); healthBar.x = 0; healthBar.y = -60; var healthText = new Text2('100/100', { size: 48, fill: '#000000' }); healthText.anchor.set(0.5, 0.5); healthText.x = 0; healthText.y = -60; self.addChild(healthText); self.updateHealth = function (current, max) { healthText.setText(current + '/' + max); var healthPercent = current / max; healthBar.scaleX = healthPercent; healthBar.x = -250 + 250 * healthPercent; }; return self; }); var SkillButton = Container.expand(function (skillName, basePower, coinCount) { var self = Container.call(this); var buttonBorder = self.attachAsset('skillButtonBorder', { anchorX: 0.5, anchorY: 0.5 }); var buttonBg = self.attachAsset('skillButton', { anchorX: 0.5, anchorY: 0.5 }); var minPower = basePower; var maxPower = basePower + coinCount * 2; var skillText = new Text2(skillName + ' (Power: ' + minPower + '-' + maxPower + ', Coins: ' + coinCount + ')', { size: 50, fill: '#000000' }); skillText.anchor.set(0.5, 0.5); skillText.x = 0; skillText.y = 0; self.addChild(skillText); self.skillName = skillName; self.basePower = basePower; self.coinCount = coinCount; self.minPower = minPower; self.maxPower = maxPower; self.selected = false; self.setSelected = function (selected) { self.selected = selected; if (selected) { buttonBg.tint = 0x2ecc71; buttonBorder.tint = 0xf1c40f; tween(buttonBorder, { scaleX: 1.05, scaleY: 1.05 }, { duration: 300, easing: tween.easeOut }); } else { buttonBg.tint = 0x27ae60; buttonBorder.tint = 0x1e8449; tween(buttonBorder, { scaleX: 1.0, scaleY: 1.0 }, { duration: 300, easing: tween.easeOut }); } }; self.down = function (x, y, obj) { if (gameState === 'selectSkill') { selectedSkill = self; skill1Button.setSelected(false); skill2Button.setSelected(false); self.setSelected(true); gameState = 'ready'; readyButton.alpha = 1; } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x34495e }); /**** * Game Code ****/ // Game state variables var gameState = 'selectClass'; var playerMaxHealth = 80 + Math.floor(Math.random() * 21); // 80-100 HP var enemyMaxHealth = 80 + Math.floor(Math.random() * 21); // 80-100 HP var playerHealth = playerMaxHealth; var enemyHealth = enemyMaxHealth; // Class definitions with their specific skills var playerClasses = [{ name: 'Spearman', description: 'Balanced fighter with reach', skills: [{ name: 'Thrust', power: 6, coins: 1 }, { name: 'Strike', power: 3, coins: 2 }] }, { name: 'Samurai', description: 'Skilled warrior with precision', skills: [{ name: 'Slash', power: 4, coins: 2 }, { name: 'Combo', power: 2, coins: 3 }] }, { name: 'Knife Master', description: 'Fast attacker with power', skills: [{ name: 'Bash', power: 5, coins: 1 }, { name: 'Smash', power: 7, coins: 1 }] }]; // Player skills will be assigned after class selection var playerSkills = []; var selectedClass = null; // Enemy skills - each skill now contains its own coins var enemySkills = [{ name: 'Bite', power: 2, coins: 3 }, { name: 'Claw', power: 4, coins: 2 }, { name: 'Roar', power: 3, coins: 2 }, { name: 'Charge', power: 5, coins: 1 }, { name: 'Swipe', power: 1, coins: 4 }, { name: 'Pounce', power: 6, coins: 1 }]; // Current selection var selectedSkill = null; // Create class selection UI var classSelectionTitle = new Text2('Choose Your Class', { size: 80, fill: '#000000' }); classSelectionTitle.anchor.set(0.5, 0.5); classSelectionTitle.x = 1024; classSelectionTitle.y = 400; game.addChild(classSelectionTitle); var classButtons = []; for (var i = 0; i < playerClasses.length; i++) { var classButton = new ClassButton(playerClasses[i].name, playerClasses[i].description, playerClasses[i].skills); classButton.x = 1024; classButton.y = 700 + i * 300; classButtons.push(classButton); game.addChild(classButton); } // Game UI elements (will be created after class selection) var playerCard = null; var enemyCard = null; var skill1Button = null; var skill2Button = null; var readyButton = null; var statusText = null; var enemySkillText = null; // Battle result area var battleResultText = new Text2('', { size: 60, fill: '#000000' }); battleResultText.anchor.set(0.5, 0.5); battleResultText.x = 1024; battleResultText.y = 800; game.addChild(battleResultText); // Coin flip display area var coinFlipContainer = new Container(); coinFlipContainer.x = 1024; coinFlipContainer.y = 900; game.addChild(coinFlipContainer); function startGame() { // Assign skills based on selected class playerSkills = selectedClass.skills; // Hide class selection UI classSelectionTitle.alpha = 0; for (var i = 0; i < classButtons.length; i++) { classButtons[i].alpha = 0; } // Create game UI elements playerCard = game.addChild(new PlayerCard()); playerCard.x = 1024; playerCard.y = 600; enemyCard = game.addChild(new EnemyCard()); enemyCard.x = 1024; enemyCard.y = 300; // Skills selection skill1Button = game.addChild(new SkillButton(playerSkills[0].name, playerSkills[0].power, playerSkills[0].coins)); skill1Button.x = 1024; skill1Button.y = 1200; skill2Button = game.addChild(new SkillButton(playerSkills[1].name, playerSkills[1].power, playerSkills[1].coins)); skill2Button.x = 1024; skill2Button.y = 1400; // Attack button readyButton = game.addChild(new AttackButton('BATTLE!')); readyButton.x = 1024; readyButton.y = 1700; readyButton.alpha = 0.5; // Status text statusText = new Text2('Choose your skill', { size: 70, fill: '#000000' }); statusText.anchor.set(0.5, 0.5); statusText.x = 1024; statusText.y = 1000; game.addChild(statusText); // Enemy skill display text enemySkillText = new Text2('', { size: 50, fill: '#000000' }); enemySkillText.anchor.set(0.5, 0.5); enemySkillText.x = 1024; enemySkillText.y = 450; game.addChild(enemySkillText); // Initialize health displays playerCard.updateHealth(playerHealth, playerMaxHealth); enemyCard.updateHealth(enemyHealth, enemyMaxHealth); // Change game state gameState = 'selectSkill'; } // Battle logic function performBattle() { if (!selectedSkill) return; gameState = 'battle'; statusText.setText('Battle in progress...'); readyButton.alpha = 0.5; // Player's turn var playerBasePower = selectedSkill.basePower; var playerCoins = selectedSkill.coinCount; // Enemy's turn (AI) var enemySkillIndex = Math.floor(Math.random() * enemySkills.length); var enemySkill = enemySkills[enemySkillIndex]; var enemyBasePower = enemySkill.power; var enemyCoins = enemySkill.coins; var enemyMinPower = enemyBasePower; var enemyMaxPower = enemyBasePower + enemyCoins * 2; // Display enemy's planned skill enemySkillText.setText('Enemy plans: ' + enemySkill.name + ' (Power: ' + enemyMinPower + '-' + enemyMaxPower + ', ' + enemyCoins + ' coins)'); // Clear previous coins coinFlipContainer.removeChildren(); // Flip player coins var playerSuccessfulFlips = 0; var playerCoinsFlipped = 0; for (var i = 0; i < playerCoins; i++) { var coin = new FlippingCoin(); coin.x = (i - (playerCoins - 1) / 2) * 100; coin.y = -50; coinFlipContainer.addChild(coin); LK.setTimeout(function (coinRef) { return function () { coinRef.flip(function (result) { if (result === 'heads') { playerSuccessfulFlips++; } playerCoinsFlipped++; if (playerCoinsFlipped === playerCoins) { // All player coins flipped, now flip enemy coins flipEnemyCoins(); } }); }; }(coin), i * 800); } function flipEnemyCoins() { var enemySuccessfulFlips = 0; var enemyCoinsFlipped = 0; for (var i = 0; i < enemyCoins; i++) { var coin = new FlippingCoin(); coin.x = (i - (enemyCoins - 1) / 2) * 100; coin.y = 50; coinFlipContainer.addChild(coin); LK.setTimeout(function (coinRef) { return function () { coinRef.flip(function (result) { if (result === 'heads') { enemySuccessfulFlips++; } enemyCoinsFlipped++; if (enemyCoinsFlipped === enemyCoins) { // All coins flipped, resolve battle resolveBattle(playerBasePower, playerSuccessfulFlips, playerCoins, enemyBasePower, enemySuccessfulFlips, enemyCoins, enemySkill.name); } }); }; }(coin), i * 800 + 3000); } } } function resolveBattle(playerBasePower, playerSuccessfulFlips, playerCoins, enemyBasePower, enemySuccessfulFlips, enemyCoins, enemySkillName) { var playerTotalPower = playerBasePower + playerSuccessfulFlips * 2; var enemyTotalPower = enemyBasePower + enemySuccessfulFlips * 2; var resultText = 'CLASH RESULTS:\n'; resultText += 'Player: ' + playerBasePower + ' base + ' + playerSuccessfulFlips + '/' + playerCoins + ' heads = ' + playerTotalPower + '\n'; resultText += 'Enemy: ' + enemyBasePower + ' base + ' + enemySuccessfulFlips + '/' + enemyCoins + ' heads = ' + enemyTotalPower + '\n'; if (playerTotalPower > enemyTotalPower) { // Player wins enemyHealth -= playerCoins; resultText += 'Player wins! Enemy takes ' + playerCoins + ' damage!'; LK.getSound('attack').play(); // Flash enemy red tween(enemyCard, { tint: 0xff0000 }, { duration: 800, onFinish: function onFinish() { tween(enemyCard, { tint: 0xffffff }, { duration: 800 }); } }); } else if (enemyTotalPower > playerTotalPower) { // Enemy wins playerHealth -= enemyCoins; resultText += 'Enemy wins with ' + enemySkillName + '! Player takes ' + enemyCoins + ' damage!'; LK.getSound('damage').play(); // Flash player red tween(playerCard, { tint: 0xff0000 }, { duration: 800, onFinish: function onFinish() { tween(playerCard, { tint: 0xffffff }, { duration: 800 }); } }); } else { // Tie resultText += 'It\'s a tie! No damage dealt.'; } battleResultText.setText(resultText); // Update health displays playerCard.updateHealth(Math.max(0, playerHealth), playerMaxHealth); enemyCard.updateHealth(Math.max(0, enemyHealth), enemyMaxHealth); // Check for game over LK.setTimeout(function () { if (playerHealth <= 0) { LK.showGameOver(); } else if (enemyHealth <= 0) { LK.showYouWin(); } else { // Reset for next turn resetTurn(); } }, 4000); } function resetTurn() { gameState = 'selectSkill'; selectedSkill = null; skill1Button.setSelected(false); skill2Button.setSelected(false); readyButton.alpha = 0.5; statusText.setText('Choose your skill'); enemySkillText.setText(''); // Clear coin flips LK.setTimeout(function () { coinFlipContainer.removeChildren(); }, 2000); } // Game update loop game.update = function () { // Update status text based on game state if (gameState === 'selectClass') { // Class selection phase - no status updates needed } else if (gameState === 'selectSkill') { if (statusText) statusText.setText('Choose your skill'); if (enemySkillText) enemySkillText.setText(''); } else if (gameState === 'ready') { if (statusText) statusText.setText('Ready to battle with ' + selectedSkill.skillName + ' (Power: ' + selectedSkill.minPower + '-' + selectedSkill.maxPower + ', ' + selectedSkill.coinCount + ' coins)!'); // Show enemy's planned skill when player is ready var enemySkillIndex = Math.floor(Math.random() * enemySkills.length); var enemySkill = enemySkills[enemySkillIndex]; var enemyMinPower = enemySkill.power; var enemyMaxPower = enemySkill.power + enemySkill.coins * 2; if (enemySkillText) enemySkillText.setText('Enemy plans: ' + enemySkill.name + ' (Power: ' + enemyMinPower + '-' + enemyMaxPower + ', ' + enemySkill.coins + ' coins)'); } };
===================================================================
--- original.js
+++ change.js
@@ -340,8 +340,24 @@
}, {
name: 'Claw',
power: 4,
coins: 2
+}, {
+ name: 'Roar',
+ power: 3,
+ coins: 2
+}, {
+ name: 'Charge',
+ power: 5,
+ coins: 1
+}, {
+ name: 'Swipe',
+ power: 1,
+ coins: 4
+}, {
+ name: 'Pounce',
+ power: 6,
+ coins: 1
}];
// Current selection
var selectedSkill = null;
// Create class selection UI
@@ -367,8 +383,9 @@
var skill1Button = null;
var skill2Button = null;
var readyButton = null;
var statusText = null;
+var enemySkillText = null;
// Battle result area
var battleResultText = new Text2('', {
size: 60,
fill: '#000000'
@@ -417,8 +434,17 @@
statusText.anchor.set(0.5, 0.5);
statusText.x = 1024;
statusText.y = 1000;
game.addChild(statusText);
+ // Enemy skill display text
+ enemySkillText = new Text2('', {
+ size: 50,
+ fill: '#000000'
+ });
+ enemySkillText.anchor.set(0.5, 0.5);
+ enemySkillText.x = 1024;
+ enemySkillText.y = 450;
+ game.addChild(enemySkillText);
// Initialize health displays
playerCard.updateHealth(playerHealth, playerMaxHealth);
enemyCard.updateHealth(enemyHealth, enemyMaxHealth);
// Change game state
@@ -437,8 +463,12 @@
var enemySkillIndex = Math.floor(Math.random() * enemySkills.length);
var enemySkill = enemySkills[enemySkillIndex];
var enemyBasePower = enemySkill.power;
var enemyCoins = enemySkill.coins;
+ var enemyMinPower = enemyBasePower;
+ var enemyMaxPower = enemyBasePower + enemyCoins * 2;
+ // Display enemy's planned skill
+ enemySkillText.setText('Enemy plans: ' + enemySkill.name + ' (Power: ' + enemyMinPower + '-' + enemyMaxPower + ', ' + enemyCoins + ' coins)');
// Clear previous coins
coinFlipContainer.removeChildren();
// Flip player coins
var playerSuccessfulFlips = 0;
@@ -556,8 +586,9 @@
skill1Button.setSelected(false);
skill2Button.setSelected(false);
readyButton.alpha = 0.5;
statusText.setText('Choose your skill');
+ enemySkillText.setText('');
// Clear coin flips
LK.setTimeout(function () {
coinFlipContainer.removeChildren();
}, 2000);
@@ -568,8 +599,15 @@
if (gameState === 'selectClass') {
// Class selection phase - no status updates needed
} else if (gameState === 'selectSkill') {
if (statusText) statusText.setText('Choose your skill');
+ if (enemySkillText) enemySkillText.setText('');
} else if (gameState === 'ready') {
if (statusText) statusText.setText('Ready to battle with ' + selectedSkill.skillName + ' (Power: ' + selectedSkill.minPower + '-' + selectedSkill.maxPower + ', ' + selectedSkill.coinCount + ' coins)!');
+ // Show enemy's planned skill when player is ready
+ var enemySkillIndex = Math.floor(Math.random() * enemySkills.length);
+ var enemySkill = enemySkills[enemySkillIndex];
+ var enemyMinPower = enemySkill.power;
+ var enemyMaxPower = enemySkill.power + enemySkill.coins * 2;
+ if (enemySkillText) enemySkillText.setText('Enemy plans: ' + enemySkill.name + ' (Power: ' + enemyMinPower + '-' + enemyMaxPower + ', ' + enemySkill.coins + ' coins)');
}
};
\ No newline at end of file