### Hog

28 points

Overview
In this simple dice game, the players decide how many rounds the game will run. Each player gets a turn in each round. During each turn, a player chooses how many dice to throw (from 1 to 10). The player gets the total number of dots on the dice as his score for the turn, unless s/he rolls a 1. If the player rolls a 1, his/her score for the turn is 0.

Variables
It is important to understand the variables in the game, in order to write good code. Here are the variables:

 Dim numDice As Integer the number of dice a player chooses to roll Dim die As Integer the number of a die on the board, from 0 to 9 Dim numRounds As Integer the number of rounds the players decide to play Dim numRound As Integer the current round number Dim numTurnsTaken As Integer the number of turns that players have taken so far Dim totalTurns As Integer the total number of turns that players will take in the game totalTurns = numRounds * 2 Dim numDie As Integer the value from rolling a die, from 1 to 6 Dim imageName As Image the name of an image that is copied from Form2 to Form1 or Form 3 Dim playerNumber As Integer the current player number, either 1 or 2 Dim playerName As String the name of the current player Dim otherPlayerName As String the name of the player who is awaiting his turn Dim lastPlayerName As String the name of the player who goes second during each round Dim player1Name As String the name of player 1 Dim player2Name As String the name of player 2 Dim player1Score As Integer the score of player 1 Dim player2Score As Integer the score of player 2 Dim rolledAOne As Boolean keeps track of whether a player rolled a 1 in his turn Dim scoreThisTurn As Integer the score a player earns on a given turn Dim rand As Double to store a random number Dim gameOver As Boolean keeps track of whether or not a game is over

Setting Up the Forms
It is important to set up the Forms correctly and understand what each control does.

Form1
Form1 is the game board. This photo shows Form1 Designer:

In the top row of Form1 you see 2 PictureBoxes and 5 Labels. The leftmost PictureBox is picPlayer1 and the other one is picPlayer2. Left to right, the Labels read lblPlayer1 - lblPlayer2 - score - score - round. The actual names of these Labels are: lblPlayer1 - lblPlayer2 - lblPlayer1Score - lblPlayer2Score - lblNumRound. I suggest that you add these 2 PictureBoxes and 5 Labels to your Form1.

In the next row, you see 10 PictureBoxes and a Label. The PictureBoxes are pic0, pic1 .. pic9. The Label is lblTurnScore. Once you create 1 PictureBox, you can use copy-paste to generate the 9 other PictureBoxes. Each PictureBox should have the following property: Behavior > SizeMode > StretchImage.

Below the PictureBoxes, you see the Label stating "How many dice to you want to roll?" This Label is called lblDice.

Next are 10 RadioButtons, named rb1, rb2 .. rb10. They are inside a GroupBox control named GroupBox1. (The GroupBox control is found in Container in the Toolbox.)

Below the RadioButtons is a Button named btnRollDice. And in the lower-left hand corner is the optional hog.

Form2
Form2 simply stores images that get copied to Form1 or Form3. This photo shows Form2:

The PictureBoxes that display the images of dice are picdie1, piedie2 .. picdie6. The PictureBox with the pig/hog is pichog.

Form3
Form3 pops up at the start of a game, and allows the players to put in basic information. This photo shows Form3 in action:

At the top of the form is an optional hog in a PictureBox.
In the next row, the players enter their names into TextBoxes, which are simply called TextBox1 and TextBox2.
In the next row is the Label "Choose how many rounds this game will go".
Below this Label is a ComboBox named cmbNumRounds.
In the bottom row are 2 Buttons, btnStart and btnRules.

The Game Being Played

Here are some images of the game in progress:

This shows the screen as a player is choosing how many dice to roll:

This screen shows the screen after a player has rolled:

This screen shows when the game is over:

Instructions for writing the code are given in the VB Source Files. Rather than start from scratch, you should download these VB Source Files to use as a starting point:
Form1Student.vb
Form3Student.vb

Your Form1 will require work. For Form2, add the needed PictureBoxes, and then copy each image into a PictureBox. Form3 is complete, though you will need to populate the dropdown menu with numbers.

To get these files into your project, first create a project. To add a second or third form, use Project > Add Windows Form. You can then copy-paste the contents of Form1Student.vb or Form3Student.vb into the nearly-blank forms in your project.

You can also download this file, which includes the images for the 6 dice, the pig and the green button:
HogResources.zip

### Demo

You can download my version of this program here, to get an idea of what your program will do when it is complete. Right-click on the link and choose 'Save Target As' to download HogZip.zip. Once the file is downloaded, double-click on it to unzip it. Then click on 'MyHog' to run the program.