I have been working on a dice game which allows for two players to play.
Here are my game rules:
- Player rolls 5 dice and the values are added to their totalScore;
- Rolling a 1 or 4 will result in those dice being removed and nothing is added to their totalScore.
- Player continues to roll their remaining dice until they have no dice remaining.
- Players turn ends when they have no dice remaining and they receive their totalScore
My question is, how can I obtain a Player's totalScore to output on a label once their turn is completed?
Please note, I have just started to program, so I am very new. I appreciate the feedback.
Here is my code so far,
public partial class Form1 : Form
private void Form1_Load(object sender, EventArgs e)
diceImages = new Image
dice = new int;
r = new Random();
diceTotal = 0;
labels = new Label
public void btn_roll_Click(object sender, EventArgs e)
private void rollDice()
bool OneOrFourRolled = false;
int rollTotal = 0;
int sum = 0;
int playerScore = 0;
for (int i = 0; i < dice.Length; i++)
if (dice[i] == 1 || dice[i] == 4)
dice[i] = 0;
if (dice[i] == 0)
int rollDice = r.Next(1, 7);
dice[i] = rollDice;
sum += rollDice;
if (dice[roll] == 1 || dice[roll] == 4)
TwoOrFiveRolled = true;
rollTotal += dice[roll];
diceTotal += rollTotal;
lb_liveResults.Items.Add("You scored " + sum + " points for this roll");
penalty = true;
for (int i = 0; i < labels.Length; i++)
labels[i].Image = diceImages[dice[i]];