Hosting Solutions
mobile_logo Table of Contents
seal_frontseal_back

Simulated Dice Throw Tutorial

Learn to simulate dice throws for any type of numbered dice. You can roll the regular six sided dice or roll a 16 sided die for Dungeons and Dragons type games. We use a simple 1 - 6 random number generation technique to pinpoint two six sided dice in this tutorial since that is the most common type of dice used in online gambling and gaming. roll_btn.addEventListener(MouseEvent.CLICK, rollDice); function rollDice(event:MouseEvent):void{ var die1:uint = Math.floor(Math.random() * 6) + 1; var die2:uint = Math.floor(Math.random() * 6) + 1; var diceTotal:uint = die1 + die2; die1_txt.text = die1.toString(); die2_txt.text = die2.toString(); status_txt.text = "You rolled "+diceTotal; if(die1 == die2){ doubles_txt.text = "DOUBLES! You get a free turn"; } else { doubles_txt.text = ""; } }
thumb

Flash Videos

General Programming

Code for Parent and Child MovieclipsCustom Mouse Cursor TutorialRandom Content Display ScriptFull Flash AS3 CSS Website Template EditableMultilayer Parallax Backgrounds TutorialMouse Wheel Zooming InteractivityPlaying Card Deck for GamesSimulated Dice Throw TutorialDress Up Game Tutorial Part 1Random Number Generator CodeDraggable OS Style WindowsCreating Desktop Applications Using Adobe AIRFull Screen Application Toggle Up and DownDrag Within Bounded SpaceSystem Capabilities Class TutorialMovieclip Reflection EffectDetecting User Mouse CoordinatesCentering Dynamic Stage ElementsTrue Fit Elements WebsiteReusable Dynamic Class Code CreationDress Up Game Tutorial Part 2