gaming_Playing_Dice.jpg
Portion of Medieval People at Play, The Walters Art Museum, Baltimore - Public Domain

There are a few ways you could extend this project.

This project has just used the A and B buttons for selecting dice. That limits what we can do. However the CLUE has touchpads as well. If we used them we could make a more complex interface. One possibility would be to support selecting multiple groups of dice. E.g. 1d2 + 2d4. We might add a modifier to that to support things like 1d10 + 2d4 + 6.

Another possibility is to make the motion trigger more advanced. In addition to a basic shake, maybe slamming the CLUE (gently) on the table could automatically roll 1d20 (probably the most common roll) regardless of what was selected.

To take it in a different direction, consider that the code doesn't try to model the physics of a tumbling die at all. It blindly generates random numbers. One step to improve this would be to ensure that it won't generate the same number two times in a row. This would make the visual effect better as well: each step in the roll would be more likely to be a different number. This would be especially noticeable when rolling a single die.

These are a few ways to expand on the code in this guide. If you come up with an interesting extension, bring it to our weekly Show and Tell and share it with the community.

This guide was first published on Mar 04, 2020. It was last updated on Mar 04, 2020.

This page (Roll with it) was last updated on Oct 22, 2021.

Text editor powered by tinymce.