diff --git a/Games/RockPaperScissors/0paper.png b/Games/RockPaperScissors/0paper.png new file mode 100644 index 0000000..39c07c6 Binary files /dev/null and b/Games/RockPaperScissors/0paper.png differ diff --git a/Games/RockPaperScissors/0rock.png b/Games/RockPaperScissors/0rock.png new file mode 100644 index 0000000..664b9fa Binary files /dev/null and b/Games/RockPaperScissors/0rock.png differ diff --git a/Games/RockPaperScissors/0scissors.png b/Games/RockPaperScissors/0scissors.png new file mode 100644 index 0000000..8f9711d Binary files /dev/null and b/Games/RockPaperScissors/0scissors.png differ diff --git a/Games/RockPaperScissors/main.js b/Games/RockPaperScissors/main.js index 77a680e..7de53f9 100644 --- a/Games/RockPaperScissors/main.js +++ b/Games/RockPaperScissors/main.js @@ -10,20 +10,31 @@ window.onload = () => { for(let i=0;i<3;i++){ let choice = document.createElement("img"); choice.id = choices[i]; - choice.src = `${choices[i]}.png`; + choice.src = `0${choices[i]}.png`; choice.setAttribute("draggable", "false"); - choice.addEventListener("click", selectChoice); + choice.addEventListener("click", function() { + selectChoice(false, this.id); + }); document.getElementById("choices").append(choice); } } -function selectChoice(){ - you = this.id; - document.getElementById("your-choice").src = `${you}.png`; - - opponent = choices[Math.floor(Math.random()*3)]; - document.getElementById("opponent-choice").src = `${opponent}.png`; +document.addEventListener('keyup', (event) => { + if(event.key === '1' || event.key === '+'){ + you = 'rock'; + selectChoice(true); + } + if(event.key === '2' || event.key === 'ě'){ + you = 'paper'; + selectChoice(true); + } + if(event.key === '3' || event.key === 'š'){ + you = 'scissors'; + selectChoice(true); + } +}); +function outcome(you, opponent){ if(you===opponent){ playerScore++; opponentScore-=-1; @@ -51,6 +62,19 @@ function selectChoice(){ } } } +} + +function selectChoice(fast, choice = null){ + if(!fast && choice !== null){ + you = choice; + } + document.getElementById("your-choice").src = `${you}.png`; + + opponent = choices[Math.floor(Math.random()*3)]; + document.getElementById("opponent-choice").src = `${opponent}.png`; + + outcome(you, opponent); + document.getElementById("opponent-score").innerHTML = opponentScore; document.getElementById("your-score").innerHTML = playerScore; } \ No newline at end of file diff --git a/index.html b/index.html index 951f89b..c640ca8 100644 --- a/index.html +++ b/index.html @@ -17,7 +17,7 @@

Junior-BOY

Age:

- +
@@ -41,7 +41,7 @@ Promo for Games Promo for Games
diff --git a/main.js b/main.js index e335086..2d74e25 100644 --- a/main.js +++ b/main.js @@ -209,3 +209,12 @@ function time(){ time(); },1000); } + +function debug(){ + attributes.Clean.value = Infinity; + attributes.Hp.value = Infinity; + attributes.Hunger.value = Infinity; + attributes.Joy.value = Infinity; + attributes.Age.max = Infinity + display(); +} \ No newline at end of file diff --git a/style.css b/style.css index 80b51f4..e62f79a 100644 --- a/style.css +++ b/style.css @@ -32,6 +32,7 @@ main{ #anim{ width: 200px; margin-top: 1rem; + filter: drop-shadow(2px 2px 5px #aaaaaaaa); } .activ{ @@ -48,6 +49,7 @@ main{ border-radius: .5rem; display: flex; flex-direction: column; + align-items: center; justify-content: space-around; padding: 1rem; margin: .5rem; @@ -90,6 +92,22 @@ span p{ .actBTN{ display: block; + border: none; + height: 20px; + width: 50px; + text-align: center; + border-radius: 5px; + color: #fff; + background: #666666aa; + box-shadow: + inset 5px 5px 15px #777, + 5px 5px 15px #555; + cursor: pointer; + transition: .5s; +} +.actBTN:hover{ + background-color: #3c3; + transition: .1s; } .Lime{color: lime; user-select: none;}.Yellow{color: yellow; user-select: none;}.Orange{color: orange; user-select: none;}.Red{color: red; user-select: none;}.DarkRed{color: darkred; user-select: none;}