Simple console dice roller made in C++
Works great, ready to compile and run.
// Ultima Dice 0.1 Beta
// xIRCxes++ Project by Neo Nemesis
// Dice Roller
#include <iostream>
#include <cstdlib>
#include <time.h>
using namespace std;
int main ()
{
srand(time(NULL));
//cout << "Ultima Dice 0.1 Beta - xIRCxes++ Project by Neo Nemesis" <<endl;
cout << "ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»" <<endl;
cout << "ºÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»º" <<endl;
cout << "ºº Ultima Dice 1.0 ºº" <<endl;
cout << "ºº By: Neo Nemesis ºº" <<endl;
cout << "ºº xIRCxes Project ºº" <<endl;
cout << "ºº ºº" <<endl;
cout << "ºº Enter 1 for the main menu and press enter ºº" <<endl;
cout << "ºº Enter 0 to exit ºº" <<endl;
cout << "ºº ºº" <<endl;
cout << "ºÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼº" <<endl;
cout << "ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ" <<endl;
int a;
cout << "Selection: ";
cin >> a;
if (a=1) {
cout << "ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»" <<endl;
cout << "ºÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»º" <<endl;
cout << "ºº Enter 1 to Roll Dice ºº" <<endl;
cout << "ºº Enter 0 to exit ºº" <<endl;
cout << "ºº Enter selection and press enter. ºº" <<endl;
cout << "ºÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼº" <<endl;
cout << "ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ" <<endl;
cout << "Selection: ";
cin >> a;
while (a!=0) {
//Dice Roller
int D, N;
int result = 0;
cout << "Enter the number of dice you wish to roll: ";
cin >> N;
cout << "Enter the size of the dice you wish to roll (i.e. the sides): ";
cin >> D;
// process
for(int x=0;x<N;x++) {
cout << "You rolled\t" << (D = rand()%20+1) << endl;
result += D;
}
cout << "\nTotal = " << result << endl;
cout << "Roll again?" <<endl;
cout << "Enter 1 to roll again, 0 to exit." <<endl;
cin >> a;
}
}
return 0;
}
This script seems to work well, but I have on complaint. When it says enter the sides or whatever I enter 6, but when I roll all 6 of my dice it says I rolled one with 4, one with 20, one with 16, and more. Could you explain to me what the size means?
Not to get you wrong, this is a fantastic snippet.