»
AnglaisFran�aisVietnamien

Imprimer - Rock, Paper, Scissors - JavaScriptBank.com

Version compl�te: jsB@nk » Game » Rock, Paper, Scissors
URL: https://www.javascriptbank.com/rock-paper-scissors-index.html

Rock, Paper, Scissors © JavaScriptBank.comPlay Rock, Paper, Scissors sur votre ordinateur. Faites votre choix et l'ordinateur va choisir au hasard et puis la jeu sera marqué. Rigolo!

Version compl�te: jsB@nk » Game » Rock, Paper, Scissors
URL: https://www.javascriptbank.com/rock-paper-scissors-index.html



JavaScript
<SCRIPT LANGUAGE="JavaScript"><!-- Beginfunction playGame(choice) {with (document.game) {comp = Math.round((Math.random() * 2) + 1); var choicename;if (comp == 1) choicename = "rock";if (comp == 2) choicename = "paper";if (comp == 3) choicename = "scissors";msg.value = 'The computer chose ' + choicename + ';  ';switch(choice) { // calculates scorecase 1 : // rock         if (comp == 1) {  draw.value++; msg.value += 'It is a draw.'; break; }         if (comp == 2) {  loss.value++;  msg.value += 'You lost!';     break; }         if (comp == 3) {  win.value++; msg.value += 'You won!';      break; }case 2 : // paper         if (comp == 1) {  win.value++;  msg.value += 'You won!';      break; }         if (comp == 2) {  draw.value++; msg.value += 'It is a draw.'; break; }         if (comp == 3) {  loss.value++; msg.value += 'You lost!';     break; }case 3 : // scissors         if (comp == 1) {  loss.value++;  msg.value += 'You lost!';     break; }         if (comp == 2) {  win.value++; msg.value += 'You won!';      break; }         if (comp == 3) {  draw.value++; msg.value += 'It is a draw.'; break; }      }      msg.value += '  Go again!';   }}//  End --></script><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<form name=game><table border=1 cellpadding=5><tr><td align=center>User:</td><td align=center><a href="javascript:void(0);"onClick="playGame(1);"><img src="rock1.gif" width=29 height=23border=0></a></td><td align=center><a href="javascript:void(0);"onClick="playGame(2);"><img src="paper1.gif" width=29 height=23border=0></a></td><td align=center><a href="javascript:void(0);"onClick="playGame(3);"><img src="scissors1.gif" width=29 height=23border=0></a></td></tr><tr><td colspan=4 align=center><input type=text name=msgsize=45></td></tr><tr><td colspan=4 align=center><input type=text name=win readonly value="0" size="2">Wins   <input type=text name=loss readonly value="0" size="2">Losses   <input type=text name=draw readonly value="0"size="2"> Draws</td></tr></table></form><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


Files
http://javascriptbank.com/javascript/game/Rock_Paper_Scissors/paper.gifhttp://javascriptbank.com/javascript/game/Rock_Paper_Scissors/rock.gifhttp://javascriptbank.com/javascript/game/Rock_Paper_Scissors/scissors.gif