What am I doing wrong?

Joined
Jul 14, 2011
Messages
2
Reaction score
0
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;
}
 
Joined
Jul 14, 2011
Messages
2
Reaction score
0
BTW

I prove in rooms that rm is 12 before the swtich but the switch defaults and the prog pauses twice and ends. The prior switch works fine so I don't know where I'm going wrong here.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,154
Members
46,702
Latest member
LukasConde

Latest Threads

Top