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: 48, fill: '#ffffff' }); 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 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: 64, fill: '#ffffff' }); 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: 48, fill: '#ffffff' }); nameText.anchor.set(0.5, 0.5); nameText.x = 0; nameText.y = -140; self.addChild(nameText); 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('15/15', { size: 36, fill: '#ffffff' }); 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: 1000, 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: 48, fill: '#ffffff' }); nameText.anchor.set(0.5, 0.5); nameText.x = 0; nameText.y = -140; self.addChild(nameText); 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('20/20', { size: 36, fill: '#ffffff' }); 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 buttonBg = self.attachAsset('skillButton', { anchorX: 0.5, anchorY: 0.5 }); var skillText = new Text2(skillName + ' (Power: ' + basePower + ', Coins: ' + coinCount + ')', { size: 40, fill: '#ffffff' }); 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.selected = false; self.setSelected = function (selected) { self.selected = selected; if (selected) { buttonBg.tint = 0x27ae60; } else { buttonBg.tint = 0x2ecc71; } }; 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 = 'selectSkill'; var playerHealth = 20; var enemyHealth = 15; var playerMaxHealth = 20; var enemyMaxHealth = 15; // Player skills - each skill now contains its own coins var playerSkills = [{ name: 'Strike', power: 3, coins: 2 }, { name: 'Bash', power: 5, coins: 1 }]; // Enemy skills - each skill now contains its own coins var enemySkills = [{ name: 'Bite', power: 2, coins: 3 }, { name: 'Claw', power: 4, coins: 2 }]; // Current selection var selectedSkill = null; // Create UI elements var playerCard = game.addChild(new PlayerCard()); playerCard.x = 1024; playerCard.y = 600; var enemyCard = game.addChild(new EnemyCard()); enemyCard.x = 1024; enemyCard.y = 300; // Skills selection var skill1Button = game.addChild(new SkillButton(playerSkills[0].name, playerSkills[0].power, playerSkills[0].coins)); skill1Button.x = 1024; skill1Button.y = 1200; var skill2Button = game.addChild(new SkillButton(playerSkills[1].name, playerSkills[1].power, playerSkills[1].coins)); skill2Button.x = 1024; skill2Button.y = 1320; // Attack button var readyButton = game.addChild(new AttackButton('BATTLE!')); readyButton.x = 1024; readyButton.y = 1700; readyButton.alpha = 0.5; // Status text var statusText = new Text2('Choose your skill', { size: 56, fill: '#ffffff' }); statusText.anchor.set(0.5, 0.5); statusText.x = 1024; statusText.y = 1000; game.addChild(statusText); // Battle result area var battleResultText = new Text2('', { size: 48, fill: '#ffffff' }); 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); // Initialize health displays playerCard.updateHealth(playerHealth, playerMaxHealth); enemyCard.updateHealth(enemyHealth, enemyMaxHealth); // 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; // 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 * 200); } 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 * 200 + 1000); } } } function resolveBattle(playerBasePower, playerSuccessfulFlips, playerCoins, enemyBasePower, enemySuccessfulFlips, enemyCoins, enemySkillName) { var playerTotalPower = playerBasePower + playerSuccessfulFlips * 2; var enemyTotalPower = enemyBasePower + enemySuccessfulFlips * 2; var resultText = 'Player: ' + playerTotalPower + ' vs Enemy: ' + 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: 300, onFinish: function onFinish() { tween(enemyCard, { tint: 0xffffff }, { duration: 300 }); } }); } 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: 300, onFinish: function onFinish() { tween(playerCard, { tint: 0xffffff }, { duration: 300 }); } }); } 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(); } }, 2000); } function resetTurn() { gameState = 'selectSkill'; selectedSkill = null; skill1Button.setSelected(false); skill2Button.setSelected(false); readyButton.alpha = 0.5; statusText.setText('Choose your skill'); // Clear coin flips LK.setTimeout(function () { coinFlipContainer.removeChildren(); }, 1000); } // Game update loop game.update = function () { // Update status text based on game state if (gameState === 'selectSkill') { statusText.setText('Choose your skill'); } else if (gameState === 'ready') { statusText.setText('Ready to battle with ' + selectedSkill.skillName + ' (' + selectedSkill.coinCount + ' coins)!'); } };
===================================================================
--- original.js
+++ change.js
@@ -167,15 +167,15 @@
healthBar.x = -250 + 250 * healthPercent;
};
return self;
});
-var SkillButton = Container.expand(function (skillName, basePower) {
+var SkillButton = Container.expand(function (skillName, basePower, coinCount) {
var self = Container.call(this);
var buttonBg = self.attachAsset('skillButton', {
anchorX: 0.5,
anchorY: 0.5
});
- var skillText = new Text2(skillName + ' (Power: ' + basePower + ')', {
+ var skillText = new Text2(skillName + ' (Power: ' + basePower + ', Coins: ' + coinCount + ')', {
size: 40,
fill: '#ffffff'
});
skillText.anchor.set(0.5, 0.5);
@@ -183,8 +183,9 @@
skillText.y = 0;
self.addChild(skillText);
self.skillName = skillName;
self.basePower = basePower;
+ self.coinCount = coinCount;
self.selected = false;
self.setSelected = function (selected) {
self.selected = selected;
if (selected) {
@@ -198,9 +199,10 @@
selectedSkill = self;
skill1Button.setSelected(false);
skill2Button.setSelected(false);
self.setSelected(true);
- gameState = 'selectCoins';
+ gameState = 'ready';
+ readyButton.alpha = 1;
}
};
return self;
});
@@ -220,51 +222,44 @@
var playerHealth = 20;
var enemyHealth = 15;
var playerMaxHealth = 20;
var enemyMaxHealth = 15;
-// Player skills
+// Player skills - each skill now contains its own coins
var playerSkills = [{
name: 'Strike',
- power: 3
+ power: 3,
+ coins: 2
}, {
name: 'Bash',
- power: 5
+ power: 5,
+ coins: 1
}];
-// Enemy skills
+// Enemy skills - each skill now contains its own coins
var enemySkills = [{
name: 'Bite',
- power: 2
+ power: 2,
+ coins: 3
}, {
name: 'Claw',
- power: 4
+ power: 4,
+ coins: 2
}];
// Current selection
var selectedSkill = null;
-var selectedCoins = 0;
// Create UI elements
var playerCard = game.addChild(new PlayerCard());
playerCard.x = 1024;
playerCard.y = 600;
var enemyCard = game.addChild(new EnemyCard());
enemyCard.x = 1024;
enemyCard.y = 300;
// Skills selection
-var skill1Button = game.addChild(new SkillButton(playerSkills[0].name, playerSkills[0].power));
+var skill1Button = game.addChild(new SkillButton(playerSkills[0].name, playerSkills[0].power, playerSkills[0].coins));
skill1Button.x = 1024;
skill1Button.y = 1200;
-var skill2Button = game.addChild(new SkillButton(playerSkills[1].name, playerSkills[1].power));
+var skill2Button = game.addChild(new SkillButton(playerSkills[1].name, playerSkills[1].power, playerSkills[1].coins));
skill2Button.x = 1024;
skill2Button.y = 1320;
-// Coin selection
-var coin1Button = game.addChild(new CoinButton(1));
-coin1Button.x = 750;
-coin1Button.y = 1500;
-var coin2Button = game.addChild(new CoinButton(2));
-coin2Button.x = 1024;
-coin2Button.y = 1500;
-var coin3Button = game.addChild(new CoinButton(3));
-coin3Button.x = 1298;
-coin3Button.y = 1500;
// Attack button
var readyButton = game.addChild(new AttackButton('BATTLE!'));
readyButton.x = 1024;
readyButton.y = 1700;
@@ -296,20 +291,20 @@
playerCard.updateHealth(playerHealth, playerMaxHealth);
enemyCard.updateHealth(enemyHealth, enemyMaxHealth);
// Battle logic
function performBattle() {
- if (!selectedSkill || selectedCoins === 0) return;
+ if (!selectedSkill) return;
gameState = 'battle';
statusText.setText('Battle in progress...');
readyButton.alpha = 0.5;
// Player's turn
var playerBasePower = selectedSkill.basePower;
- var playerCoins = selectedCoins;
+ 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 = Math.floor(Math.random() * 3) + 1;
+ var enemyCoins = enemySkill.coins;
// Clear previous coins
coinFlipContainer.removeChildren();
// Flip player coins
var playerSuccessfulFlips = 0;
@@ -421,9 +416,8 @@
}
function resetTurn() {
gameState = 'selectSkill';
selectedSkill = null;
- selectedCoins = 0;
skill1Button.setSelected(false);
skill2Button.setSelected(false);
readyButton.alpha = 0.5;
statusText.setText('Choose your skill');
@@ -436,10 +430,8 @@
game.update = function () {
// Update status text based on game state
if (gameState === 'selectSkill') {
statusText.setText('Choose your skill');
- } else if (gameState === 'selectCoins') {
- statusText.setText('Choose number of coins (1-3)');
} else if (gameState === 'ready') {
- statusText.setText('Ready to battle with ' + selectedSkill.skillName + ' and ' + selectedCoins + ' coins!');
+ statusText.setText('Ready to battle with ' + selectedSkill.skillName + ' (' + selectedSkill.coinCount + ' coins)!');
}
};
\ No newline at end of file