So I made this a few days ago... as a little fun. I've wanted to mess around with dice game for a bit anyway.
May as well post it, =P
You can try it if you want, but you need to copy paste the code into a compiler, language is C++.
So basically what it does in picture form: (This is from running it)
Asks for what mode you want to play. In all of the pictures I'm doing standard.
Little description of game mode, blah blah blah.
Shows what computer rolled. Player has to choose if their roll be be more or less. Classic kind of thing.
Yup, betting. Player inputs the number of coins they want to bet. If they try to be more than they have it puts it at max.
Message if you tie. You get your bet back.
Message if you win. You get back double your bet.
Message if you lose. (Sucker!)
Asks to access shop...
But said shop is currently empty. Maybe I'll add something sometime.
And asks if you want to play again. If yes, it loops the process until you say no or X it out.
And if you do say no, then it says bye and also how much you got.
Phew, there. I was wondering if any of you had any suggestions? And I like to post random stuff I do.
- Spoiler:
- // Dice Game Upgraded.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <string>
#include <cstdlib>
#include <ctime> //used to identify time as current time. Can be used in seeding a RNG.
#include <iostream>
#include <stdlib.h>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
int gameMode;
char playAgain,shopAccess;
int greatLess, newTotal, playerCoins, bet;
cout<<"Select Game Mode:"<<endl;
cout<<"1. Standard"<<endl<<"2. Risky"<<endl<<"3. Blind"<<endl<<"4. Easy"<<endl<<endl;
cin>>gameMode;
//initializes variables
shopAccess='n';
newTotal=0;
playerCoins=20;
playAgain='y';
if(gameMode==1)
{
cout<<endl<<"DICE GAME STANDARD!"<<endl<<"Nothing is special about this mode. Just basic dice!"<<endl<<endl<<"Ready to play?"<<endl;
system("pause");
system("cls");
while (playAgain== 'y')
{
if (playerCoins==0)
{
cout<<"You're out of money! GAME OVER!"<<endl<<endl;
system ("pause");
system ("cls");
break;
}
srand(static_cast<unsigned int>(time(0)));
int myNumber = rand();
int myDie = (myNumber %6)+1;
cout<<"I rolled a "<<myDie<<endl;
cout<<"Will your number roll be more, less, or equal to mine?"<<endl<<"1 for more, 2 for less. If it's equal, it's a tie"<<endl;
cin>>greatLess;
cout<<endl<<"You have: "<<playerCoins<<" coins"<<endl<<"How many coins would you like to bet?"<<endl;
cin>>bet;
if (bet > playerCoins)
{
cout<<"You tried to bet more that you have. You will bet your maximum number of coins."<<endl;
bet=playerCoins;
}
cout<<endl;
srand(static_cast<unsigned int>(time(0)));
int yourNumber = rand();
int yourDie = (yourNumber %6)+1;
cout<<"Ready to compare?"<<endl<<endl<<endl;
system("pause");
system("cls");
cout<<"I rolled a: "<<myDie<<endl;
cout<<"You rolled a: "<<yourDie<<endl<<endl<<endl;
if (yourDie > myDie && greatLess==1)
{
cout<<yourDie<<">"<<myDie<<endl<<"You win!"<<endl;
newTotal = playerCoins + bet;
cout<<"Your new coin total is: "<<newTotal<<endl;
}
else if (yourDie < myDie && greatLess==2)
{
cout<<yourDie<<"<"<<myDie<<endl<<"You win!"<<endl;
newTotal = playerCoins + bet;
cout<<"Your new coin total is: "<<newTotal<<endl;
}
else if (yourDie > myDie &&greatLess==2)
{
cout<<yourDie <<"<"<< myDie<<" is not true"<<endl<<"You lose."<<endl;
newTotal = playerCoins - bet;
cout<<"Your new coin total is: "<<newTotal<<endl;
}
else if (yourDie < myDie &&greatLess==1)
{
cout<<yourDie <<">"<< myDie<<" is not true."<<endl<<"You lose."<<endl;
newTotal = playerCoins- bet;
cout<<"Your new coin total is: "<<newTotal<<endl;
}
else if (yourDie == myDie)
{
cout<<"They're equal. Tie! No coins for either side."<<endl;
cout<<"Your new coin total is: "<<playerCoins<<endl;
playerCoins=newTotal;
}
system ("pause");
system("cls");
playerCoins=newTotal;
newTotal=playerCoins;
cout<<"Your coins total is: "<<playerCoins<<endl<<endl;
cout<<"Would you like to access shop? (y/n)"<<endl;
cin>>shopAccess;
if (shopAccess=='y')
{
system ("cls");
cout<<"Welcome to the shop! What would you like to buy?"<<endl<<"Type the number of the item you wish to buy."<<endl<<endl<<"The shop is empty!"<<endl;
system ("pause");
}
shopAccess='n';
system ("cls");
cout<<"Would you like to play again? (y/n)"<<endl<<"Play again? ";
cin>>playAgain;
system("CLS");
}
}
else if (gameMode==2)
{
cout<<endl<<"DICE GAME RISKY!"<<endl<<"In this mode, you always bet all your coins! If you run out, you get 10 more."<<endl<<endl<<"Ready to play?"<<endl;
system("pause");
system("cls");
while (playAgain== 'y')
{
if(playerCoins==0)
{
cout<<"You're out of money! Risky Mode is enabled, so +10 coins."<<endl;
newTotal=playerCoins+10;
playerCoins=newTotal;
system ("pause");
system ("cls");
}
srand(static_cast<unsigned int>(time(0)));
int myNumber = rand();
int myDie = (myNumber %6)+1;
cout<<"I rolled a "<<myDie<<endl;
cout<<"Will your number roll be more, less, or equal to mine?"<<endl<<"1 for more, 2 for less. If it's equal, it's a tie"<<endl;
cin>>greatLess;
cout<<endl<<"You have: "<<playerCoins<<" coins"<<endl;
cout<<"Risky Mode enabled! You will bet all your coins."<<endl;
bet=playerCoins;
cout<<endl;
srand(static_cast<unsigned int>(time(0)));
int yourNumber = rand();
int yourDie = (yourNumber %6)+1;
cout<<"Ready to compare?"<<endl<<endl<<endl;
system("pause");
system("cls");
cout<<"I rolled a: "<<myDie<<endl;
cout<<"You rolled a: "<<yourDie<<endl<<endl<<endl;
if (yourDie > myDie &&greatLess==2)
{
cout<<yourDie <<"<"<< myDie<<" is not true"<<endl<<"You lose."<<endl;
newTotal = playerCoins - bet;
cout<<"Your new coin total is: "<<newTotal<<endl;
}
else if (yourDie < myDie &&greatLess==1)
{
cout<<yourDie <<">"<< myDie<<" is not true."<<endl<<"You lose."<<endl;
newTotal = playerCoins- bet;
cout<<"Your new coin total is: "<<newTotal<<endl;
}
else if (yourDie == myDie)
{
cout<<"They're equal. Tie! No coins for either side."<<endl;
cout<<"Your new coin total is: "<<playerCoins<<endl;
playerCoins=newTotal;
}
else if (yourDie > myDie && greatLess==1)
{
cout<<yourDie<<">"<<myDie<<endl<<"You win!"<<endl;
newTotal = 2*(playerCoins + bet);
cout<<"Your new coin total is: "<<newTotal<<endl;
}
else if (yourDie < myDie && greatLess==2)
{
cout<<yourDie<<"<"<<myDie<<endl<<"You win!"<<endl;
newTotal = 2*(playerCoins + bet);
cout<<"Your new coin total is: "<<newTotal<<endl;
}
system ("pause");
system("cls");
playerCoins=newTotal;
newTotal=playerCoins;
cout<<"Your coins total is: "<<playerCoins<<endl<<endl;
cout<<"Would you like to access shop? (y/n)"<<endl;
cin>>shopAccess;
if (shopAccess=='y')
{
system ("cls");
cout<<"Welcome to the shop! What would you like to buy?"<<endl<<"Type the number of the item you wish to buy."<<endl<<endl;
system ("pause");
}
shopAccess='n';
system ("cls");
cout<<"Would you like to play again? (y/n)"<<endl<<"Play again? ";
cin>>playAgain;
system("CLS");
}
}
else if(gameMode==3)
{
cout<<endl<<"DICE GAME BLIND!"<<endl<<"In this mode, you can't see what number the computer rolled."<<endl<<endl<<"Ready to play?"<<endl;
system("pause");
system("cls");
while (playAgain== 'y')
{
if (playerCoins==0)
{
cout<<"You're out of money! GAME OVER!"<<endl<<endl;
system ("pause");
system ("cls");
break;
}
srand(static_cast<unsigned int>(time(0)));
int myNumber = rand();
int myDie = (myNumber %6)+1;
cout<<"I rolled a (BLINDED)"<<endl;
cout<<"Will your number roll be more, less, or equal to mine?"<<endl<<"1 for more, 2 for less. If it's equal, it's a tie"<<endl;
cin>>greatLess;
cout<<endl<<"You have: "<<playerCoins<<" coins"<<endl<<"How many coins would you like to bet?"<<endl;
cin>>bet;
if (bet > playerCoins)
{
cout<<"You tried to bet more that you have. You will bet your maximum number of coins."<<endl;
bet=playerCoins;
}
cout<<endl;
srand(static_cast<unsigned int>(time(0)));
int yourNumber = rand();
int yourDie = (yourNumber %6)+1;
cout<<"Ready to compare?"<<endl<<endl<<endl;
system("pause");
system("cls");
cout<<"I rolled a: "<<myDie<<endl;
cout<<"You rolled a: "<<yourDie<<endl<<endl<<endl;
if (yourDie > myDie && greatLess==1)
{
cout<<yourDie<<">"<<myDie<<endl<<"You win!"<<endl;
newTotal = playerCoins + bet;
cout<<"Your new coin total is: "<<newTotal<<endl;
}
else if (yourDie < myDie && greatLess==2)
{
cout<<yourDie<<"<"<<myDie<<endl<<"You win!"<<endl;
newTotal = playerCoins + bet;
cout<<"Your new coin total is: "<<newTotal<<endl;
}
else if (yourDie > myDie &&greatLess==2)
{
cout<<yourDie <<"<"<< myDie<<" is not true"<<endl<<"You lose."<<endl;
newTotal = playerCoins - bet;
cout<<"Your new coin total is: "<<newTotal<<endl;
}
else if (yourDie < myDie &&greatLess==1)
{
cout<<yourDie <<">"<< myDie<<" is not true."<<endl<<"You lose."<<endl;
newTotal = playerCoins- bet;
cout<<"Your new coin total is: "<<newTotal<<endl;
}
else if (yourDie == myDie)
{
cout<<"They're equal. Tie! No coins for either side."<<endl;
cout<<"Your new coin total is: "<<playerCoins<<endl;
playerCoins=newTotal;
}
system ("pause");
system("cls");
playerCoins=newTotal;
newTotal=playerCoins;
cout<<"Your coins total is: "<<playerCoins<<endl<<endl;
cout<<"Would you like to access shop? (y/n)"<<endl;
cin>>shopAccess;
if (shopAccess=='y')
{
system ("cls");
cout<<"Welcome to the shop! What would you like to buy?"<<endl<<"Type the number of the item you wish to buy."<<endl<<endl<<"The shop is empty!"<<endl;
system ("pause");
}
shopAccess='n';
system ("cls");
cout<<"Would you like to play again? (y/n)"<<endl<<"Play again? ";
cin>>playAgain;
system("CLS");
}
}
if(gameMode==4)
{
cout<<endl<<"DICE GAME Easy!"<<endl<<"In this mode, you win many more coins than your bet, and lose much less!"<<endl<<endl<<"Ready to play?"<<endl;
system("pause");
system("cls");
while (playAgain== 'y')
{
if (playerCoins==0)
{
cout<<"You're out of money! GAME OVER!"<<endl<<endl;
system ("pause");
system ("cls");
break;
}
srand(static_cast<unsigned int>(time(0)));
int myNumber = rand();
int myDie = (myNumber %6)+1;
cout<<"I rolled a "<<myDie<<endl;
cout<<"Will your number roll be more, less, or equal to mine?"<<endl<<"1 for more, 2 for less. If it's equal, it's a tie"<<endl;
cin>>greatLess;
cout<<endl<<"You have: "<<playerCoins<<" coins"<<endl<<"How many coins would you like to bet?"<<endl;
cin>>bet;
if (bet > playerCoins)
{
cout<<"You tried to bet more that you have. You will bet your maximum number of coins."<<endl;
bet=playerCoins;
}
cout<<endl;
srand(static_cast<unsigned int>(time(0)));
int yourNumber = rand();
int yourDie = (yourNumber %6)+1;
cout<<"Ready to compare?"<<endl<<endl<<endl;
system("pause");
system("cls");
cout<<"I rolled a: "<<myDie<<endl;
cout<<"You rolled a: "<<yourDie<<endl<<endl<<endl;
if (yourDie > myDie && greatLess==1)
{
cout<<yourDie<<">"<<myDie<<endl<<"You win!"<<endl;
newTotal = 4*(playerCoins + bet);
cout<<"Your new coin total is: "<<newTotal<<endl;
}
else if (yourDie < myDie && greatLess==2)
{
cout<<yourDie<<"<"<<myDie<<endl<<"You win!"<<endl;
newTotal = 4*(playerCoins + bet);
cout<<"Your new coin total is: "<<newTotal<<endl;
}
else if (yourDie > myDie &&greatLess==2)
{
cout<<yourDie <<"<"<< myDie<<" is not true"<<endl<<"You lose."<<endl;
newTotal = playerCoins - (bet/2);
cout<<"Your new coin total is: "<<newTotal<<endl;
}
else if (yourDie < myDie &&greatLess==1)
{
cout<<yourDie <<">"<< myDie<<" is not true."<<endl<<"You lose."<<endl;
newTotal = playerCoins- (bet/2);
cout<<"Your new coin total is: "<<newTotal<<endl;
}
else if (yourDie == myDie)
{
cout<<"They're equal. Tie! No coins for either side."<<endl;
cout<<"Your new coin total is: "<<playerCoins<<endl;
playerCoins=newTotal;
}
system ("pause");
system("cls");
playerCoins=newTotal;
newTotal=playerCoins;
cout<<"Your coins total is: "<<playerCoins<<endl<<endl;
cout<<"Would you like to access shop? (y/n)"<<endl;
cin>>shopAccess;
if (shopAccess=='y')
{
system ("cls");
cout<<"Welcome to the shop! What would you like to buy?"<<endl<<"Type the number of the item you wish to buy."<<endl<<endl<<"The shop is empty!"<<endl;
system ("pause");
}
shopAccess='n';
system ("cls");
cout<<"Would you like to play again? (y/n)"<<endl<<"Play again? ";
cin>>playAgain;
system("CLS");
}
}
cout<<"Thanks for playing!"<<endl;
cout<<"Your grand coin total was: "<<playerCoins<<endl;
return 0;
}
May as well post it, =P
You can try it if you want, but you need to copy paste the code into a compiler, language is C++.
So basically what it does in picture form: (This is from running it)
Asks for what mode you want to play. In all of the pictures I'm doing standard.
Little description of game mode, blah blah blah.
Shows what computer rolled. Player has to choose if their roll be be more or less. Classic kind of thing.
Yup, betting. Player inputs the number of coins they want to bet. If they try to be more than they have it puts it at max.
Message if you tie. You get your bet back.
Message if you win. You get back double your bet.
Message if you lose. (Sucker!)
Asks to access shop...
But said shop is currently empty. Maybe I'll add something sometime.
And asks if you want to play again. If yes, it loops the process until you say no or X it out.
And if you do say no, then it says bye and also how much you got.
Phew, there. I was wondering if any of you had any suggestions? And I like to post random stuff I do.