Code:
Form:
private void btnRoll_Click(object sender, EventArgs e)
{
if (turn % 2 == 0) //if turn is even
{
player one = new player();
one.diceLoad();
lblRollValue.Text = Convert.ToString(one.rollValue);
one.getPosition();
lblPlayerOnePositionValue.Text = Convert.ToString(one.position);
}
}
playerClass:
Random randomGenerator;
dice gameDice;
public int rollValue,
position;
public void diceLoad()
{
randomGenerator = new Random();
gameDice = new dice(randomGenerator);
rollValue = gameDice.Roll();
}
public void getPosition()
{
position += rollValue;
}


Sign In
Create Account


Back to top









