1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
|
/* In this game, there will be a ninja.
He will kill the dark evil Ninja. He will go to
New York, L.A, or San Francisco to search for the evil Ninja.
When he goes to the correct one, he will battle the evil Ninja.
*/
#include <iostream>
#include <string>
#include <fstream>
#include <windows.h>
#include <Winuser.h>
using namespace std;
void name(); //function for the name of the user
char getName(); // gets the name of the person.
void dialogue(string name, string text); // use for talking
void keystroke(); // any key to continue
int main()
{
string sPlayAgain;
string *pPlayAgain;
pPlayAgain = &sPlayAgain;
string yes;
Sleep(1000);
cout <<"\nWelcome to Ninja!\n" << endl;
Sleep(2000);
do{
do{
name(); //remember to leave out "void".
ifstream nameFile("name.txt"); //reads file
string name;
nameFile >> name; //using pointer from L23
cout << "\nYour name is.. " << name << endl;
Sleep(1500);
cout << "\n Is that correct..?";
cout << "\n Type Yes or No\n\n";
cin >> yes;
}while(yes != "Yes");
/* ************ Start with the game! ************/
string beginName;
ifstream getTheName("name.txt");
getTheName >> beginName;
Sleep(1500);
dialogue("Narrator","The city is burning. There are dead corpse everywhere...");
dialogue(beginName,"Oh my god. I just left to go buy some groceries\n and this is what happened?");
dialogue("Unknown","...");
dialogue(beginName, "Who's there?!");
dialogue("Pirate", beginName + "..cough..cough..");
dialogue(beginName, "Oh my.. who did this to you? Was it, the dark evil ninja?");
dialogue("Pirate", "yes..");
dialogue(beginName, "please.. don't speak.");
dialogue("Pirate", "I'm sorry...");
dialogue(beginName, "Why are you sorry for?");
dialogue("Pirate", "I couldn't stop him..");
dialogue(beginName, "Don't worry... I'll.. i'll..!!");
dialogue("Pirate", "*Head drops down*");
keystroke();
dialogue(beginName, "Nooooooooooo! PIRATE!");
dialogue(beginName, "I must avenge my friend..time to meditate..");
/* ***********BELOW END GAME SEQUENCE************** */
cout << "\nWould you like to play again? Please type Yes if you do. \n";
cin >> sPlayAgain;
if (sPlayAgain == "No")
{
cout <<"\n THANK YOU FOR PLAYING! \n";
}
}while(*pPlayAgain == "Yes");
return 0;
}
void name()
{
Sleep(1000);
ofstream nameFile("name.txt");
if(nameFile.is_open())
{
cout <<"\nWhat is your name? Press Ctrl+Z to quit\n" << endl;
string name;
cin >> name;
nameFile << name;
nameFile.close();
}
}
void dialogue(string name, string text)
{
string Name;
Name = name;
cout << endl << Name << ":\n " << text << endl;
Sleep(3000);
}
void keystroke()
{
int i;
while((GetAsyncKeyState(i!=13) == -32767))
{
cout<< "Please press enter";
cin.get();
}
}
|