Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // msvc++
- // paulogp
- #include <iostream>
- #include <time.h>
- #include <Windows.h> // Sleep
- using namespace std;
- int randomChamber();
- int spinBarrel();
- int randomChamber()
- {
- // 5 bullets chamber
- int the_temp = ((rand() % 5) + 1);
- return the_temp;
- }
- int spinBarrel()
- {
- int the_current_chamber;
- // assigning the loaded variable a random number
- the_current_chamber = randomChamber();
- cout << "spun to chamber " << the_current_chamber << endl;
- cout << "the chambers have been spun." << endl;
- return (the_current_chamber);
- }
- int main()
- {
- int the_loaded_barrel, the_current_barrel;
- char the_spin;
- cout << "welcome to Russian Roulette.\n";
- // load gun
- // random seed
- srand (time(NULL));
- // assigning the loaded variable a random number
- the_loaded_barrel = randomChamber();
- cout << "the revolver is loaded. spin the Barrel or quit (y, q)? ";
- cin >> the_spin;
- // go to game
- if ((the_spin == 'Y') || (the_spin == 'y'))
- {
- the_current_barrel = spinBarrel();
- cout << "shaking, you pull the trigger...\n";
- // suspense
- Sleep (4000);
- if (the_loaded_barrel != the_current_barrel)
- cout << "*click*.... the bullet wasn't in that chamber." << endl;
- else
- cout << "a loud explosion fills your ears, then... nothing.\n" << "-- You lose! --" << endl;
- // quit
- Sleep (5000);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement