Dice Roller

Anonymous's picture
Anonymous
October 10, 2007 - 9:52pm
I made a dice roller I thought you all might like. Bill helped me trick it out with a blur image and sound. Bill has given me some more efficient code for the die roller. See below for three sets of dice rolled and the code for each set.

This is a small set of dice patterned after the original boxed set:


Below is the code:

<script>
  var blusm=new Array(10), redsm=new Array(10)
  var redsmX=new Image(); redsmX.src="/files/u21/red.jpg"
  var blusmX=new Image(); blusmX.src="/files/u21/blu.jpg"
  var redblursm=new Image(); redblursm.src="/files/u21/redblur.jpg"
  var blublursm=new Image(); blublursm.src="/files/u21/blublur.jpg"
  for (o=1; !(o>10); o++){
    blusm[o]=new Image(); blusm[o].src="/files/u21/blu"+(o-1)+".jpg"
    redsm[o]=new Image(); redsm[o].src="/files/u21/red"+(o-1)+".jpg"
  }
  function cleardicesm(){drawdiesm('tensm',blusmX);drawdiesm('onesm',redsmX)}
  function rollsm(numdicesm){
  cleardicesm()
  drawdiesm('onesm',redblursm)
  if (numdicesm==2) drawdiesm('tensm',blublursm)
    document.soundsm.Play()
    setTimeout('resultssm('+numdicesm+')',750)
  }
  function resultssm(numdicesm){
    drawdiesm('onesm',redsm[Math.round(Math.random()*9+1)])
    if (numdicesm==2) drawdiesm('tensm',blusm[Math.round(Math.random()*9+1)])
  }
  function drawdiesm(whichdiesm,whichsrcsm) {document.images[whichdiesm].src=whichsrcsm.src}
</script>
<form style="cursor: pointer">
  <embed src="/files/u21/DieRoll.wav" autostart="false" name="soundsm" enablejavascript="true" height="0" width="0"></embed>
  <img onclick="rollsm(2)" src="/files/u21/blu.jpg" name="tensm" />
  <img onclick="rollsm(1)" src="/files/u21/red.jpg" name="onesm" />
  <br /><input value="Clear" onclick="cleardicesm();" type="button" />
</form>

Here are the originals with double digit tens die:


Below is the code:

<script>
  var bluten=new Array(10), redone=new Array(10)
  var redoneX=new Image(); redoneX.src="/files/u21/dieX.jpg"
  var blutenX=new Image(); blutenX.src="/files/u21/dieXX.jpg"
  var redoneblur=new Image(); redoneblur.src="/files/u21/dieblurX.jpg"
  var bluetenblur=new Image(); bluetenblur.src="/files/u21/dieblurXX.jpg"
  for (m=1; !(m>10); m++){
    bluten[m]=new Image(); bluten[m].src="/files/u21/die"+(m-1)+"0.jpg"
    redone[m]=new Image(); redone[m].src="/files/u21/die"+(m-1)+".jpg"
  }
  function cleardicetop(){drawdietop('tens',blutenX);drawdietop('ones',redoneX)}
  function rolltop(numdicetop){
    cleardicetop()
    drawdietop('ones',redoneblur)
    if (numdicetop==2) drawdietop('tens',bluetenblur)
    document.sound1top.Play()
    setTimeout('resultstop('+numdicetop+')',750)
  }
  function resultstop(numdicetop){
    drawdie('ones',redone[Math.round(Math.random()*9+1)])
    if (numdicetop==2) drawdietop('tens',bluten[Math.round(Math.random()*9+1)])
  }
  function drawdietop(whichdietop,whichsrctop) {document.images[whichdietop].src=whichsrctop.src}
</script>
<form style="cursor: pointer">
  <embed src="/files/u21/DieRoll.wav" autostart="false" name="sound1top" enablejavascript="true" height="0" width="0"></embed>
  <img onclick="rolltop(2)" src="/files/u21/dieXX.jpg" name="tens" />
  <img onclick="rolltop(1)" src="/files/u21/dieX.jpg" name="ones" />
  <br /><input value="Clear" onclick="cleardicetop();" type="button" />
</form>

The following is with the single digit blue die from the boxed set:


Below is the code:

<script>
  var blu=new Array(10), red=new Array(10)
  var redX=new Image(); redX.src="/files/u21/dieX.jpg"
  var bluX=new Image(); bluX.src="/files/u21/dieXX.jpg"
  var redblur=new Image(); redblur.src="/files/u21/dieblurX.jpg"
  var blueblur=new Image(); blueblur.src="/files/u21/dieblurXX.jpg"
  for (n=1; !(n>10); n++){
    blu[n]=new Image(); blu[n].src="/files/u21/blue"+(n-1)+".jpg"
    red[n]=new Image(); red[n].src="/files/u21/die"+(n-1)+".jpg"
  }
  function cleardice(){drawdie('ten',bluX);drawdie('one',redX)}
  function roll(numdice){
    cleardice()
    drawdie('one',redblur)
    if (numdice==2) drawdie('ten',blueblur)
    document.sound1.Play()
    setTimeout('results('+numdice+')',750)
  }
  function results(numdice){
    drawdie('one',red[Math.round(Math.random()*9+1)])
    if (numdice==2) drawdie('ten',blu[Math.round(Math.random()*9+1)])
  }
  function drawdie(whichdie,whichsrc) {document.images[whichdie].src=whichsrc.src}
