get game to make players take turns ?

Can someone explain to me how to get a game to have the players take turns rolling dice ?
Thank you!
set up a while loop that makes player 1 roll the dice, then stores the outcome, displays it, then sets the variable to a different number, breaking that while loop, and moving it on to the next one.

so, probably something like this
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <iostream>
#include <time.h>
#include <windows.h>
#include <cstdlib>
using namespace std;

int main
{

int a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,y,z;   //This allows for many players 
                                                                             //and many different variables

a = 1

while (a == 1)
{
system ("CLS");
cout << "Player One roll the dice, or pass your turn." << endl <<"1 - Roll" << endl << "2 - Pass Turn" << endl;
cin >> b

if (b == 1)
{
system ("CLS");
srand((unsigned)time(NULL));
		c = (rand() %6) +1;                        //you can change the number                      
                                                                       //after the % to account for a die
                                                                       //with a different number of sides
cout << "Player One rolled" << c;
system ("pause");                                        //This keeps the program from
                                                                   // immediately jumping to player two
a = 2;
}

else if (b == 2)
{system ("CLS");

cout << "Player One passes.";
system (pause);
a = 2}

else 
{system ("CLS");

cout<< "Come on Player One, get with the program!";
system (pause);
}
}
}


then keep doing that with the same pattern and syntax, just increasing the requisite value of "a" with each while loop.
This did help me a little bit but. Can you explain what system("CLS") is and what it does please? Also, I am wanting it to let each player have three rolls of the dice and each player a total of thirteen turns?
Thank you!
system("CLS") makes it so that the program clears the console screen and you dont have a large build-up of old text.

and if you want each player to roll three times, then i would set a to 0 outside of the while loop, then increase it by one each time player one either passes or rolls.

and to make 13 rounds in all, make another while loop that continues until some variable equals 13, and have the variable increase at the very end of the loop after each player has gone.

does that make sense?
You helped me tremendously and thank you.
I will tell you I am trying to make a yahtzee game and now I am lost again.
I need to create a class of scores and get the program to add the scores?
I am totally lost here!
Any help is appreciated very much!
1
2
3
4
5
6
7
8
9
10
class Scores
{
      public:
             int ones; int twos; int threes; int fours; int fives; int sixes;
             int twoPair; int _3ofAKind; int _4ofAKind; 
             int smallStrait;
             int largeStrait;
             int yahtzee;
             int total;      
};
Topic archived. No new replies allowed.