Dice Roller Game
-
Content:
6 dice (D4, D6, D8, D10, D12, D20)
Rules:Roll the first die (D4)
If it lands on the highest possible number move onto next die and roll for highest number
If the dice does not land on the highest possible number, restart from the first die (D4)
-
ASP.NET .NET Framework (v4.8)
C#
This was a fairly simple coding project that I completed one Friday night while trying to keep my skills sharp. The idea started with my Dungeons and Dragons group chatting one night about this dice game. We got to talking, and someone in the group said that one of us needed to code it - so I did.
Code Logic
Final Game
Future Steps
I started this project with the basic button functions. I made six <asp:Button> elements, corresponding to each die, and then worked on the C#. Each button had its own ‘OnClick’ function to run a random number generator for each die.
I set the random number generator to populate a number corresponding to the number of faces, and then pull the image for the matching dice roll. If the number was the highest number (4 in this case) then it made the next dice roll button visible.
I chose to use individual images for each face because I wanted to make sure that the numbers would be placed like they are on a real dice. If I were going to optimize this project, I would most likely use the blank die image as a label background, and use ‘Label.Text = D4_Roll;’.
This was repeated for all 6 dice.
Ultimately, the only thing I will certainly add is a better win screen. As of right now this hasn’t been necessary because the win chances are so slim. I also want to add a click counter to keep track of how many dice rolls took place before winning.
Winning the Game:
Automation:
Pro: I could run this to automatically click so that the user doesn’t have to. At the end I would have a popup that reads how many clicks were needed to finish the game.
Con: This would minimize user engagement
Adjusted Probability:
Pro: I could adjust the win probability and make the game more “winnable”
Con: This could potentially make the came less satisfying. The impossible nature could feel more addictive than a high win probability.
Roll D6 (Second Die)
Roll D10 (Fourth Die)
Win Screen