</script>
<form style="cursor: pointer">
  <embed src="/files/u21/DieRoll.wav" autostart="false" name="sound1" enablejavascript="true" height="0" width="0"></embed>
  <img onclick="roll(2)" src="/files/u21/dieXX.jpg" name="ten" />
  <img onclick="roll(1)" src="/files/u21/dieX.jpg" name="one" />
  <br /><input value="Clear" onclick="cleardice();" type="button" />
</form>

Enjoy!
Comments:

Anonymous's picture
Corjay (not verified)
October 12, 2007 - 10:38am
I've been pondering that. So far what I have in mind is a entry field that you can press an add button to put the results into it and then when you've grabbed all the results, you press equal and it tabulates all the rolls for you, but I wouldn't know the first thing how to program that.

Thanks for adding the feature. :)

CleanCutRogue's picture
CleanCutRogue
October 12, 2007 - 10:56am
Corjay wrote:
I've been pondering that. So far what I have in mind is a entry field that you can press an add button to put the results into it and then when you've grabbed all the results, you press equal and it tabulates all the rolls for you, but I wouldn't know the first thing how to program that.

Thanks for adding the feature. :)
If used in a real game, it would be nicer to have a floating popup or more robust block in the sidebar that handles dice rolls somehow... which would report back to the Referee what was rolled and what the total was.

For example, in game chat the Referee might say "Corjay - roll 4d10 for damage" and then you would go over to your popup that's always there (or your more robust block in your left sidebar), and select "4" somehow, then click "ROLL" and have it generate 4 red dice randomized on a popup with a single "CLOSE" button under them, and send the result to the Referee in a form of "Corjay rolls 4d10 and gets a 22."

3. We wear sungoggles during the day. Not because the sun affects our vision, but when you're cool like us the sun shines all the time.

-top 11 reasons to be a Yazirian, ShadowShack


Anonymous's picture
w00t (not verified)
October 12, 2007 - 12:55pm
CleanCutRogue wrote:
I TOTALLY prefer the smaller version. Those really *FEEL* like Star Frontiers original dice from the boxed set! Love it.

If you go to your user profile and click "EDIT", then on the blue "Account" button to get to your personal account settings, you can now enable a "Dice Roller" block in your customization options. It puts a lil dice roller right under your quicklinks in the left sidebar.

What about rolling other dice quantities - such as a frag grenade's 8d10?


<<diceroller>>


Can I get the dice roller in my profile page?

Anonymous's picture
Corjay (not verified)
October 12, 2007 - 1:18pm
w00t wrote:
CleanCutRogue wrote:
I TOTALLY prefer the smaller version. Those really *FEEL* like Star Frontiers original dice from the boxed set! Love it.

If you go to your user profile and click "EDIT", then on the blue "Account" button to get to your personal account settings, you can now enable a "Dice Roller" block in your customization options. It puts a lil dice roller right under your quicklinks in the left sidebar.

What about rolling other dice quantities - such as a frag grenade's 8d10?
<<diceroller>>


Can I get the dice roller in my profile page?
Spoken like a true junkie. The side bar isn't good enough for you, w00t? Now you want it in your profile? Should we put it that top of each page too? Wink Laughing

CleanCutRogue's picture
CleanCutRogue
October 12, 2007 - 1:28pm
w00t wrote:
CleanCutRogue wrote:
I TOTALLY prefer the smaller version. Those really *FEEL* like Star Frontiers original dice from the boxed set! Love it.

If you go to your user profile and click "EDIT", then on the blue "Account" button to get to your personal account settings, you can now enable a "Dice Roller" block in your customization options. It puts a lil dice roller right under your quicklinks in the left sidebar.

What about rolling other dice quantities - such as a frag grenade's 8d10?


<<diceroller>>


Can I get the dice roller in my profile page?
You have the code right there... put it in if you want to, why should I have to make a tag for it?
3. We wear sungoggles during the day. Not because the sun affects our vision, but when you're cool like us the sun shines all the time.

-top 11 reasons to be a Yazirian, ShadowShack


Anonymous's picture
w00t (not verified)
October 12, 2007 - 1:34pm
CleanCutRogue wrote:
You have the code right there... put it in if you want to, why should I have to make a tag for it?


I think there has been a misunderstanding.
/me waves hand
You are at our whim todo whatever we want on this site.

Kiss Laughing

Full Bleed's picture
Full Bleed
November 2, 2007 - 2:28am
So, what's the chance of getting a Java version of this: http://oos.moxiecode.com/flash8/dice_test.html

;)



Anonymous's picture
Corjay (not verified)
November 2, 2007 - 6:12am
Money mouthKiss

Anonymous's picture
w00t (not verified)
November 2, 2007 - 6:16am
Full Bleed wrote:
So, what's the chance of getting a Java version of this: http://oos.moxiecode.com/flash8/dice_test.html
;)


I the dice roller on this site is JS.
You can use the scripts provided.

Anonymous's picture
Corjay (not verified)
November 2, 2007 - 7:35am
w00t wrote:
Full Bleed wrote:
So, what's the chance of getting a Java version of this: http://oos.moxiecode.com/flash8/dice_test.html
;)


I the dice roller on this site is JS.
You can use the scripts provided.
His point was that it's Flash, and wondering if we could do the 10-sided dice in the same way. It requires more than the applet info. It requires vectored images and other stuff.