Jump to content
  • Advertisement
Sign in to follow this  
  • entry
    1
  • comments
    0
  • views
    3038

Entries in this blog

 

Dice Gen 0.1

// I wrote this little program and decided to put it here to remind myself what I covered in programming so far and to
// share as well.

#include
#include
#include

// DiceGen 0.1 by: Michael T. Dixon (6-7-2010)

using namespace std;


int die;

int dieChoice;
int dieTotal;

int Hold_die1;
int Hold_die2;
int Hold_die3;

bool quit = false;

void greet();

void roll_d4();
void roll_d6();
void roll_d8();
void roll_d12();

int randomNumber = rand();

int main(int argc, char *argv[])
{

do
{

srand(time(0));

greet();

while(!(cin >> dieChoice)){

system("CLS");
cin.clear();
cin.ignore(100, '\n');

greet();

cout cout }

switch(dieChoice){
case 1:

roll_d4();
break;

case 2:

roll_d6();
break;

case 3:

roll_d8();
break;

case 4:

roll_d12();
break;

case 5:
cout quit = true;
break;

default:
cout }
cout system("PAUSE");
system("CLS");

}while(!quit);

return EXIT_SUCCESS;
}

void greet()
{
cout cout
cout cout cout cout cout cout cout }


void roll_d4()
{
cout for (int i = 1; i {

die = (randomNumber %4) + 1;

cout
if (i==1){Hold_die1=die;}
if (i==2){Hold_die2=die;}
if (i==3){Hold_die3=die;}

i++;
}
dieTotal=Hold_die1+Hold_die2+Hold_die3;

cout }


void roll_d6()
{

cout for (int i = 1; i {

die = (randomNumber %6) + 1;
cout
if (i==1){Hold_die1=die;}
if (i==2){Hold_die2=die;}
if (i==3){Hold_die3=die;}

i++;
}
dieTotal=Hold_die1+Hold_die2+Hold_die3;

cout }


void roll_d8()
{

cout

for (int i = 1; i {

die = (randomNumber %8) + 1;
cout
if (i==1){Hold_die1=die;}
if (i==2){Hold_die2=die;}
if (i==3){Hold_die3=die;}

i++;

}
dieTotal=Hold_die1+Hold_die2+Hold_die3;

cout }

void roll_d12()
{
cout for (int i = 1; i {

die = (randomNumber %12) + 1;
cout
if (i==1){Hold_die1=die;}
if (i==2){Hold_die2=die;}
if (i==3){Hold_die3=die;}

i++;
}
dieTotal=Hold_die1+Hold_die2+Hold_die3;

cout
}



cat_class_code

cat_class_code

Sign in to follow this  
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!