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

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!