User prompt
Highlight the choice in the color of the players, who choose it. Red for enemy, green for the player.
User prompt
I want to see the wins of each player at the bottom of board.
User prompt
Give both players a win counter under their id objects.
User prompt
Give both players a win counter.
User prompt
Give the information to the player, what the enemy choose and what the player choose. Also a text, why the player won or loos. Add also an info button at the top right corner. It opens a window with the rules, which object wins against which object.
Initial prompt
Scissors Stone Paper
===================================================================
--- original.js
+++ change.js
@@ -1,8 +1,9 @@
var Enemy = Container.expand(function () {
var self = Container.call(this);
var enemyGraphics = self.createAsset('enemy', 'Enemy character', .5, .5);
self.choice = null;
+ self.color = 0xff0000;
self.choose = function () {
var choices = ['scissors', 'stone', 'paper'];
self.choice = choices[Math.floor(Math.random() * choices.length)];
};
@@ -10,8 +11,9 @@
var Player = Container.expand(function () {
var self = Container.call(this);
var playerGraphics = self.createAsset('player', 'Player character', .5, .5);
self.choice = null;
+ self.color = 0x00ff00;
self.choose = function (choice) {
self.choice = choice;
};
});
@@ -57,11 +59,13 @@
result = 'Draw!';
} else if (player.choice === 'scissors' && enemy.choice === 'paper' || player.choice === 'stone' && enemy.choice === 'scissors' || player.choice === 'paper' && enemy.choice === 'stone') {
result = 'You win!';
self.playerScore++;
+ choiceBtn.tint = player.color;
} else {
result = 'You lose!';
self.enemyScore++;
+ choiceBtn.tint = enemy.color;
}
resultTxt.setText(result);
playerScoreTxt.setText('Player Score: ' + self.playerScore);
enemyScoreTxt.setText('Enemy Score: ' + self.enemyScore);