I'm trying to learn how to make a text adventure and this is the intro code to understand how the basic structure will work. It should work as I see it and the compiler is saying there's a multi-character issue on line 14 but I don't see how. Any help would be greatly appreciated.
#include <iostream>
#include <string>
using namespace std;
void start(char&choice,int&rm,int&orm,int&rnd,int&ply);
void room(int&rm,int&orm,int&rnd,int&ply);
int main()
{
char choice; // What commands you want to give
int rm = 11;
int orm = 11;
int rnd = 0;
int ply =0;
cout << "You're standing on the outskirt of a little town.\n";
cout << "Before you is the main street to the town.\n";
cout << "Behind you is a deep wood that you came from.\n";
cout << "To either side is more forest.\n\n";
while (ply==0)
{
start(choice,rm,orm,rnd,ply); //Room choosing segment
room(rm,orm,rnd,ply); //Segment to decide what is in each room
}
system("pause");
return 0;
}
void start(char&choice,int&rm,int&orm,int&rnd,int&ply)
{
cout << "What do you want to do?\n";
cout<<"n- Go North s- Go South\n";
cout<<"e- Go East w- Go West\n\n";
cin >> choice;
//int rooms[17]={11,12,13,14,15,16,17,18,2,3,4,5,22,23,24,25,27};
switch(choice)
{
case 'n':
case 'N':
rm+=1;
break;
case 's':
case 'S':
rm-=1;
break;
case 'w':
case 'W':
rm-=10;
break;
case 'e':
case 'E':
rm-=10;
break;
default:
cout<<"That is not a direction.....\n\n";
system("pause");
}
return;
}
void room (int&rm,int&orm,int&rnd,int&ply) //Text for various rooms
{
cout <<rm<<endl;
switch(rm)
{
case '12':
cout<<"Just one step into town brings pleasant smells of baked bread\n";
cout<<"and the sounds of children playing.\n";
cout<<"You feel a sense of peace and tranquility from the calmness around.\n";
cout<<"This is nothing like the bustle of the city.\n";
cout<<"you are on round "<<rnd<<".\n";
orm=rm;
rnd++;
break;
case '11':
cout << "You're standing on the outskirt of a little town.\n";
cout << "Before you is the main street to the town.\n";
cout << "Behind you is a deep wood that you came from.\n";
cout << "To either side is more forest.\n\n";
orm=rm;
rnd++;
break;
default: //check for invalid selections
cout<<"That is not a room...\n";
system("pause");
rm=orm;
ply=1;
}
return;
}
#include <iostream>
#include <string>
using namespace std;
void start(char&choice,int&rm,int&orm,int&rnd,int&ply);
void room(int&rm,int&orm,int&rnd,int&ply);
int main()
{
char choice; // What commands you want to give
int rm = 11;
int orm = 11;
int rnd = 0;
int ply =0;
cout << "You're standing on the outskirt of a little town.\n";
cout << "Before you is the main street to the town.\n";
cout << "Behind you is a deep wood that you came from.\n";
cout << "To either side is more forest.\n\n";
while (ply==0)
{
start(choice,rm,orm,rnd,ply); //Room choosing segment
room(rm,orm,rnd,ply); //Segment to decide what is in each room
}
system("pause");
return 0;
}
void start(char&choice,int&rm,int&orm,int&rnd,int&ply)
{
cout << "What do you want to do?\n";
cout<<"n- Go North s- Go South\n";
cout<<"e- Go East w- Go West\n\n";
cin >> choice;
//int rooms[17]={11,12,13,14,15,16,17,18,2,3,4,5,22,23,24,25,27};
switch(choice)
{
case 'n':
case 'N':
rm+=1;
break;
case 's':
case 'S':
rm-=1;
break;
case 'w':
case 'W':
rm-=10;
break;
case 'e':
case 'E':
rm-=10;
break;
default:
cout<<"That is not a direction.....\n\n";
system("pause");
}
return;
}
void room (int&rm,int&orm,int&rnd,int&ply) //Text for various rooms
{
cout <<rm<<endl;
switch(rm)
{
case '12':
cout<<"Just one step into town brings pleasant smells of baked bread\n";
cout<<"and the sounds of children playing.\n";
cout<<"You feel a sense of peace and tranquility from the calmness around.\n";
cout<<"This is nothing like the bustle of the city.\n";
cout<<"you are on round "<<rnd<<".\n";
orm=rm;
rnd++;
break;
case '11':
cout << "You're standing on the outskirt of a little town.\n";
cout << "Before you is the main street to the town.\n";
cout << "Behind you is a deep wood that you came from.\n";
cout << "To either side is more forest.\n\n";
orm=rm;
rnd++;
break;
default: //check for invalid selections
cout<<"That is not a room...\n";
system("pause");
rm=orm;
ply=1;
}
return;
}