Hi,
I created a dice game using the code below. I would like to build on it, to build a craps game, asking for help on the programming logic either using if else, or switch statements. The dice can roll random numbers, would like to be able to:
1) First roll, if the dice roll 7 or 11 you win
2) First roll, if the dice roll 2,3,12 you lose
3) First roll, if the dice roll 4,5,6,8,9,10 - that becomes the point, you must roll one of these to win before you roll a 7, if you roll 7 you lose
Thanks!!
DM
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
</head>
<head>
<script>
var diceFace=new Array("images/c1.gif", "images/c2.gif", "images/c3.gif", "images/c4.gif", "images/c5.gif", "images/c6.gif");
function throwdice(){
//create a random integer between 0 and 5
var randomdice=Math.round(Math.random()5);
var randomdice2=Math.round(Math.random()5);
document.images["mydice"].src=diceFace[randomdice];
document.images["mydice2"].src=diceFace[randomdice2];
}
</script>
</head>
<body>
<img src="images/d1.gif" name="mydice" id="mydice">
<img src="images/d1.gif" name="mydice2" id="mydice2">
<form>
<input type="button" value="Throw dice!" onClick="timer()">
</form>
</body>
</html>