Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

jQuery Rock Paper Scissors Game! if your a bit bored check it out...

Hi everyone,

I am trying to learn more JavaScript as I'm lacking a little in that area so I have been putting in some time to making a little game using jQuery and this is it

http://codepen.io/Craig-Watson/pen/grqxvK

Please feel free to give me feedback and any feature suggestions all in the name of learning and experience...

Hope you like it!

Tough to say whats actually going on. Im on mobile so might just be codepen mobile being weird.

Yes this would not be that easy to use on a mobile sorry Carl

That's a nifty game you've got going there! One thing I did notice was that after pressing Play and closing the pop-up dialogue, I can still change my selection. Perhaps you should disable the Rock, Paper, and Scissors button after Play is pressed, and then enable those buttons after Reset is pressed.

Also, have you considered expanding it to Rock Paper Scissors Lizard Spock? (:

Hi Anjali,

I have played around with a few setting to be honest and not quite settled on what works best, I wondered if the 'Close & Reset' button should do the reset itself.

You would have to explain the 'Lizard Spock' part as I have never heard of it lol :) but im certainly going to expand on the idea it has been fun to make.

Thank you for your feedback!

All of the comments and answers I've seen so far are good ideas. The Lizard Spock addition was created by Sam Kass and Karen Bryla, and was subsequently used in The Big Bang Theory. Rock, Paper, and Scissors function as they normally would (Rock crushes Scissors cuts Paper covers Rock). Lizard is crushed by rock, is decapitated by Scissors, and eats Paper. Spock is disproven by Paper, smashes Scissors, and vaporizes Rock. Lizard poisons Spock. You can find a diagram and explanation on the website of the creator!

http://www.samkass.com/theories/RPSSL.html

Hi everyone!

I have added some further functionality to keep the ball rolling, your score is now tracked with the option to restart the game...

I think I need to clean the code up a little though its looking a little bloated in terms of repetition so it needs a little drying out!

Should be up on GitHub Pages Later tonight if I stop playing the damn thing and put some effort in haha!

Lizard Spock is on its way as well as a little colour just working on the images :)

Have fun!

2 Answers

Steven Parker
Steven Parker
243,134 Points

Very cute! :+1: Where did those images come from? (and as Anjali suggested, do they have "spock" and "lizard"?)

I don't think having the select buttons always work is a problem. In fact, you could make the reset function optional, and make play also always available. Anytime you press play it could make a pick and compare with the currently-displayed player selection, and score them. Reset could be a separate button.

And if you do add spock/lizard ... you could have radio buttons to choose which style game. (Classic or Nerd)

A minor visual suggestion: in the CSS rule for .btn, instead of flex-grow: 1, try just flex: 1 to give all the buttons equal widths.

Hi Steve,

Thank you for the feedback, the images are form iconfinder, I have modified them a little and feel it could do with a little colour to be honest.

I am going to have a run over the way the buttons and rest can be used to make sure it is simple and easy.

I think the idea of the radio button to choose Classic or Nerd is great so look out for that. I will stick it up on GitHub Pages today so its more accessible!

Craig

Steven Parker
Steven Parker
243,134 Points

The scorekeeping works well, but the idea is a bit silly. The potential lead in percentage of total points will always get smaller the longer you play.

It may be silly, but it could be fun to play with, if you're into analyzing data sets that have a pretty simple model associated with them in your free time. The expected value of the fraction of times you'll win is 1/3. The same is true of the number of times you tie, as well as the number of times you lose. It'd be fun to keep track of ties as well as wins and losses, and to see how many games you have to play to get reasonably close to those fractions. It'd also be fun to store the win/loss/tie data from different users, and use those data to experimentally demonstrate the Central Limit Theorem, or see how close the experimental mean/standard deviation are to the theoretical mean/standard deviation, or visualize in various ways what the data do as more samples are added to them.

Steven Parker
Steven Parker
243,134 Points

I amended my answer above :arrow_up:

Also, doesn't bootstrap have an option to make button groups look like that without all the tricky CSS?

Finally reached my computer and I think this is great! I agree with the above comment, maybe instead of hitting reset after the game, the game should restart when you click the close/reset button. Saves an extra step as I am eager to play another round right away lol. But this is inspiring me to create something too. Also maybe a counter that keeps tracks of wins/loses and overall game?....but all in all good job!

Hi Carl,

The 'Close and Reset' button is now working this seems a much cleaner solution as you can play the game in three clicks start to re start which is cool.

Yes agreed needs to track the score because then you have a reason to keep playing to beat your highest score.

I will get on it ASAP!

Thanks again for the feedback!