http://postimg.org/image/3uy1elypj/
http://postimg.org/image/7q1fh6hvb/
Hi everyone, I am trying to make a rock paper scissors game that does all the things in the images placed above. I can only post two links here but if you would like more images please let me know. The game is supposed to start with no images showing until something is selected. I have some code created but its not working out well for me. I would really really appreciate it if you could help me with this! Below is my code.
<body>
<div class="game">
<div class= "choice">
<input name="player" type="radio" id="rock"
value = "0" checked="checked"/> <img src="rock.png" width="268" height="291" alt=""/>ROCK <br />
<input name="player" type="radio" id="paper"
value = "1" data-photo-url="http://www.clker.com/cliparts/Y/t/o/V/q/F/paper-md.png"/>
PAPER <br />
<input name="player" type="radio" id="scissors"
value = "2" data-photo-url="http://www.clker.com/cliparts/8/B/i/M/Y/Z/scissors-md.png" /> SCISSORS <br />
<button id = "play">
PLAY
</button>
</div>
<div class="players">
<div>
<H3>PLAYER</H3> <img class="player-pick" src="scissors-purple.png" width="268" height="291" alt=""/></div>
<div>
<H3>COMPUTER</H3><img class="computer-pick" src="http://www.clker.com/cliparts/Y/t/o/V/q/F/paper-md.png"></img>
</div>
</div>
<div class = "answers">
<li>YOUR WINS:<input type="text" id= "output" size="5" /></li>
<li>MY WINS:<input type="text" id = "output" size="5" /></li>
<li>DRAWS:<input type="text" id = "output" size="5" /></li>
<button id = "newgame">
NEW GAME
</button>
</div>
<h3 class="instructions">Make your pick and click PLAY</h3>
</div>
<script src = "projectt.js"> </script>
</body>
This is the CSS
.game {
width: 100%;
min-width: 500px;
}
.game > div {
float: left;
}
.choice {
width: 25%;
}
.players {
width: 50%;
}
.answers {
width: 25%;
}
.players > div {
width: 50%;
float: left;
min-height: 200px;
}
h3 {
text-align: center;
}
.instructions {
clear: both;
}
.players img {
display: block;
max-width: 100%;
}
I am having the biggest problem with the javascript. This is what I have:
var choiceArray = ["paper", "rock", "scissors"];
var computerChoice = Math.floor(3*Math.random());
console.log(computerChoice);
if(computerChoice=0){
computerChoice="rock";
}else if(computerChoice>1){
computerChoice="paper";
}else{
computerChoice="scissors";
}
console.log(computerChoice);