+ 1
Rock Paper Scissors game Help.
I’m trying to make Rock Paper Scissors game, and before I go any further, I need help taking care of this problem. JS/ The go_btn is the button that says ‘ROCK’. This is how the game goes. You click ‘ROCK’, and then at the bottom the emojis say Paper Scissors Shoot (with rotating motion). On shoot you have to pick your weapon (the three emojis at the top). But the ‘ROCK’ button is causing problems. The more you click on it, the score keeps adding more than one (+1, +1, +2, +3...) I’m not sure how to... https://code.sololearn.com/Wo4uSXbgnm5T/?ref=app
10 Antworten
+ 1
the reason is that your rock, paper, scissors add event listener in play()
so when player clicked go_btn, it adds the event listener multiple times, so after say 3 clicks of go_btn, one click of paper will become playing paper for three times.
solution is to take those three addEventListener out of play(), a good place is below go_btn addEventListener
+ 1
default display none
in play(), set style.display
+ 1
use random syntax
0
I didn’t finish my thought:
I’m not even sure how we would fix that. I feel like I’m expecting too much.
0
Gordon Yeah, I could pit it outside, but
I want it to be like...
You can’t press on the options (rock, paper, sciss..), befoe clicking the ‘ROCK’ button.
have to click on ‘ROCK’ everytime before it you can click on the options (rock, paper, sc...)
0
Gordon , display the buttons, none| block, when ‘ROCK’ clicked?
0
yes, in css, display none
in button event listener, set their style.display block (or other appropriate value)
0
Check this men
https://code.sololearn.com/cgDhpLufWanI/?ref=app
0
https://code.sololearn.com/ccHdhgoKlLtV/?ref=app
It can help you
0
Leandro Blandi , Anay Sah :
i kind of know how to do that, but this is a little different.
..