|
| |||||||||||||||||||
| Kainis (3) | |
|
Ok I have my code that allows the two dice to roll, however I have run into a slump, which is I am trying to output the dice as the picture and the dice as the numeric value. However everytime I change this to show the number it will break the physical dice. Heres My Code: #include <time.h> #include <iostream> #include <cstdlib> using namespace std; int dice1, dice2 = 0; void RollDice(); // The Void Program That Rolls The Dice int main() { srand(time(NULL)); int input = 1; do { if (input == 1) { system ("CLS"); RollDice(); // Function That Does Everything For The Code cout << "\n 1. Roll \n 2. Quit\n\n Your Choice Sir : "; } else if (input !=1 || input != 2) { cout << "Input Again:"; } cin >> input; } while(input!=2); return 0; } void RollDice() { dice1 = ((rand()*rand())%6)+1; // 1-6 Numbers dice2 = ((rand()*13)%6)+1; // To Make It Different It Multiplies By 13 cout << "\n\t"<<(char)218 <<(char)196<<(char)196<<(char)196 <<(char)191 << "\t" << (char)218 <<(char)196<<(char)196<<(char)196 <<(char)191<<"\n\t"<<(char)179; switch(dice1) //Switch Statement That Has All The Possible Outcomes For Dice 1 { case 1: cout << " . "; break; case 2: cout << " : "; break; case 3: cout << ". :"; break; case 4: cout << ": :"; break; case 5: cout << ":.:"; break; case 6: cout << ":::"; break; } cout <<(char)179 << "\t" << char(179); switch(dice2) //Same As Above Except For Dice 2 { case 1: cout << " . "; break; case 2: cout << " : "; break; case 3: cout << ". :"; break; case 4: cout << ": :"; break; case 5: cout << ":.:"; break; case 6: cout << ":::"; break; } cout <<(char)179 << "\n\t"<<(char)192 <<(char)196<<(char)196<<(char)196 <<(char)217 <<"\t" << (char)192 <<(char)196<<(char)196<<(char)196 <<(char)217 << endl; } | |
|
|
|