Rock Paper Scissors

Page

Have you been naughty or nice?
Promotion+
Joined
Jul 15, 2015
Messages
46,749
Reaction score
7,911
FP$
315,147
Howdy guys, I'm very interested of what people will came up with this basic game. This thread will be for those that want to code and show of there work/code. I have already set up most of the requirements. All you need to do is add the missing code.

The reason for this because everyone will do it differently, the expert will probably be very similar, You have been employed by a web based game company to develop a simple Rock Paper Scissors game. The game is to be a single player game where the user can play against the computer.

The requirements are:
The game must be web based
The user selects their move from one of three buttons
The computer select it's move randomly
The moves are displayed as images (provided below)
The result must be displayed as text below the buttons - this must update instantly after the move
The result must be either: "You win!", "You lose!" or "It's a draw!"
The rules are: Paper beats Rock, Rock beats Scissors, Scirrors beats Paper
The program must keep a tally of how many games have been played
The program must keep a tally of how many wins, losses and draws there have been
You will need to use your HTML and CSS skills in this project

Here is a starting point you can base your game on:

JavaScript
Code:
function move(choicePlayer) {
    // Calculate computers move by generating a random number between 1 and 3
    
    // Use a switch statement to conver the random number to either "rock", "scissors" or "paper"
    var choiceComputer= "?";
    
    // Output the computers move
    var imageComputer = "<img src='http://www.vcampus.net.au/pluginfile.php/79451/mod_assignment/intro/rps-"+choiceComputer+".gif' />";
    document.getElementById('computer').innerHTML = "computers move goes here";
    
    // Output the players move
    var imagePlayer = "<img src='http://www.vcampus.net.au/pluginfile.php/79451/mod_assignment/intro/rps-"+choicePlayer+".gif' />";
    document.getElementById('player').innerHTML = imagePlayer;
    
    // Calculate who won (rules: paper beats rock, rock beats scissors, scirrors beats paper or a draw)
    
    // Output the result
    document.getElementById('result').innerHTML = "result goes here";
}

HTML
Code:
<h1>Rock Paper Scissors</h1>
<div id="computer"></div>
<div id="player"></div>

<p>Make your choice:</p>
<button id="rock" onclick="move(this.id);">Rock</button>
<button id="paper" onclick="move(this.id);">Paper</button>
<button id="scissors" onclick="move(this.id);">Scissors</button>

<p id="result"></p>

CSS
Code:
#player, #computer {
    border: 1px solid black;
    height: 100px;
    width: 150px;
    margin: 10px;
}

Good luck
 
Cool, I'll participate. Quick question - does the text for whether you lose, win, or if it's a draw have to be exactly what you posted?
 
You have to add the missing code. The users pick and so does the computer. It's basically all three. Win, loss and draw.

It's in the requirements.

You can have a alert box pop-up saying about you have win and etc
 
Empire said:
You have to add the missing code. The users pick and so does the computer. It's basically all three. Win, loss and draw.

It's in the requirements.

You can have a alert box pop-up saying about you have win and etc

I know, I know - I mean, you said: "...The result must be either: "You win!", "You lose!" or "It's a draw!" I'm asking if that exact text has to be used or if we can change it a bit.

And as for the alert boxes, I'd rather not - they're really tacky and ugly, TBH. 😀 I
 
Yes, exactly as the text used.

And that's fine, half the time the alert box doesn't work. Depending on what browser you are using.

Plus brackets is really good to use. Should try out brackets if you already haven't
 
Empire said:
Yes, exactly as the text used.

And that's fine, half the time the alert box doesn't work. Depending on what browser you are using.

Plus brackets is really good to use. Should try out brackets if you already haven't

Brackets?
Oh, and I'm pretty much done with the JS - just a bit of styling with CSS and I'm done. 🙂
 
Reverse Flash said:
Empire said:
Yes, exactly as the text used.

And that's fine, half the time the alert box doesn't work. Depending on what browser you are using.

Plus brackets is really good to use. Should try out brackets if you already haven't

Brackets?
Oh, and I'm pretty much done with the JS - just a bit of styling with CSS and I'm done. 🙂

http://brackets.io/
 
Reverse Flash said:
Cool, I'll participate. Quick question - does the text for whether you lose, win, or if it's a draw have to be exactly what you posted?

Hows it going? :great:
 
Back
Top Bottom