C# Windows form- Pig game Roll the dice

Monday, May 5, 2014

Hi guys It is simple pig game (dice game) written in c#.


Currently The dice image will change after I click the button"Click to roll the die". And I also want to update the label(Player's total) when I click the "Click to roll the die "bottom. How do I achieve this?



private void rollDieBotton_Click(object sender, EventArgs e) {

RollDice();


}

private void RollDice() {

for (int i = 0; i < dice.Length; i++){
dice[i] = roll.Next(1, 6);

}

dicePictureBox.Image = diceImages[dice[0]];

}

private void PigForm_Load(object sender, EventArgs e) {

diceImages = new Image[6];
diceImages[0] = Properties.Resources.Alea_1;
diceImages[1] = Properties.Resources.Alea_2;
diceImages[2] = Properties.Resources.Alea_3;
diceImages[3] = Properties.Resources.Alea_4;
diceImages[4] = Properties.Resources.Alea_5;
diceImages[5] = Properties.Resources.Alea_6;

dice = new int[1] { 0 };

roll = new Random();

}






http://ift.tt/1fLdzi4