What is d4 Demo?
The only down side is a digital die(4) can't be used as emergency caltrops
Example
Result:
How the Template Works
The code for this demo creates an object showcasing a feature of the RollPlayer.js
library and returns it to the template as demo.rollable
. Both when the page
loads and when the button above is pressed the template code calls demo.rollable.roll()
and the returned result is displayed above. This process is identicle for all the demos
allowing the explanations below to focus on only the object being demoed.
Every result is also logged to the console
if you want to see a history after
a bunch of button clicks.
Version
1.0
Authors
- Derek Pennycuff
Full source
- 1: var demo = function() {
- 2: var d4 = RollPlayer.die(4);
- 3: return { rollable : d4 };
- 4: }();
Explanations
We're creating a wrapper object called demo
so that the template code can access the inner workings of this particular example.
- 1: var demo = function() {
The simpelest possible use of the RolePlayer.js library is to simulate the traditional polyhedral dice. Here's how you create a four sided die.
- 2: var d4 = RollPlayer.die(4);
Return an object so that our template code can access the star of this example as demo.rollable
- 3: return { rollable : d4 };
- 4: }();