Tic Tac Toe Game
This project will be an ongoing project. You will work on it over the next
few weeks at the same time you are working on weekly lab assignments.
You will create your own interface. The following is an image of the
interface I created

Requirements:
Provide a mechanism for two players to take turns claiming
squares
Once claimed the square may not be claimed by the other
player
When a player has claimed three squares in a row (horizontal,
vertical, or diagonal) display a message stating who won the game.
When all squares have been claimed and nobody has won display
a message reporting a tie.
Keep track of and report the total number of games won by
each player, and the number of ties
Provide the ability to start a new game
What I did:
I have created two versions of this program. They are
located in the Sample Executables folder in Angel
Version 1
In one of my versions I used labels and changed the BackColor of the
labels when they were clicked. To prevent another player from claiming the
square I disabled the label. When a control is disabled (enabled property =
False) the control will not respond to a click event. After each box was
selected the program inspected all the boxes (using compound If and ElseIF
statements)
If lblBox1.BackColor =
lblBox2.BackColor And _
lblBox1.BackColor =
lblBox3.BackColor And _
..................................................................... Then
............
ElseIf ......
to determine if the game had been
won or was a tie. Please be advised that there is a little
more to this since if nobody has claimed any boxes in a row they will all also
have the same color. Something to think about........
If the game was over (tie or otherwise) I disabled all of the
boxes.
lblBox1.Enabled = False
and displayed appropriate messages.
When a new game was started I enabled
all the boxes and set their ForeColor to the beginning color.
lblBox1.BackColor = Color.White
To ensure that all unclaimed boxes were the same color
throughout the program execution I set the BackColor of all the labels to the
same color in the Form_Load event. The Form_Load event is an event that always
executes when the Form is first loaded into memory.
Note: If you need to compare a Color to a "variable" Color
(different colors using the same statement) you will need to create a Color
reference variable of type Color and store the color you need to use in it.
Dim ColorTesting
As New Color 'The keyword New is
important
If ........
Then
ColorTesting = Color.Red
Else
ColorTesting = Color.Blue
End If
Version 2
In the other version instead of changing the BackColor of the
Label I assigned an image to the Image property (I used .ico files that had been
imported into the applications resources. You did this with images at the
beginning of the semester).
lblBox1.Image =
My.Resources.Smile
This version presented more challenges to my first version
because I could not simply compare the Image properties of the Labels to see if
three in a row had been selected. (I tried but it did not work.)
Instead I used the Tag property of the labels to flag the label as belonging to
a particular player . At the same time I assigned the image to the label I
stored a string identifying the player who had claimed the box
lblBox1.Tag = "red"
and then compared the strings stored in the Tag
properties to see if the same player had claimed 3 boxes in a row.
If
lblBox1.Tag.ToString = strWhosTurn And _
lblBox1.Tag.ToString = lblBox2.Tag.ToString
And _
lblBox1.Tag.ToString = lblBox3.Tag.ToString
Then
......
We will be covering tools that will be necessary / useful to
complete this project in the coming weeks. I will provide more suggestions as we
progress.
Remember to:
-
Include your name in the title bar of the form
-
Add documentation to the General Declaration Section of the class that includes
your name
a brief description of what the program does
A record of how much time you spent on the lab
-
Add documentation throughout the program to explain code whose purpose
is not obvious.
-
Adhere to all coding guidelines.
When you are confident the program works
Submit a zipped folder(s) containing the entire project(s) as an attachment in the
appropriate drop box.