comentsys.wordpress.com today features a Universal Windows Platform tutorial showing how to create a Flags Game where you need to choose which is the correct flag based on the country name displayed and if you get them all correct you win and also a good way to learn a small selection of the world’s flags and maybe even get into vexillology – which is the study or interest in flags.
There’s a Class to represent a Flag with Design property for the Designs possible with either HorizontalStripes or VerticalStripes, then a Name and list of Colours for the flag. In the main Class there’s a list of flags with each Country’s flag properties set to the correct Design and Colours. There’s a Random number generator plus a list of indexes and choices, also there’s a ConvertHexToColor method which converts the colour used in a flag to a system Color that can be used plus there’s a Shuffle method to use the random number generator to create a list of values and a Show method to display a message on screen.
The GetFlag method helps to create the correct look of a flag using a StackPanel with the correct Orientation based on the Design then creates a Rectangle for each colour in the correct Height and Width for the Design. There’s a SetButton method which will set a Button to be visible or not by setting the Opacity, the Add method is used to add all the flags plus this handles when you guess all nine and win the game by showing a message, the Layout method sets up the game to show all the flags and the Choose method gets the next flag to choose and the name of the country’s flag to find with the New method starting the game and setting the first flag to find.
Behind the Scenes
There’s a lot to be said for having fun with flags and interesting to see how similar the world’s flags are and there’s the whole subject of vexillology to get into if you want, the selection of flags used was chosen because each of the country’s flags are just solid colours – there’s Argentina or Spain that could be used or Canada but each of these has an extra element such as the Maple leaf which if missed off wouldn’t be correct and with this example it was important to include flags only made of solid colours and to make it easier with three horizontal or vertical stripes. For those who do have an interest in flags may notice that some of the proportions of the coloured bands isn’t 100% correct such as with Nigeria or France but hopefully the representations of all the flags is as those who call those countries home would be happy with and it would be possible to add more designs and add more flags such as the Union Flag for the United Kingdom or for other countries such as the United States of America or South Africa. Hopefully it’s a fun game to play and to learn from and a chance to learn to identify a small selection of world flags!