Throws two dice. Each with a different random value between 1 and 6. use only first or both as required in your game!
Press space or enter or press the button to throw. Another implementation is here
|
sel2in.com
Code snippet:
function dorand2(w, s){
document.getElementById("chng").innerHTML = '';
var odice = document.getElementById("dice");
var r1 = (getRandomInt(1, 6000) % 6) + 1;
if(w < 3){
if(w == 1){
s = "Dice A : " + r1
}else{
s += " Dice B : " + r1;
}
w++;
var timeoutID = setTimeout(dorand2, 160 + (64 * getRandomInt(1, 3)) + (getRandomInt(95, 373)), w, s);
}else{
odice.innerHTML = s + " Dice C : " + r1;
endDice();
}
}
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
(c) 2017 Tushar Kapila. v 2