I'm not sure if this is a coding problem, as on my computer when you input the player name it is fine, but when my buddy does it he says it cuts off the first character he typed in. When he selects 'no' as a response to if his name is correct the next time around it cuts of the first two characters he types in.
// Runners of Remoria.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <string>
#include <sstream>
int userInput;
usingnamespace std;
bool running = 1;
void clearscreenFunc();
string heroname = ""; //GLOBAL HERO NAME
string herodrug=""; //Drug of choice
void namechoicefunc();
int playerchoice;
int fouropt();
void clearscreenFunc()
{
cout << string( 100, '\n');
return ;
}
int fouropt() //Whenever there is a choice where there are between 1 - 4 options, call this
{
int playerchoice = 0;
cout << "Choice: ";
cin >> playerchoice;
switch (playerchoice)
{
case 1:
return 1;
case 2:
return 2;
case 3:
return 3;
case 4:
return 4;
default:
cout << "Try again.\n";
fouropt;
}
}
void namechoicefunc() //handles hero entering name
{
clearscreenFunc();
//insert scoped int playerchoice=0 if global doesn't work
cout << "What name will the people know you by?\n";
cin.get();
cout << "Name: ";
getline(cin, heroname); //Cleaner way of getting input from player
cout << "Am I correct in hearing that your name is " << heroname << "?\n" << "1. Yes\n2. No\n";
playerchoice = fouropt();
switch (playerchoice)
{
case 1:
if(heroname == "")
{
cout << "Please speak up a little bit, I did not hear you.\n";
cin.get();
cin.get();
}
else
{
cout << "Good to know that my hearing hasn't all but gone.\n";
cin.get();
break;
}
case 2:
cout << "Are you certain? Let us try again then.\n";
cin.get();
cin.get();
namechoicefunc();
default:
cout << "Try again.";
cin.get();
cin.get();
namechoicefunc();
}
cout << "Nicely written speel about Drugs leading into a question such as:\n";
cout << "What was is your method of poison?\n";
cout << "1: Double U\n2: Jenkum\n3: Miercluf\n4: Minthe\n\n";
playerchoice = fouropt();
switch (playerchoice)
{
case 1:
cout << "Speel about Double U\n";
cin.get();
cout << "I can see this being your method of coping.\n";
herodrug = "Double U";
cin.get();
break;
case 2:
cout << "Speel about Jenkum\n";
cin.get();
cout << "Hehe, a butt huffer.\n";
cin.get();
herodrug = "Jenkum";
break;
case 3:
cout << "Speel about Miercluf.\n";
cin.get();
cout << "I can see this being your method of coping.\n";
cin.get();
herodrug = "Miercluf";
break;
case 4:
cout << "Speel about Minthe.\n";
cin.get();
cout << "I can see this being your method of coping.\n";
cin.get();
herodrug = "Minthe";
break;
}
clearscreenFunc();
cout << "\n\n\n\n\n\n\nName = " << heroname << "\t\t\t Favorite Drug = " << herodrug << endl;
cout << "Code for after The Name and Drug choice!";
cin.get();
cin.get();
return;
}
int titleFunc() //Function that handles the title screen
{
cout << "\t\t\t------RUNNERS OF REMORIA------\n\n"; //displays the title
cout << "\t\t\txxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n";
cout << "\t\t\txxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n";
cout << "\t\t\txxxxxxxxxx__________ xxxxxxxxxx\n";
cout << "\t\t\txxxxxxx\\__|________|__/xxxxxxxx\n";
cout << "\t\t\txxxxxxxxxx| _ _ |xxxxxxxxxxx\n";
cout << "\t\t\txxxxxxxxxx| . . |xxxxxxxxxxx\n";
cout << "\t\t\txxxxxxxxxxx\\ / -\\ /xxxxxxxxxxxx\n";
cout << "\t\t\txxxxxxxxxxxx-------xxxxxxxxxxxx\n";
cout << "\t\t\txxxxxxxxxxx/| |\\xxxxxxxxxx\n";
cout << "\t\t\txxxxxxxxxxx|| ||xxxxxxxxxxx\n";
cout << "\t\t\txxxxxxxxxxx|| ||xxxxxxxxxxx\n";
cout << "\t\t\txxxxxxxxxxx\\|--&--|/xxxxxxxxxxx\n";
cout << "\t\t\txxxxxxxxxxxx| v |xxxxxxxxxxxx\n";
cout << "\t\t\t. . . | | | . . . \n";
cout << "\t\t\t . . .| | | \n";
cout << "\t\t\t . |--|--| . . .\n";
cout << "\t\t\t. . . MM MM . . \n";
cout << "\t\t\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
cout << "\n\t\t\t\t 1:Play\n";
cout << "\t\t\t\t 2:Exit\n\n\n\n"; //displays the options
cout << "Choice: ";
cin >> userInput;
if(userInput == 1)
{
clearscreenFunc();
cout << "Children are tucked into bed with candlelit stories of heroes present and past.\n";
cin.get();
cin.get();
cout << "Roaring campfires most always cackle with the deeds of brave men,\n";
cout << "triumphs over adversaries, and glory to the high king and to this\n";
cout << "land of which he reigns sovereign.\n";
cin.get();
cout << "The selfless hero shall always overcome\n";
cout << "all obstacles and bring victory to his people.\n";
cin.get();
clearscreenFunc();
cout << "Remorian tales make no such mentioning of these heroic acts or deeds.\n";
cin.get();
cout << "The story of Remoria more often than not is filled with greed and grey lines.\n";
cin.get();
clearscreenFunc();
cout << "\nYou are Remorian. Let your path run true. \n"; //Take it to _newgamefunc
cin.get();
cout << "Before a story is told, your name must be known.\n";
cin.get();
namechoicefunc(); //FUNCTION
running = 0;
}
elseif(userInput == 2)
{
clearscreenFunc();
cout << "Good day, young runner.";
cin.get();
cin.get();
running = 0;
}
elseif(userInput != 1 || 2)
{
clearscreenFunc();
cout << "Perhaps you did not understand your options.\n";
cin.get();
cin.get();
cout << "Perhaps you are not yet ready to run.";
cin.get();
running = 1;
}
return 0;
} //Takes care of main title duties
int main()
{
//titleFunc(); Also a possibility
while(running)
{
titleFunc(); //Will continue the title loop while running boolean == true
}
return 0;
}
I'm like a week into programming so I'm a baby and I could use some help with this, and anything else messed up with my code.
Is there one I should prefer over the other? That still doesn't explain why it would show up on my computer and clip on his computer though, although I understand what you just said.