User prompt
VS is only shown while the battle is in place, not in the selection wheel moment
Code edit (2 edits merged)
Please save this source code
User prompt
Please center the wheel and everything happen in half of the screen in y axis.
User prompt
Ok those comments in defeats are great. You gave me an idea: let's have a keyword of why an element defeat other(s). You have for example "crushes", "breaks", "absorbs", "sharps", etc in the defeats object comment. Let's define and use those keywords to show in the game when an element defeats another. For example, "absorbs!" if a sponge wins over water.
User prompt
Can you add a comment to each element key in defats explaining what is the logic why that key element defents the value elements'
User prompt
Please change the defeats elements to these: { "rock": ["scissors", "sponge", "gas", "metal", "ice", "gun", "tree", "sand"], "paper": ["rock", "metal", "water", "gas", "sand", "ice", "air", "smoke"], "scissors": ["paper", "sponge", "air", "tree", "gas", "oil", "ice", "smoke"], "water": ["fire", "rock", "scissors", "gas", "oil", "sand", "tree", "metal"], "fire": ["paper", "scissors", "sponge", "ice", "tree", "sand", "oil", "smoke"], "air": ["fire", "gas", "smoke", "metal", "rock", "oil", "tree", "gun"], "lightning": ["water", "metal", "gun", "air", "paper", "sponge", "smoke", "sand"], "tree": ["water", "paper", "sponge", "smoke", "gun", "sand", "ice", "gas"], "gun": ["scissors", "rock", "tree", "metal", "gas", "ice", "oil", "paper"], "sponge": ["water", "metal", "air", "paper", "gas", "rock", "sand", "smoke"], "smoke": ["ice", "gun", "rock", "paper", "air", "metal", "water", "oil"], "gas": ["paper", "ice", "gun", "smoke", "air", "scissors", "sponge", "sand"], "metal": ["scissors", "tree", "ice", "fire", "gun", "oil", "rock", "sand"], "ice": ["air", "water", "paper", "sponge", "fire", "smoke", "gun", "lightning"], "sand": ["scissors", "ice", "gun", "fire", "air", "paper", "rock", "lightning"], "oil": ["rock", "scissors", "gun", "metal", "water", "gas", "lightning", "fire"] }
Code edit (1 edits merged)
Please save this source code
User prompt
Ultimate Elements Showdown
Initial prompt
A rock paper scissors game but much more complex: rock, paper, scissors, water, fire, air, lightning, human, snake, tree, wolf, gun, sponge, devil, dragon.
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var BattleElement = Container.expand(function (elementType, isPlayer) { var self = Container.call(this); self.elementType = elementType; self.isPlayer = isPlayer; var background = self.attachAsset('elementButton', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.5, scaleY: 1.5 }); var icon = self.attachAsset('elementIcon', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.2, scaleY: 1.2 }); var label = new Text2(elementType.toUpperCase(), { size: 32, fill: 0x000000 }); label.anchor.set(0.5, 0.5); label.y = 120; self.addChild(label); self.playWinAnimation = function () { var effect = self.attachAsset('winEffect', { anchorX: 0.5, anchorY: 0.5, alpha: 0.7 }); tween(self, { scaleX: 1.3, scaleY: 1.3 }, { duration: 500 }); tween(effect, { scaleX: 2, scaleY: 2, alpha: 0 }, { duration: 800, onFinish: function onFinish() { self.removeChild(effect); } }); }; self.playLoseAnimation = function () { var effect = self.attachAsset('loseEffect', { anchorX: 0.5, anchorY: 0.5, alpha: 0.7 }); tween(self, { scaleX: 0.7, scaleY: 0.7, alpha: 0.5 }, { duration: 500 }); tween(effect, { scaleX: 2, scaleY: 2, alpha: 0 }, { duration: 800, onFinish: function onFinish() { self.removeChild(effect); } }); }; return self; }); var ElementButton = Container.expand(function (elementType, index) { var self = Container.call(this); self.elementType = elementType; self.index = index; self.isSelected = false; var button = self.attachAsset('elementButton', { anchorX: 0.5, anchorY: 0.5 }); var icon = self.attachAsset('elementIcon', { anchorX: 0.5, anchorY: 0.5 }); var label = new Text2(elementType.toUpperCase(), { size: 24, fill: 0x000000 }); label.anchor.set(0.5, 0.5); self.addChild(label); self.setSelected = function (selected) { self.isSelected = selected; if (selected) { button.tint = 0xffd700; tween(self, { scaleX: 1.2, scaleY: 1.2 }, { duration: 200 }); } else { button.tint = 0x4a90e2; tween(self, { scaleX: 1.0, scaleY: 1.0 }, { duration: 200 }); } }; self.down = function (x, y, obj) { if (gameState === 'selection') { LK.getSound('select').play(); selectElement(self.elementType); } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x1a1a2e }); /**** * Game Code ****/ // Game elements and their relationships var elements = ['rock', 'paper', 'scissors', 'water', 'fire', 'air', 'lightning', 'tree', 'gun', 'sponge', 'smoke', 'gas', 'metal', 'ice', 'sand', 'oil']; // Element defeat relationships (each element defeats 8 others) var defeats = { // Rock: Heavy and solid, crushes fragile things, breaks weapons, absorbs energy 'rock': ['scissors', 'sponge', 'gas', 'metal', 'ice', 'gun', 'tree', 'sand'], // Paper: Wraps and covers, conducts electricity, absorbs liquids, blocks air flow 'paper': ['rock', 'metal', 'water', 'gas', 'sand', 'ice', 'air', 'smoke'], // Scissors: Sharp cutting tool, cuts through soft materials and gases 'scissors': ['paper', 'sponge', 'air', 'tree', 'gas', 'oil', 'ice', 'smoke'], // Water: Extinguishes fire, erodes materials, conducts electricity, flows through spaces 'water': ['fire', 'rock', 'scissors', 'gas', 'oil', 'sand', 'tree', 'metal'], // Fire: Burns combustible materials, melts solids, heats and expands gases 'fire': ['paper', 'scissors', 'sponge', 'ice', 'tree', 'sand', 'oil', 'smoke'], // Air: Feeds fire, disperses gases, creates pressure, moves objects 'air': ['fire', 'gas', 'smoke', 'metal', 'rock', 'oil', 'tree', 'gun'], // Lightning: Electrical discharge, conducts through metals and water, ionizes gases 'lightning': ['water', 'metal', 'gun', 'air', 'paper', 'sponge', 'smoke', 'sand'], // Tree: Absorbs water and nutrients, grows through materials, provides shelter 'tree': ['water', 'paper', 'sponge', 'smoke', 'gun', 'sand', 'ice', 'gas'], // Gun: Projectile weapon, breaks through barriers, fires through gases 'gun': ['scissors', 'rock', 'tree', 'metal', 'gas', 'ice', 'oil', 'paper'], // Sponge: Absorbs liquids and gases, flexible material, filters particles 'sponge': ['water', 'metal', 'air', 'paper', 'gas', 'rock', 'sand', 'smoke'], // Smoke: Obscures vision, suffocates, corrodes metals, covers surfaces 'smoke': ['ice', 'gun', 'rock', 'paper', 'air', 'metal', 'water', 'oil'], // Gas: Expands and fills spaces, displaces air, creates pressure, volatile 'gas': ['paper', 'ice', 'gun', 'smoke', 'air', 'scissors', 'sponge', 'sand'], // Metal: Strong and durable, conducts electricity, resists cutting, heavy 'metal': ['scissors', 'tree', 'ice', 'fire', 'gun', 'oil', 'rock', 'sand'], // Ice: Freezes liquids, slippery surface, preserves, expands when frozen 'ice': ['air', 'water', 'paper', 'sponge', 'fire', 'smoke', 'gun', 'lightning'], // Sand: Abrasive particles, absorbs liquids, extinguishes fire, buries objects 'sand': ['scissors', 'ice', 'gun', 'fire', 'air', 'paper', 'rock', 'lightning'], // Oil: Slippery liquid, flammable, coats surfaces, lubricates mechanisms 'oil': ['rock', 'scissors', 'gun', 'metal', 'water', 'gas', 'lightning', 'fire'] }; // Action keywords for how elements defeat others var actionKeywords = { 'rock': { 'scissors': 'crushes', 'sponge': 'crushes', 'gas': 'disperses', 'metal': 'breaks', 'ice': 'shatters', 'gun': 'blocks', 'tree': 'crushes', 'sand': 'compacts' }, 'paper': { 'rock': 'wraps', 'metal': 'covers', 'water': 'absorbs', 'gas': 'captures', 'sand': 'covers', 'ice': 'insulates', 'air': 'blocks', 'smoke': 'filters' }, 'scissors': { 'paper': 'cuts', 'sponge': 'cuts', 'air': 'cuts', 'tree': 'cuts', 'gas': 'cuts', 'oil': 'cuts', 'ice': 'cuts', 'smoke': 'cuts' }, 'water': { 'fire': 'extinguishes', 'rock': 'erodes', 'scissors': 'rusts', 'gas': 'dissolves', 'oil': 'displaces', 'sand': 'washes', 'tree': 'nourishes', 'metal': 'rusts' }, 'fire': { 'paper': 'burns', 'scissors': 'melts', 'sponge': 'burns', 'ice': 'melts', 'tree': 'burns', 'sand': 'heats', 'oil': 'ignites', 'smoke': 'burns' }, 'air': { 'fire': 'feeds', 'gas': 'disperses', 'smoke': 'clears', 'metal': 'oxidizes', 'rock': 'erodes', 'oil': 'evaporates', 'tree': 'sways', 'gun': 'deflects' }, 'lightning': { 'water': 'electrifies', 'metal': 'conducts', 'gun': 'shorts', 'air': 'ionizes', 'paper': 'ignites', 'sponge': 'shocks', 'smoke': 'disperses', 'sand': 'vitrifies' }, 'tree': { 'water': 'absorbs', 'paper': 'grows over', 'sponge': 'outgrows', 'smoke': 'filters', 'gun': 'blocks', 'sand': 'roots in', 'ice': 'breaks', 'gas': 'absorbs' }, 'gun': { 'scissors': 'shoots', 'rock': 'shatters', 'tree': 'shoots through', 'metal': 'pierces', 'gas': 'ignites', 'ice': 'shatters', 'oil': 'ignites', 'paper': 'pierces' }, 'sponge': { 'water': 'absorbs', 'metal': 'corrodes', 'air': 'filters', 'paper': 'soaks', 'gas': 'absorbs', 'rock': 'erodes', 'sand': 'absorbs', 'smoke': 'filters' }, 'smoke': { 'ice': 'melts', 'gun': 'jams', 'rock': 'corrodes', 'paper': 'stains', 'air': 'pollutes', 'metal': 'corrodes', 'water': 'pollutes', 'oil': 'mixes with' }, 'gas': { 'paper': 'dissolves', 'ice': 'sublimates', 'gun': 'corrodes', 'smoke': 'displaces', 'air': 'displaces', 'scissors': 'corrodes', 'sponge': 'fills', 'sand': 'displaces' }, 'metal': { 'scissors': 'dulls', 'tree': 'cuts', 'ice': 'breaks', 'fire': 'conducts', 'gun': 'reinforces', 'oil': 'repels', 'rock': 'crushes', 'sand': 'compacts' }, 'ice': { 'air': 'freezes', 'water': 'freezes', 'paper': 'freezes', 'sponge': 'freezes', 'fire': 'extinguishes', 'smoke': 'condenses', 'gun': 'jams', 'lightning': 'grounds' }, 'sand': { 'scissors': 'dulls', 'ice': 'melts', 'gun': 'jams', 'fire': 'smothers', 'air': 'fills', 'paper': 'abrades', 'rock': 'erodes', 'lightning': 'grounds' }, 'oil': { 'rock': 'lubricates', 'scissors': 'lubricates', 'gun': 'lubricates', 'metal': 'lubricates', 'water': 'floats on', 'gas': 'dissolves', 'lightning': 'insulates', 'fire': 'feeds' } }; // Game state variables var gameState = 'selection'; // 'selection', 'battle', 'result' var elementButtons = []; var playerElement = null; var aiElement = null; var playerBattleElement = null; var aiBattleElement = null; var vsText = null; var consecutiveWins = 0; var difficultyLevel = 1; var battleTimer = 0; // UI elements var titleText = new Text2('ULTIMATE ELEMENTS SHOWDOWN', { size: 48, fill: 0xFFFFFF }); titleText.anchor.set(0.5, 0); LK.gui.top.addChild(titleText); titleText.y = 50; var instructionText = new Text2('Choose your element', { size: 32, fill: 0xCCCCCC }); instructionText.anchor.set(0.5, 0.5); game.addChild(instructionText); instructionText.x = 1024; instructionText.y = 400; var scoreText = new Text2('Score: 0', { size: 36, fill: 0xFFFFFF }); scoreText.anchor.set(1, 0); LK.gui.topRight.addChild(scoreText); scoreText.x = -20; scoreText.y = 20; var winsText = new Text2('Wins: 0', { size: 32, fill: 0xFFFFFF }); winsText.anchor.set(1, 0); LK.gui.topRight.addChild(winsText); winsText.x = -20; winsText.y = 70; // Create element selection grid function createElementButtons() { var centerX = 1024; var centerY = 1400; var radius = 800; for (var i = 0; i < elements.length; i++) { var angle = i / elements.length * Math.PI * 2 - Math.PI / 2; var x = centerX + Math.cos(angle) * radius; var y = centerY + Math.sin(angle) * radius; var button = game.addChild(new ElementButton(elements[i], i)); button.x = x; button.y = y; elementButtons.push(button); } } // Select element function function selectElement(elementType) { if (gameState !== 'selection') { return; } playerElement = elementType; // Update button states for (var i = 0; i < elementButtons.length; i++) { elementButtons[i].setSelected(elementButtons[i].elementType === elementType); } // Start battle after short delay LK.setTimeout(function () { startBattle(); }, 500); } // AI element selection function getAIElement() { // Basic AI that becomes more strategic with difficulty if (difficultyLevel === 1) { // Random selection return elements[Math.floor(Math.random() * elements.length)]; } else if (difficultyLevel === 2) { // 30% chance to counter player's last choice if (Math.random() < 0.3 && playerElement) { var counters = []; for (var i = 0; i < elements.length; i++) { if (defeats[elements[i]] && defeats[elements[i]].indexOf(playerElement) !== -1) { counters.push(elements[i]); } } if (counters.length > 0) { return counters[Math.floor(Math.random() * counters.length)]; } } return elements[Math.floor(Math.random() * elements.length)]; } else { // 50% chance to counter player's choice if (Math.random() < 0.5 && playerElement) { var counters = []; for (var i = 0; i < elements.length; i++) { if (defeats[elements[i]] && defeats[elements[i]].indexOf(playerElement) !== -1) { counters.push(elements[i]); } } if (counters.length > 0) { return counters[Math.floor(Math.random() * counters.length)]; } } return elements[Math.floor(Math.random() * elements.length)]; } } // Start battle phase function startBattle() { gameState = 'battle'; aiElement = getAIElement(); // Hide selection elements for (var i = 0; i < elementButtons.length; i++) { tween(elementButtons[i], { alpha: 0 }, { duration: 300 }); } instructionText.setText('BATTLE!'); // Create battle elements playerBattleElement = game.addChild(new BattleElement(playerElement, true)); playerBattleElement.x = 400; playerBattleElement.y = 1000; playerBattleElement.alpha = 0; aiBattleElement = game.addChild(new BattleElement(aiElement, false)); aiBattleElement.x = 1648; aiBattleElement.y = 1000; aiBattleElement.alpha = 0; // Animate battle elements in tween(playerBattleElement, { alpha: 1, x: 512 }, { duration: 500 }); tween(aiBattleElement, { alpha: 1, x: 1536 }, { duration: 500 }); // Add VS text vsText = new Text2('VS', { size: 72, fill: 0xFF6B35 }); vsText.anchor.set(0.5, 0.5); vsText.x = 1024; vsText.y = 1000; vsText.alpha = 0; game.addChild(vsText); tween(vsText, { alpha: 1, scaleX: 1.5, scaleY: 1.5 }, { duration: 300, onFinish: function onFinish() { LK.getSound('battle').play(); // Start battle timer battleTimer = 0; } }); } // Get action keyword for how one element defeats another function getActionKeyword(winner, loser) { if (actionKeywords[winner] && actionKeywords[winner][loser]) { return actionKeywords[winner][loser]; } return 'defeats'; } // Check battle result function checkBattleResult() { var playerWins = defeats[playerElement] && defeats[playerElement].indexOf(aiElement) !== -1; var aiWins = defeats[aiElement] && defeats[aiElement].indexOf(playerElement) !== -1; if (playerWins) { return 'player'; } else if (aiWins) { return 'ai'; } else { return 'tie'; } } // Show battle result function showBattleResult() { gameState = 'result'; var result = checkBattleResult(); if (result === 'player') { LK.getSound('win').play(); playerBattleElement.playWinAnimation(); aiBattleElement.playLoseAnimation(); consecutiveWins++; var points = 10 * difficultyLevel * consecutiveWins; LK.setScore(LK.getScore() + points); var actionWord = getActionKeyword(playerElement, aiElement); instructionText.setText(playerElement.toUpperCase() + ' ' + actionWord + ' ' + aiElement.toUpperCase() + '!\nYOU WIN! +' + points + ' points'); instructionText.tint = 0x00ff00; // Increase difficulty every 3 wins if (consecutiveWins % 3 === 0 && difficultyLevel < 3) { difficultyLevel++; } } else if (result === 'ai') { LK.getSound('lose').play(); playerBattleElement.playLoseAnimation(); aiBattleElement.playWinAnimation(); consecutiveWins = 0; var actionWord = getActionKeyword(aiElement, playerElement); instructionText.setText(aiElement.toUpperCase() + ' ' + actionWord + ' ' + playerElement.toUpperCase() + '!\nYOU LOSE!'); instructionText.tint = 0xff0000; } else { instructionText.setText('TIE!'); instructionText.tint = 0xffff00; } // Update UI scoreText.setText('Score: ' + LK.getScore()); winsText.setText('Wins: ' + consecutiveWins); // Return to selection after delay LK.setTimeout(function () { resetForNextRound(); }, 2000); } // Reset for next round function resetForNextRound() { gameState = 'selection'; // Clean up battle elements if (playerBattleElement) { playerBattleElement.destroy(); playerBattleElement = null; } if (aiBattleElement) { aiBattleElement.destroy(); aiBattleElement = null; } if (vsText) { vsText.destroy(); vsText = null; } // Reset instruction text instructionText.setText('Choose your element'); instructionText.tint = 0xcccccc; // Show selection elements for (var i = 0; i < elementButtons.length; i++) { elementButtons[i].setSelected(false); tween(elementButtons[i], { alpha: 1 }, { duration: 300 }); } // Reset battle timer battleTimer = 0; } // Initialize game createElementButtons(); // Game update loop game.update = function () { if (gameState === 'battle' && playerBattleElement && aiBattleElement) { battleTimer++; // Show result after 3 seconds if (battleTimer >= 180) { // 3 seconds at 60 FPS showBattleResult(); } } };
===================================================================
--- original.js
+++ change.js
@@ -342,8 +342,9 @@
var playerElement = null;
var aiElement = null;
var playerBattleElement = null;
var aiBattleElement = null;
+var vsText = null;
var consecutiveWins = 0;
var difficultyLevel = 1;
var battleTimer = 0;
// UI elements
@@ -380,10 +381,10 @@
winsText.y = 70;
// Create element selection grid
function createElementButtons() {
var centerX = 1024;
- var centerY = 1000;
- var radius = 300;
+ var centerY = 1400;
+ var radius = 800;
for (var i = 0; i < elements.length; i++) {
var angle = i / elements.length * Math.PI * 2 - Math.PI / 2;
var x = centerX + Math.cos(angle) * radius;
var y = centerY + Math.sin(angle) * radius;
@@ -459,9 +460,9 @@
instructionText.setText('BATTLE!');
// Create battle elements
playerBattleElement = game.addChild(new BattleElement(playerElement, true));
playerBattleElement.x = 400;
- playerBattleElement.y = 1400;
+ playerBattleElement.y = 1000;
playerBattleElement.alpha = 0;
aiBattleElement = game.addChild(new BattleElement(aiElement, false));
aiBattleElement.x = 1648;
aiBattleElement.y = 1000;
@@ -479,9 +480,9 @@
}, {
duration: 500
});
// Add VS text
- var vsText = new Text2('VS', {
+ vsText = new Text2('VS', {
size: 72,
fill: 0xFF6B35
});
vsText.anchor.set(0.5, 0.5);
@@ -570,8 +571,12 @@
if (aiBattleElement) {
aiBattleElement.destroy();
aiBattleElement = null;
}
+ if (vsText) {
+ vsText.destroy();
+ vsText = null;
+ }
// Reset instruction text
instructionText.setText('Choose your element');
instructionText.tint = 0xcccccc;
// Show selection elements
A hand with its fingers symbolizing gas
Make the background darker (blue)
Make the bacgkground color darker(blue)
a triangle pointing down. In-Game asset. 2d. High contrast. No shadows
This place after a draught
This place in very windy conditions
This place but it's raining
This place but there is an electric storm
a popup frame, retro pixel style, rectangular. In-Game asset. 2d. High contrast. No shadows
A version of this frame that symbolizes that this button has boosted / improved power
a minimalistic pixel button, no text on it, just the buton. White.. In-Game asset. 2d. High contrast. No shadows
A win effect that will be over a round button and that will triger for some seconds after a win happens, scaling in x and y as an effect.. In-Game asset. 2d. High contrast. No shadows
Lose
The frame should be ice related too
The frame should be earth related too
The frame should be water related too
The frame should be wind too
A hand with its fingers symbolizing ash
A hand with its fingers symbolizing sun
A hand with its fingers symbolizing moon
A hand with a piece of leather
A hand with a piece of plastic
A hand with a piece of opaque plastic
A hand with its fingers symbolizing salt
Can you make this picture slightly lighter
Can you make this image lighter please? But not a lot lighter, just a little
A frame that symbolizes that the element inside is penalized, unboosted, has a minus to its effect. It should be shown in the frame, not inside! With some VFX effect
One drop of rain. In-Game asset. 2d. High contrast. No shadows
Yellow / Orange colour
wind. In-Game asset. 2d. High contrast. No shadows
A pixel style magician from Magicka who has an arc around him of elements to be casted (fire, water, ice, rock, etc). In-Game asset. 2d. High contrast. No shadows
Tint the wizard to blue
Make the black border of the start twice thicker
A '?' (question mark) symbol inside
A white shield. In-Game asset. 2d. High contrast. No shadows
background
Music
air
Music
storm
Music
rain
Music
draught
Music
rock
Sound effect
paper
Sound effect
scissors
Sound effect
fire
Sound effect
metal
Sound effect
water
Sound effect
airy
Sound effect
lightning
Sound effect
tree
Sound effect
gun
Sound effect
sponge
Sound effect
smoke
Sound effect
gas
Sound effect
ice
Sound effect
sand
Sound effect
oil
Sound effect
plastic
Sound effect
leather
Sound effect
sun
Sound effect
glass
Sound effect
cloth
Sound effect
ash
Sound effect
fungus
Sound effect
moon
Sound effect
salt
Sound effect
select
Sound effect
spinning
Sound effect
win
Sound effect