Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <conio.h>
- #include <windows.h>
- #include <cstdlib>
- #include <time.h>
- using namespace std;
- int clr=7,v2,bal=250,bal2;
- int game2=false;
- int x=0,y=0;
- char keygame,keyclr,keymenu,keyshop,keyagree,game2key;
- char cuv[]="Hello";
- char bet;
- void setcolor (unsigned short color)
- {
- HANDLE hcon = GetStdHandle(STD_OUTPUT_HANDLE);
- SetConsoleTextAttribute(hcon,color);
- }
- void color ()
- {
- setcolor(clr);
- }
- void menu ()
- {
- system("cls");
- setcolor(14); cout<<"1."; color(); cout<<" Start a new game"<<endl;
- setcolor(14); cout<<"2."; color(); cout<<" Settings"<<endl;
- setcolor(14); cout<<"3."; color(); cout<<" Shop"<<endl<<endl;
- if(game2==false)
- {
- setcolor(14); cout<<"4."; setcolor(8); cout<<" Mini-game #2 (locked)"<<endl<<endl;
- }
- color();
- if(game2==true)
- {
- setcolor(14); cout<<"4."; color(); cout<<" Mini-game #2"<<endl<<endl;
- }
- setcolor(14); cout<<"9."; color(); cout<<" Quit game"<<endl<<endl;
- setcolor(13);
- cout<<"Balance: ";
- color();
- cout<<bal<<endl<<endl;
- keymenu=getch();
- }
- void settings ()
- {
- cout<<"Press 1 for red color."<<endl;
- cout<<"Press 2 for green color."<<endl;
- cout<<"Press 3 for blue color."<<endl;
- cout<<"Press 4 for yellow color."<<endl;
- cout<<"Press 5 for light blue color."<<endl;
- cout<<"Press 6 for pink color."<<endl;
- cout<<"Press 7 for grey color."<<endl;
- cout<<"Press 8 for white color."<<endl<<endl;
- cout<<"M = Main Menu"<<endl<<endl;
- keyclr=getch();
- if(keyclr=='1')
- {
- clr=12;
- }
- if(keyclr=='2')
- {
- clr=10;
- }
- if(keyclr=='3')
- {
- clr=9;
- }
- if(keyclr=='4')
- {
- clr=14;
- }
- if(keyclr=='5')
- clr=3;
- if(keyclr=='6')
- clr=13;
- if(keyclr=='7')
- clr=8;
- if(keyclr=='8')
- clr=7;
- if(keyclr=='m')
- {
- system("cls");
- menu();
- }
- }
- void spaces (int x)
- {
- for(int j=0;j<x;j++)
- cout<<" ";
- }
- void lines (int y)
- {
- for(int j=0;j<y;j++)
- cout<<endl;
- }
- void word ()
- {
- cout<<cuv;
- }
- int main()
- {
- color();
- menu();
- while(true and keymenu!=9)
- {
- color();
- if(keymenu!='9' and keymenu!='1' and keymenu!='2' and keymenu!='3' and keymenu!='m' and keymenu!='4')
- {
- menu();
- }
- if(keymenu=='1') // GAME
- {
- system("cls");
- if(bal==0)
- {
- cout<<"You have 0 credits. Press any key to receive 100 credits. . .";
- keygame=getch();
- bal=100;
- }
- system("cls");
- setcolor(11);
- cout<<"** DOUBLE GAME **"<<endl<<endl;
- setcolor(12);
- cout<<"Red";
- color();
- cout<<" is between 1-7 and multiplies your balance by 2."<<endl;
- setcolor(15);
- cout<<"White";
- color();
- cout<<" is between 8-14 and multiplies your balance by 2."<<endl;
- setcolor(10);
- cout<<"Green";
- color();
- cout<<" is 0 and multiplies your balance by 14."<<endl<<endl;
- system("pause");
- do
- {
- srand(time(NULL));
- v2=rand()%15;
- system("cls");
- cout<<"You have "<<bal<<" credit(s)."<<endl<<endl;
- cout<<"Place a bet: ";
- cin>>bal2;
- if(bal2<1 or bal2>bal)
- {
- do
- {
- system("cls");
- cout<<"Insufficient credits. Try again: ";
- cin>>bal2;
- }
- while(bal2<1 or bal2>bal);
- }
- system("cls");
- cout<<"You have bet "<<bal2<<" credit(s)."<<endl<<endl;
- cout<<"Press any key if you want to proceed."<<endl;
- cout<<"Press 2 if you want to modify your bet."<<endl<<endl;
- keygame=getch();
- if(keygame=='2')
- {
- system("cls");
- cout<<"You have "<<bal<<" credit(s)."<<endl<<endl;
- cout<<"Place a bet: ";
- cin>>bal2;
- }
- system("cls");
- cout<<"Choose a color (r = ";
- setcolor(12);
- cout<<"red";
- color();
- cout<<" , w = ";
- setcolor(15);
- cout<<"white";
- color();
- cout<<" , g = ";
- setcolor(10);
- cout<<"green";
- color();
- cout<<"): ";
- cin>>bet;
- cout<<endl;
- if(bet!='r' and bet!='w' and bet!='g')
- {
- do
- {
- system("cls");
- cout<<"Undefined bet. Try again: ";
- cin>>bet;
- cout<<endl;
- }
- while(bet!='r' and bet!='w' and bet!='g');
- }
- if(bet=='r')
- {
- if(v2>=1 and v2<=7)
- {
- cout<<"Congratulations! System rolled color ";
- setcolor(12);
- cout<<"red";
- color();
- cout<<" with number ";
- setcolor(12);
- cout<<v2;
- color();
- cout<<endl;
- bal+=bal2;
- }
- if(v2==0)
- {
- cout<<"Bad luck! System rolled color ";
- setcolor(10);
- cout<<"green";
- color();
- cout<<" with number ";
- setcolor(10);
- cout<<v2<<endl;
- color();
- bal-=bal2;
- }
- if(v2>=8 and v2<=14)
- {
- cout<<"Bad luck! System rolled color ";
- setcolor(15);
- cout<<"white";
- color();
- cout<<" with number ";
- setcolor(15);
- cout<<v2<<endl;
- color();
- bal-=bal2;
- }
- }
- if(bet=='g')
- {
- if(v2>=1 and v2<=7)
- {
- cout<<"Bad luck! System rolled color ";
- setcolor(12);
- cout<<"red";
- color();
- cout<<" with number ";
- setcolor(12);
- cout<<v2<<endl;
- color();
- bal-=bal2;
- }
- if(v2==0)
- {
- cout<<"Congratulations! System rolled color ";
- setcolor(10);
- cout<<"green";
- color();
- cout<<" with number ";
- setcolor(10);
- cout<<v2<<endl;
- color();
- bal+=bal2*14;
- }
- if(v2>=8 and v2<=14)
- {
- cout<<"Bad luck!! System rolled color ";
- setcolor(15);
- cout<<"white";
- color();
- cout<<" with number ";
- setcolor(15);
- cout<<v2<<endl;
- color();
- bal-=bal2;
- }
- }
- if(bet=='w')
- {
- if(v2>=1 and v2<=7)
- {
- cout<<"Bad luck! System rolled color ";
- setcolor(12);
- cout<<"red";
- color();
- cout<<" with number ";
- setcolor(12);
- cout<<v2<<endl;
- color();
- bal-=bal2;
- }
- if(v2==0)
- {
- cout<<"Bad luck! System rolled color ";
- setcolor(10);
- cout<<"green";
- color();
- cout<<" with number ";
- setcolor(10);
- cout<<v2<<endl;
- color();
- bal-=bal2*14;
- }
- if(v2>=8 and v2<=14)
- {
- cout<<"Congratulations! System rolled color ";
- setcolor(15);
- cout<<"white";
- color();
- cout<<" with number ";
- setcolor(15);
- cout<<v2<<endl;
- color();
- bal+=bal2;
- }
- }
- Sleep(1300);
- system("cls");
- if(bal==0)
- {
- system("cls");
- cout<<"You lost all your credits.";
- Sleep(1300);
- menu();
- }
- else
- {
- cout<<"Press any key to continue"<<endl<<"Press m to get to the main menu"<<endl<<endl;
- keygame=getch();
- if(keygame=='m')
- {
- system("cls");
- menu();
- }
- }
- }
- while(bal and keygame!='m');
- }
- else if(keymenu=='2') // SETTINGS
- {
- system("cls");
- settings();
- }
- else if(keymenu=='3') // SHOP
- {
- system("cls");
- cout<<"Welcome to the shop!"<<endl<<endl;
- cout<<"1. Mini-game #2 - 250 credits";
- keyshop=getch();
- if(keyshop!='1')
- {
- cout<<endl<<endl;
- cout<<"Invalid value. Try again: ";
- do
- {
- keyshop=getch();
- }while(keyshop!='1');
- }
- if(keyshop!='1' and keyshop!='m')
- {
- do
- {
- system("cls");
- cout<<"Invalid key. Try again: ";
- }while(keyshop!='1' and keyshop!='m');
- }
- if(keyshop=='1')
- {
- if(bal<250)
- {
- system("cls");
- cout<<"Insufficient credits. Press any key to get to the main menu. . .";
- keygame=getch();
- menu();
- }
- else
- {
- system("cls");
- cout<<"You currently have "; setcolor(12); cout<<bal; color(); cout<<" credits. Do you want to spend "; setcolor(12); cout<<"250"; color(); cout<<" credits on Mini-game #2? (y/n)";
- keyagree=getch();
- if(keyagree='y')
- {
- system("cls");
- game2=true;
- cout<<"Item purchased.";
- bal-=250;
- Sleep(1300);
- menu();
- }
- }
- }
- if(keyshop=='m')
- menu();
- }
- else if(keymenu=='4') // MINI-GAME #2
- {
- x=0;
- y=0;
- if(game2==false)
- {
- system("cls");
- cout<<"You must buy this item from the shop!";
- Sleep(1300);
- menu();
- }
- if(game2==true)
- {
- system("cls");
- cout<<"Controls: W A S D and M";
- while(true and game2key!='m')
- {
- game2key=getch();
- if(game2key==97)
- x--;
- if(game2key==100)
- x++;
- if(game2key==115)
- y++;
- if(game2key==119)
- y--;
- system("cls");
- lines(y);
- spaces(x);
- word();
- if(game2key=='m')
- menu();
- }
- }
- }
- else if(keymenu=='9') // QUIT
- {
- system("cls");
- cout<<"Are you sure? (y/n) ";
- keyagree=getch();
- if(keyagree=='y')
- break;
- else
- menu();
- }
- else if(keymenu=='m') // MENIU
- {
- system("cls");
- menu();
- }
- system("cls");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement