Universal Windows Platform – Tutorial Insider – Lucky Dominoes



comentsys.wordpress.com today features a Universal Windows Platform tutorial showing how to create a pair of Dominoes. This demonstrates a simple way of creating the look-and-feel of a Domino as well as obeying the rules of a single Domino. Although it’s a simple example it could form the basis of any domino-based game.


There’s the use of two string[], the first is a list of all the positions a dot or “pip” can appear on Domino but there are also a few extra if you wanted to make each Domino go up to nine, the second is a list of all the possible combination of Domino Tiles there can be from blank to a pair of sixes. There is also int[][] which is a list of a list of numbers – this encodes all the combinations needed to display a set number of pips from 0 to 6 there are some positions that are never set as this is a three-by-three grid but is done this way to make it easier to understand.

There’s a Random number and set of two lists to store the values of a Domino in plus how many Turns have been made. There are many methods to make the displaying of a Domino work, the first is the Add method to add one of the “pips” which is represented by an Ellipse and set to a given Row and Column on a Grid. There is also a Portion method which represents the upper and lower part of a Domino with a given name and also has a Gradient background set – the pips are added using the previous Add method and are given a name composed of the given name and position of the pip as a letter from lost of all the positions a pip can appear on a Domino.

There’s a method to define a Domino called Domino and sets the Upper and Lower Portion, this method is used by the Layout to create the pair of Dominoes used in the example. Then there is a method to get a pip GetPip used by SetPortion to set the Opacity of a given pip – this will allow each value to be displayed as needed and uses the list of list of numbers that encode all the display combinations and the SetDomino method calls this to set the upper and lower parts of a Domino to the one of the valid values from the Tiles list.

There are then methods to Shuffle a list of generated random numbers and start a New game and Choose a value from the shuffled list.

Behind the Scenes

Lucky Dominoes was inspired by Lucky Dice which had been ported from many earlier examples from Silverlight and even back as far as Visual Basic in 2005 however there’s a lot easier ways of creating the layout of a Dice and a better way of doing it using a lookup table that could then set which pips are displayed, but then to extend that something else and the closest thing to a Dice is a Domino and that became this tutorial – the technique used here was done with a Digital Clock example to help draw the LED-style display but realised this same technique which was based on how a real seven-segment display works could be extended to any similar layout and allows the layout to be created far more effeciently.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s