Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <fstream>
- #include <string>
- #include <cstdlib>
- #include <ctime>
- using namespace std;
- void splashScreen();
- void login();
- void command();
- void startzone();
- void starterSwamp();
- void lockedShack();
- void turnBack();
- void encounter();
- void movement();
- char userCommand[30];
- int x, y;
- int main()
- {
- ifstream inputData;
- inputData.open("data.txt");
- splashScreen();
- login();
- do{
- //sets player grid to 0,0 until proper login system is working
- x = 0; y = 0;
- command();
- //checks for movement each command
- movement();
- //Startzone (0, 0)
- if(x == 0 && y == 0)
- startzone();
- //Encounter in cave(0, 1)
- else if(x == 0 && y == 1)
- encounter();
- else if(x == 0 && y == -1)
- starterSwamp();
- else if(x == 1 && y == 0)
- turnBack();
- else if(x == -1 && y == 0)
- lockedShack();
- }while(!_stricmp(userCommand, "quit"));
- return 0;
- }
- void splashScreen()
- {
- cout << "================================================" << endl;
- cout << "== ________ ==" << endl;
- cout << "== | o __ o | Title ==" << endl;
- cout << "== \\_ __ _/ ==" << endl;
- cout << "== __ | | __ ==" << endl;
- cout << "== ************** ==" << endl;
- cout << "================================================" << endl;
- }
- void login()
- {
- string userName, userPass;
- cout << "Username: ";
- cin >> userName;
- cout << "Password: ";
- cin >> userPass;
- //check userName to username in file
- //check userPass to password in file
- }
- void command()
- {
- cout << ">> ";
- cin >> userCommand;
- }
- void startzone()
- {
- cout << "You are in the center of a foggy forest. There is a marshy \n"
- << "swamp to the South. To the East lies a thick line of bushes.\n"
- << "To the North through a winding path you catch a glimpse of a\n"
- << "cave with a shinng light coming out. To the West is a small\n"
- << "wooden shack, with a locked door. " << endl;
- }
- void starterSwamp()
- {
- cout << "You have ventured into the dangerous marshes. To the North lies \n"
- << "a forest clearing. To the east lies a beached row boat. To the \n"
- << "south the water gets deeper, out into a large lake. To the \n"
- << "west is a rock formation, but its hard to make out from here." << endl;
- }
- void lockedShack()
- {
- cout << "You approach the shack, only to find that there is a pad lock \n"
- << "on the door. Perhaps if you had the key?" << endl;
- }
- void turnBack()
- {
- cout << "This area is impassible. You have been forced to turn back. " << endl;
- }
- void movement()
- {
- if(_stricmp(userCommand, "walk north") == 1)
- {
- //moves character 1 place up grid
- x = x;
- y = y + 1;
- }
- else if(_stricmp(userCommand, "walk south") == 1)
- {
- //moves character 1 place down grid
- x = x;
- y = y - 1;
- }
- else if(_stricmp(userCommand, "walk east") == 1)
- {
- //moves character 1 place right of grid
- x = x + 1;
- y = y;
- }
- else if(_stricmp(userCommand, "walk west") == 1)
- {
- //moves character 1 place left of grid
- x = x - 1;
- y = y;
- }
- }
- void encounter()
- {
- srand(time(0));
- int num = rand() % 10 + 1;
- switch(num)
- {
- case 1:
- case 2:
- case 3:
- case 4:
- case 5:
- case 6:
- case 7:
- case 8:
- case 9:
- case 10:
- cout << "STOMP! A giant stone golem almost flattened you, luckily you halted an \n"
- << "inch short of his foot as it fell. He begins to raise his leg again \n"
- << "for another bash." << endl;
- command();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement