GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 27-Nov-2006, 14:04
thrash423 thrash423 is offline
New Member
 
Join Date: Nov 2006
Posts: 19
thrash423 is on a distinguished road

help with counter in a game. please check out!


ok guys im workin on phase 2 of my project zork game, and im really not sure about how im supposed to move from room to room, i have the description all setup and i have all the directions in the room down, that was the really bulky part, but i dont know how to use a counter to move from room to room, any help would be greatly appreciated.. Thanks!!

CPP / C++ / C Code:
/*
Programmer Name: Colby Collier
Date Started: 11/18/06
Date Completed: 11/28/06
Compile command: g++ -o newgame newgame.cpp
*/


#include <iostream>
#include <string>

using namespace std;

void UserInput(string &out);

struct Room
{
     string Description;  //room description
     char North;          //directions in room
     char South;
     char East;
     char West;
     char Up;
     char Down;
};

void CreateWorld(Room&); //proto type

int main()
{
string max;
UserInput(max);

int total[10][13]; //10 rows 13 columns
Room MyRoom[10][13];


MyRoom[5][3].Description="You are in an open field west of a big white house with a boarded front door. There is a small mailbox here.";
cout<<MyRoom[5][3].Description<<endl;
MyRoom[5][3].North='y';
MyRoom[5][3].South='y';
MyRoom[5][3].East='n';
MyRoom[5][3].West='y';
MyRoom[5][3].Up='n';
MyRoom[5][3].Down='n';

MyRoom[3][5].Description="You are facing the north side of a white house. There is no door here and all the windows are barred.";
cout<<MyRoom[3][5].Description<<endl;
MyRoom[3][5].North='y';
MyRoom[3][5].South='n';
MyRoom[3][5].East='y';
MyRoom[3][5].West='y';
MyRoom[3][5].Up='n';
MyRoom[3][5].Down='n';

MyRoom[2][5].Description="You are in a dimly lit forest, with large rees all around. One particularly large tree with some low branches stands here";
cout<<MyRoom[2][5].Description<<endl;
MyRoom[2][5].North='y';
MyRoom[2][5].South='y';
MyRoom[2][5].East='y';
MyRoom[2][5].West='y';
MyRoom[2][5].Up='y';
MyRoom[2][5].Down='n';

MyRoom[1][6].Description="You are ten feet above ground nestled among some large branches. The nearest branch above you is beyond your reach. On the branch is a small birds nest. The birds nest contains : A jewel encrusted egg.";
cout<<MyRoom[1][6].Description<<endl;
MyRoom[1][6].North='n';
MyRoom[1][6].South='n';
MyRoom[1][6].East='n';
MyRoom[1][6].West='n';
MyRoom[1][6].Up='n';
MyRoom[1][6].Down='y';

MyRoom[0][4].Description="You are in a dimly lit forest, with trees all around. To the east there appears to be sunlight";
cout<<MyRoom[0][4].Description<<endl;
MyRoom[0][4].North='n';
MyRoom[0][4].South='y';
MyRoom[0][4].East='y';
MyRoom[0][4].West='y';
MyRoom[0][4].Up='n';
MyRoom[0][4].Down='y';

MyRoom[5][1].Description="You are in a forest, with trees all around you.";
cout<<MyRoom[5][1].Description<<endl;
MyRoom[5][1].North='y';
MyRoom[5][1].South='n';
MyRoom[5][1].East='y';
MyRoom[5][1].West='y';
MyRoom[5][1].Up='n';
MyRoom[5][1].Down='n';

MyRoom[8][7].Description="You are in a dimly lit forest, with trees all around. To the east there appears to be sunlight";
cout<<MyRoom[8][7].Description<<endl;
MyRoom[8][7].North='y';
MyRoom[8][7].South='n';
MyRoom[8][7].East='y';
MyRoom[8][7].West='y';
MyRoom[8][7].Up='n';
MyRoom[8][7].Down='n';

MyRoom[5][8].Description="You are in a clearing, with a forest surrounding you on the west and south. There is a pile of leaves on the ground";
cout<<MyRoom[5][8].Description<<endl;
MyRoom[5][8].North='y';
MyRoom[5][8].South='y';
MyRoom[5][8].East='y';
MyRoom[5][8].West='y';
MyRoom[5][8].Up='n';
MyRoom[5][8].Down='n';

MyRoom[2][8].Description="You are in a clearing, with a forest surrounding you on the west and south. There is a pile of leaves on the ground";
cout<<MyRoom[2][8].Description<<endl;
MyRoom[2][8].North='y';
MyRoom[2][8].South='y';
MyRoom[2][8].East='y';
MyRoom[2][8].West='y';
MyRoom[2][8].Up='n';
MyRoom[2][8].Down='n';

MyRoom[2][10].Description="You are in a forest that is thinning out.";
cout<<MyRoom[2][10].Description<<endl;
MyRoom[2][10].North='y';
MyRoom[2][10].South='y';
MyRoom[2][10].East='n';
MyRoom[2][10].West='y';
MyRoom[2][10].Up='n';
MyRoom[2][10].Down='n';

MyRoom[1][4].Description="You are in the grating room";
cout<<MyRoom[1][4].Description<<endl;
MyRoom[1][4].North='n';
MyRoom[1][4].South='n';
MyRoom[1][4].East='n';
MyRoom[1][4].West='n';
MyRoom[1][4].Up='y';
MyRoom[1][4].Down='n';

MyRoom[5][7].Description="You are behind the white house. In one corner of the house there is a window that is slightly ajar";
cout<<MyRoom[5][7].Description<<endl;
MyRoom[5][7].North='y';
MyRoom[5][7].South='y';
MyRoom[5][7].East='y';
MyRoom[5][7].West='y';
MyRoom[5][7].Up='n';
MyRoom[5][7].Down='n';

MyRoom[5][6].Description="You are in the kitchen of the white house. A table seems to have been used recently for the preperation of food. A passage leads to the west, and a dark stairase can be seen leading upward. To the east there is a small window which is open. On the table is an elongated brown sack, smelling of hot peppers. A clear glass bottle is here. The glass bottle contains: A quantity of water";
cout<<MyRoom[5][6].Description<<endl;
MyRoom[5][6].North='n';
MyRoom[5][6].South='n';
MyRoom[5][6].East='y';
MyRoom[5][6].West='y';
MyRoom[5][6].Up='y';
MyRoom[5][6].Down='y';

MyRoom[4][6].Description="It is pitch dark. You are likely to be eaten by a gruel.";
cout<<MyRoom[4][6].Description<<endl;
MyRoom[4][6].North='n';
MyRoom[4][6].South='n';
MyRoom[4][6].East='n';
MyRoom[4][6].West='n';
MyRoom[4][6].Up='n';
MyRoom[4][6].Down='y';

MyRoom[5][4].Description="You are in the living room. There is a door to the east. To the west is a wooden door with strange gothic lettering, which appears to be nailed shut. In the center of the room is a large oriental rug. There is a trophy case here, On hooks above the mantlepiece hangs an elvish sword of great antiquity. A battery-powered brass lantern is on the trophy case. There is an issue of US NEWS & DUNGEON REPORT dated 11-Mar-91 here.";
cout<<MyRoom[5][4].Description<<endl;
MyRoom[5][4].North='n';
MyRoom[5][4].South='n';
MyRoom[5][4].East='y';
MyRoom[5][4].West='n';
MyRoom[5][4].Up='n';
MyRoom[5][4].Down='y';

MyRoom[6][4].Description="You are in the cellar";
cout<<MyRoom[6][4].Description<<endl;
MyRoom[6][4].North='n';
MyRoom[6][4].South='n';
MyRoom[6][4].East='n';
MyRoom[6][4].West='n';
MyRoom[6][4].Up='y';
MyRoom[6][4].Down='n';

MyRoom[7][5].Description="You are facing the south side of a white house. There is no door here, and all the windows are barred";
cout<<MyRoom[7][5].Description<<endl;
MyRoom[7][5].North='n';
MyRoom[7][5].South='y';
MyRoom[7][5].East='y';
MyRoom[7][5].West='y';
MyRoom[7][5].Up='n';
MyRoom[7][5].Down='n';

MyRoom[5][10].Description="You are at the top of the great canyon on its south wall. From here there is a marvelous view of the canyon and parts of the frigid River upstream. Across the canyon, the the walls of the white cliffs still appear to loom far above. Following the canyon upstream (north and northwest), Aragain falls may be seen, complete with rainbow. Fortunately, my vision is better than average, and i can discern the top of the flood control dam #3 far to the distant north. To the west and south can be seen an immense forest, stretching for miles around. It is possible to climb down into the canyon from here.";
cout<<MyRoom[5][10].Description<<endl;
MyRoom[5][10].North='y';
MyRoom[5][10].South='n';
MyRoom[5][10].East='y';
MyRoom[5][10].West='y';
MyRoom[5][10].Up='n';
MyRoom[5][10].Down='n';

MyRoom[7][9].Description="You are on a ledge about half way up the wall of the river canyon. You can see from here that the main flow from Aragain falls twists along a passage which it is impossible to enter. Below you is the canyone bottom. Above you is more cliff, which still appears climbable.";
cout<<MyRoom[7][9].Description<<endl;
MyRoom[7][9].North='n';
MyRoom[7][9].South='n';
MyRoom[7][9].East='n';
MyRoom[7][9].West='n';
MyRoom[7][9].Up='y';
MyRoom[7][9].Down='n';

MyRoom[9][9].Description="You are beneath the walls of the river canyon, which may be climbable here. There is a small stream here, which is the lesser part of the runoff of Aragain falls. To the north is a narrow path.";
cout<<MyRoom[9][9].Description<<endl;
MyRoom[9][9].North='y';
MyRoom[9][9].South='n';
MyRoom[9][9].East='n';
MyRoom[9][9].West='n';
MyRoom[9][9].Up='y';
MyRoom[9][9].Down='n';

MyRoom[8][10].Description="You are on a small beach on the continuation of the Frigid River past the falls. The beach is narrow due to the presence of the white cliffs. The river canyon opens here, and sunlight shines in from above. A rainbow crosses over the falls to the west, and a narrow path continues to the southeast.";
cout<<MyRoom[8][10].Description<<endl;
MyRoom[8][10].North='n';
MyRoom[8][10].South='y';
MyRoom[8][10].East='y';
MyRoom[8][10].West='n';
MyRoom[8][10].Up='n';
MyRoom[8][10].Down='n';

MyRoom[8][11].Description="You are on the rainbow";
cout<<MyRoom[8][11].Description<<endl;
MyRoom[8][11].North='n';
MyRoom[8][11].South='n';
MyRoom[8][11].East='y';
MyRoom[8][11].West='y';
MyRoom[8][11].Up='n';
MyRoom[8][11].Down='n';

MyRoom[8][12].Description="You are at Aragain Falls";
cout<<MyRoom[8][12].Description<<endl;
MyRoom[8][12].North='n';
MyRoom[8][12].South='n';
MyRoom[8][12].East='n';
MyRoom[8][12].West='y';
MyRoom[8][12].Up='n';
MyRoom[8][12].Down='n';

MyRoom[6][2].Description="You are at the stone barrow";
cout<<MyRoom[6][2].Description<<endl;
MyRoom[6][2].North='y';
MyRoom[6][2].South='n';
MyRoom[6][2].East='n';
MyRoom[6][2].West='y';
MyRoom[6][2].Up='n';
MyRoom[6][2].Down='n';

MyRoom[7][2].Description="You are inside the barrow";
cout<<MyRoom[7][2].Description<<endl;
MyRoom[7][2].North='n';
MyRoom[7][2].South='n';
MyRoom[7][2].East='n';
MyRoom[7][2].West='y';
MyRoom[7][2].Up='n';
MyRoom[7][2].Down='n';

MyRoom[8][1].Description="You are at the altar";
cout<<MyRoom[8][1].Description<<endl;
MyRoom[8][1].North='y';
MyRoom[8][1].South='n';
MyRoom[8][1].East='n';
MyRoom[8][1].West='n';
MyRoom[8][1].Up='n';
MyRoom[8][1].Down='n';

MyRoom[6][6].Description="You are in the studio";
cout<<MyRoom[6][6].Description<<endl;
MyRoom[6][6].North='n';
MyRoom[6][6].South='n';
MyRoom[6][6].East='n';
MyRoom[6][6].West='n';
MyRoom[6][6].Up='y';
MyRoom[6][6].Down='n';


MyRoom[0][0].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[0][1].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[0][2].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[0][3].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[0][6].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[0][5].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[0][7].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[0][8].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[0][9].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[0][10].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[0][11].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[0][12].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[1][1].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[1][2].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[1][3].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[1][5].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[1][7].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[1][8].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[1][9].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[1][10].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[1][11].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[1][12].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[2][1].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[2][2].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[2][3].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[2][4].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[2][6].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[2][7].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[2][12].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[2][9].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[2][11].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[3][1].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[3][2].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[3][3].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[3][5].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[3][6].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[3][7].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[3][8].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[3][9].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[3][10].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[3][11].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[3][12].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[4][1].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[4][2].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[4][3].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[4][4].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[4][5].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[4][7].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[4][8].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[4][9].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[4][10].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[4][11].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[4][12].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[5][2].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[5][5].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[5][9].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[5][11].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[5][12].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[6][1].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[6][2].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[6][3].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[6][5].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[6][7].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[6][8].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[6][9].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[6][10].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[6][11].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[6][12].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[7][1].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[7][3].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[7][4].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[7][6].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[7][7].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[7][8].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[7][10].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[7][11].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[7][12].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[8][2].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[8][3].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[8][4].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[8][5].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[8][6].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[8][8].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[8][9].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[9][1].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[9][2].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[9][3].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[9][4].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[9][5].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[9][6].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[9][7].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[9][9].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[9][10].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[9][11].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;
MyRoom[9][12].Description="Empty";
cout<<MyRoom[0][0].Description<<endl;

return(0);

}                      //Closes main



void UserInput(string &max)
{

char input[80];
char newstring[4][80];
int wordCount = 0;
int NewWordCounter = 0;
int NumberOfWords = 0;



for(int rowCount = 0; rowCount < 5; rowCount++)
{
    for(int ColCount = 0; ColCount < 81; ColCount++)
            newstring[rowCount][ColCount]='X';

}

cout<<"> ";
cin.getline(input, 80);


// This for loop takes a two-dimensional array of characters and parses it into tokens

for(int x = 0; x < 80; x++) // 80 possible characters on a line
{
    newstring[wordCount][NewWordCounter]=input[x];  // newstring[0][0] to the first character
    if(input[x] == ' ')
    {
            NumberOfWords++;
            newstring[wordCount][NewWordCounter]='\0';  // we have to enter the string terminator
            wordCount++; // since I hit a space - I must be onto a new word
            NewWordCounter = -1;  // This is used for the row of my newstring 2D array
    }
    NewWordCounter++;

    if(input[x]=='\0')
            break;  // Why keep going if I have reached the last character -- let's break
}

cout<<"There are "<<NumberOfWords + 1<<" words in the string.  They are: "<<endl;

for (int counter = 0; counter < NumberOfWords + 1; counter++)
{       if(counter == 0)
{       cout<<"<<verb>>";
}

     else if (counter == 1)
{
     cout<<"<<noun>>";
}
     else if (counter == 2)
{
     cout<<"<<adverb>>";
}
     else if (counter == 3)
{
     cout<<"<<noun>>";
}
    cout<<newstring[counter]<<endl;
}

}//closes if


  #2  
Old 27-Nov-2006, 18:01
thrash423 thrash423 is offline
New Member
 
Join Date: Nov 2006
Posts: 19
thrash423 is on a distinguished road

Re: help with counter in a game. please check out!


anyone have any ideas i have to turn this thing in tommorrow
  #3  
Old 28-Nov-2006, 06:39
thrash423 thrash423 is offline
New Member
 
Join Date: Nov 2006
Posts: 19
thrash423 is on a distinguished road

Re: help with counter in a game. please check out!


just so everyone understands what im trying to do here in the zork game you have to be able to successfully move from room to room like if you are in the first room [5][3] and you can go north from there, you can be able to do it. im just not sure how to code that part.
  #4  
Old 28-Nov-2006, 23:50
thrash423 thrash423 is offline
New Member
 
Join Date: Nov 2006
Posts: 19
thrash423 is on a distinguished road

Re: help with counter in a game. please check out!


ok guys i have redone a little chunk of the code, now i need to figure out how to be able to start in room [5][3] (first room that is in the description) and i need to be able to cout the description of each room when i enter it. im really not sure how to even start doing this, so any help would be greatly appreciated. again im not allowed to use vector, simply because we havent covered that in class yet.

CPP / C++ / C Code:
/*
Programmer Name: Colby Collier
Date Started: 11/18/06
Date Completed: 11/28/06
Compile command: g++ -o newgame newgame.cpp
*/


#include <iostream>
#include <string>

using namespace std;

void UserInput(string &out);

struct Room
{
     string Description;  //room description
     char North;          //directions in room
     char South;
     char East;
     char West;
     char Up;
     char Down;
};

void CreateWorld(Room&); //proto type

int main()
{
string max;
UserInput(max);

int total[10][13]; //10 rows 13 columns
Room MyRoom[10][13];


MyRoom[5][3].Description="You are in an open field west of a big white house with a boarded front door. There is a small mailbox here.";
MyRoom[5][3].North='y';
MyRoom[5][3].South='y';
MyRoom[5][3].East='n';
MyRoom[5][3].West='y';
MyRoom[5][3].Up='n';
MyRoom[5][3].Down='n';

MyRoom[3][5].Description="You are facing the north side of a white house. There is no door here and all the windows are barred.";
MyRoom[3][5].North='y';
MyRoom[3][5].South='n';
MyRoom[3][5].East='y';
MyRoom[3][5].West='y';
MyRoom[3][5].Up='n';
MyRoom[3][5].Down='n';

MyRoom[2][5].Description="You are in a dimly lit forest, with large rees all around. One particularly large tree with some low branches stands here";
MyRoom[2][5].North='y';
MyRoom[2][5].South='y';
MyRoom[2][5].East='y';
MyRoom[2][5].West='y';
MyRoom[2][5].Up='y';
MyRoom[2][5].Down='n';

MyRoom[1][6].Description="You are ten feet above ground nestled among some large branches. The nearest branch above you is beyond your reach. On the branch is a small birds nest. The birds nest contains : A jewel encrusted egg.";
MyRoom[1][6].North='n';
MyRoom[1][6].South='n';
MyRoom[1][6].East='n';
MyRoom[1][6].West='n';
MyRoom[1][6].Up='n';
MyRoom[1][6].Down='y';

MyRoom[0][4].Description="You are in a dimly lit forest, with trees all around. To the east there appears to be sunlight";
MyRoom[0][4].North='n';
MyRoom[0][4].South='y';
MyRoom[0][4].East='y';
MyRoom[0][4].West='y';
MyRoom[0][4].Up='n';
MyRoom[0][4].Down='y';

MyRoom[5][1].Description="You are in a forest, with trees all around you.";
MyRoom[5][1].North='y';
MyRoom[5][1].South='n';
MyRoom[5][1].East='y';
MyRoom[5][1].West='y';
MyRoom[5][1].Up='n';
MyRoom[5][1].Down='n';

MyRoom[8][7].Description="You are in a dimly lit forest, with trees all around. To the east there appears to be sunlight";
MyRoom[8][7].North='y';
MyRoom[8][7].South='n';
MyRoom[8][7].East='y';
MyRoom[8][7].West='y';
MyRoom[8][7].Up='n';
MyRoom[8][7].Down='n';

MyRoom[5][8].Description="You are in a clearing, with a forest surrounding you on the west and south. There is a pile of leaves on the ground";
MyRoom[5][8].North='y';
MyRoom[5][8].South='y';
MyRoom[5][8].East='y';
MyRoom[5][8].West='y';
MyRoom[5][8].Up='n';
MyRoom[5][8].Down='n';

MyRoom[2][8].Description="You are in a clearing, with a forest surrounding you on the west and south. There is a pile of leaves on the ground";
MyRoom[2][8].North='y';
MyRoom[2][8].South='y';
MyRoom[2][8].East='y';
MyRoom[2][8].West='y';
MyRoom[2][8].Up='n';
MyRoom[2][8].Down='n';

MyRoom[2][10].Description="You are in a forest that is thinning out.";
MyRoom[2][10].North='y';
MyRoom[2][10].South='y';
MyRoom[2][10].East='n';
MyRoom[2][10].West='y';
MyRoom[2][10].Up='n';
MyRoom[2][10].Down='n';

MyRoom[1][4].Description="You are in the grating room";
MyRoom[1][4].North='n';
MyRoom[1][4].South='n';
MyRoom[1][4].East='n';
MyRoom[1][4].West='n';
MyRoom[1][4].Up='y';
MyRoom[1][4].Down='n';

MyRoom[5][7].Description="You are behind the white house. In one corner of the house there is a window that is slightly ajar";
MyRoom[5][7].North='y';
MyRoom[5][7].South='y';
MyRoom[5][7].East='y';
MyRoom[5][7].West='y';
MyRoom[5][7].Up='n';
MyRoom[5][7].Down='n';

MyRoom[5][6].Description="You are in the kitchen of the white house. A table seems to have been used recently for the preperation of food. A passage leads to the west, and a dark stairase can be seen leading upward. To the east there is a small window which is open. On the table is an elongated brown sack, smelling of hot peppers. A clear glass bottle is here. The glass bottle contains: A quantity of water";
MyRoom[5][6].North='n';
MyRoom[5][6].South='n';
MyRoom[5][6].East='y';
MyRoom[5][6].West='y';
MyRoom[5][6].Up='y';
MyRoom[5][6].Down='y';

MyRoom[4][6].Description="It is pitch dark. You are likely to be eaten by a gruel.";
MyRoom[4][6].North='n';
MyRoom[4][6].South='n';
MyRoom[4][6].East='n';
MyRoom[4][6].West='n';
MyRoom[4][6].Up='n';
MyRoom[4][6].Down='y';

MyRoom[5][4].Description="You are in the living room. There is a door to the east. To the west is a wooden door with strange gothic lettering, which appears to be nailed shut. In the center of the room is a large oriental rug. There is a trophy case here, On hooks above the mantlepiece hangs an elvish sword of great antiquity. A battery-powered brass lantern is on the trophy case. There is an issue of US NEWS & DUNGEON REPORT dated 11-Mar-91 here.";
MyRoom[5][4].North='n';
MyRoom[5][4].South='n';
MyRoom[5][4].East='y';
MyRoom[5][4].West='n';
MyRoom[5][4].Up='n';
MyRoom[5][4].Down='y';

MyRoom[6][4].Description="You are in the cellar";
MyRoom[6][4].North='n';
MyRoom[6][4].South='n';
MyRoom[6][4].East='n';
MyRoom[6][4].West='n';
MyRoom[6][4].Up='y';
MyRoom[6][4].Down='n';

MyRoom[7][5].Description="You are facing the south side of a white house. There is no door here, and all the windows are barred";
MyRoom[7][5].North='n';
MyRoom[7][5].South='y';
MyRoom[7][5].East='y';
MyRoom[7][5].West='y';
MyRoom[7][5].Up='n';
MyRoom[7][5].Down='n';

MyRoom[5][10].Description="You are at the top of the great canyon on its south wall. From here there is a marvelous view of the canyon and parts of the frigid River upstream. Across the canyon, the the walls of the white cliffs still appear to loom far above. Following the canyon upstream (north and northwest), Aragain falls may be seen, complete with rainbow. Fortunately, my vision is better than average, and i can discern the top of the flood control dam #3 far to the distant north. To the west and south can be seen an immense forest, stretching for miles around. It is possible to climb down into the canyon from here.";
MyRoom[5][10].North='y';
MyRoom[5][10].South='n';
MyRoom[5][10].East='y';
MyRoom[5][10].West='y';
MyRoom[5][10].Up='n';
MyRoom[5][10].Down='n';

MyRoom[7][9].Description="You are on a ledge about half way up the wall of the river canyon. You can see from here that the main flow from Aragain falls twists along a passage which it is impossible to enter. Below you is the canyone bottom. Above you is more cliff, which still appears climbable.";
MyRoom[7][9].North='n';
MyRoom[7][9].South='n';
MyRoom[7][9].East='n';
MyRoom[7][9].West='n';
MyRoom[7][9].Up='y';
MyRoom[7][9].Down='n';

MyRoom[9][9].Description="You are beneath the walls of the river canyon, which may be climbable here. There is a small stream here, which is the lesser part of the runoff of Aragain falls. To the north is a narrow path.";
MyRoom[9][9].North='y';
MyRoom[9][9].South='n';
MyRoom[9][9].East='n';
MyRoom[9][9].West='n';
MyRoom[9][9].Up='y';
MyRoom[9][9].Down='n';

MyRoom[8][10].Description="You are on a small beach on the continuation of the Frigid River past the falls. The beach is narrow due to the presence of the white cliffs. The river canyon opens here, and sunlight shines in from above. A rainbow crosses over the falls to the west, and a narrow path continues to the southeast.";
MyRoom[8][10].North='n';
MyRoom[8][10].South='y';
MyRoom[8][10].East='y';
MyRoom[8][10].West='n';
MyRoom[8][10].Up='n';
MyRoom[8][10].Down='n';

MyRoom[8][11].Description="You are on the rainbow";
MyRoom[8][11].North='n';
MyRoom[8][11].South='n';
MyRoom[8][11].East='y';
MyRoom[8][11].West='y';
MyRoom[8][11].Up='n';
MyRoom[8][11].Down='n';

MyRoom[8][12].Description="You are at Aragain Falls";
MyRoom[8][12].North='n';
MyRoom[8][12].South='n';
MyRoom[8][12].East='n';
MyRoom[8][12].West='y';
MyRoom[8][12].Up='n';
MyRoom[8][12].Down='n';

MyRoom[6][2].Description="You are at the stone barrow";
MyRoom[6][2].North='y';
MyRoom[6][2].South='n';
MyRoom[6][2].East='n';
MyRoom[6][2].West='y';
MyRoom[6][2].Up='n';
MyRoom[6][2].Down='n';

MyRoom[7][2].Description="You are inside the barrow";
MyRoom[7][2].North='n';
MyRoom[7][2].South='n';
MyRoom[7][2].East='n';
MyRoom[7][2].West='y';
MyRoom[7][2].Up='n';
MyRoom[7][2].Down='n';

MyRoom[8][1].Description="You are at the altar";
MyRoom[8][1].North='y';
MyRoom[8][1].South='n';
MyRoom[8][1].East='n';
MyRoom[8][1].West='n';
MyRoom[8][1].Up='n';
MyRoom[8][1].Down='n';

MyRoom[6][6].Description="You are in the studio";
MyRoom[6][6].North='n';
MyRoom[6][6].South='n';
MyRoom[6][6].East='n';
MyRoom[6][6].West='n';
MyRoom[6][6].Up='y';
MyRoom[6][6].Down='n';


MyRoom[0][0].Description="Empty";
MyRoom[0][1].Description="Empty";
MyRoom[0][2].Description="Empty";
MyRoom[0][3].Description="Empty";
MyRoom[0][6].Description="Empty";
MyRoom[0][5].Description="Empty";
MyRoom[0][7].Description="Empty";
MyRoom[0][8].Description="Empty";
MyRoom[0][9].Description="Empty";
MyRoom[0][10].Description="Empty";
MyRoom[0][11].Description="Empty";
MyRoom[0][12].Description="Empty";
MyRoom[1][1].Description="Empty";
MyRoom[1][2].Description="Empty";
MyRoom[1][3].Description="Empty";
MyRoom[1][5].Description="Empty";
MyRoom[1][7].Description="Empty";
MyRoom[1][8].Description="Empty";
MyRoom[1][9].Description="Empty";
MyRoom[1][10].Description="Empty";
MyRoom[1][11].Description="Empty";
MyRoom[1][12].Description="Empty";
MyRoom[2][1].Description="Empty";
MyRoom[2][2].Description="Empty";
MyRoom[2][3].Description="Empty";
MyRoom[2][4].Description="Empty";
MyRoom[2][6].Description="Empty";
MyRoom[2][7].Description="Empty";
MyRoom[2][12].Description="Empty";
MyRoom[2][9].Description="Empty";
MyRoom[2][11].Description="Empty";
MyRoom[3][1].Description="Empty";
MyRoom[3][2].Description="Empty";
MyRoom[3][3].Description="Empty";
MyRoom[3][5].Description="Empty";
MyRoom[3][6].Description="Empty";
MyRoom[3][7].Description="Empty";
MyRoom[3][8].Description="Empty";
MyRoom[3][9].Description="Empty";
MyRoom[3][10].Description="Empty";
MyRoom[3][11].Description="Empty";
MyRoom[3][12].Description="Empty";
MyRoom[4][1].Description="Empty";
MyRoom[4][2].Description="Empty";
MyRoom[4][3].Description="Empty";
MyRoom[4][4].Description="Empty";
MyRoom[4][5].Description="Empty";
MyRoom[4][7].Description="Empty";
MyRoom[4][8].Description="Empty";
MyRoom[4][9].Description="Empty";
MyRoom[4][10].Description="Empty";
MyRoom[4][11].Description="Empty";
MyRoom[4][12].Description="Empty";
MyRoom[5][2].Description="Empty";
MyRoom[5][5].Description="Empty";
MyRoom[5][9].Description="Empty";
MyRoom[5][11].Description="Empty";
MyRoom[5][12].Description="Empty";
MyRoom[6][1].Description="Empty";
MyRoom[6][2].Description="Empty";
MyRoom[6][3].Description="Empty";
MyRoom[6][5].Description="Empty";
MyRoom[6][7].Description="Empty";
MyRoom[6][8].Description="Empty";
MyRoom[6][9].Description="Empty";
MyRoom[6][10].Description="Empty";
MyRoom[6][11].Description="Empty";
MyRoom[6][12].Description="Empty";
MyRoom[7][1].Description="Empty";
MyRoom[7][3].Description="Empty";
MyRoom[7][4].Description="Empty";
MyRoom[7][6].Description="Empty";
MyRoom[7][7].Description="Empty";
MyRoom[7][8].Description="Empty";
MyRoom[7][10].Description="Empty";
MyRoom[7][11].Description="Empty";
MyRoom[7][12].Description="Empty";
MyRoom[8][2].Description="Empty";
MyRoom[8][3].Description="Empty";
MyRoom[8][4].Description="Empty";
MyRoom[8][5].Description="Empty";
MyRoom[8][6].Description="Empty";
MyRoom[8][8].Description="Empty";
MyRoom[8][9].Description="Empty";
MyRoom[9][1].Description="Empty";
MyRoom[9][2].Description="Empty";
MyRoom[9][3].Description="Empty";
MyRoom[9][4].Description="Empty";
MyRoom[9][5].Description="Empty";
MyRoom[9][6].Description="Empty";
MyRoom[9][7].Description="Empty";
MyRoom[9][9].Description="Empty";
MyRoom[9][10].Description="Empty";
MyRoom[9][11].Description="Empty";
MyRoom[9][12].Description="Empty";
return(0);

}                      //Closes main



void UserInput(string &max)
{

char input[80];
char newstring[4][80];
int wordCount = 0;
int NewWordCounter = 0;
int NumberOfWords = 0;



for(int rowCount = 0; rowCount < 5; rowCount++)
{
    for(int ColCount = 0; ColCount < 81; ColCount++)
            newstring[rowCount][ColCount]='X';

}

cout<<"> ";
cin.getline(input, 80);


// This for loop takes a two-dimensional array of characters and parses it into tokens

for(int x = 0; x < 80; x++) // 80 possible characters on a line
{
    newstring[wordCount][NewWordCounter]=input[x];  // newstring[0][0] to the first character
    if(input[x] == ' ')
    {
            NumberOfWords++;
            newstring[wordCount][NewWordCounter]='\0';  // we have to enter the string terminator
            wordCount++; // since I hit a space - I must be onto a new word
            NewWordCounter = -1;  // This is used for the row of my newstring 2D array
    }
    NewWordCounter++;

    if(input[x]=='\0')
            break;  // Why keep going if I have reached the last character -- let's break
}


for (int counter = 0; counter < NumberOfWords + 1; counter++)
{       if(counter == 0)
{       cout<<"<<verb>>";
}

     else if (counter == 1)
{
     cout<<"<<noun>>";
}
     else if (counter == 2)
{
     cout<<"<<adverb>>";
}
     else if (counter == 3)
{
     cout<<"<<noun>>";
}
    cout<<newstring[counter]<<endl;
}

}//closes if
 
 

Recent GIDBlogProblems with the Navy (Officers) by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Computer Game Design HELP NEEDED! dcallito C++ Forum 3 01-Jun-2007 12:29
Need help understand function prototypes! Blstretch C++ Forum 20 25-Oct-2005 14:14
Tips for game troubleshooting pcxgamer Computer Software Forum - Games 0 02-Jan-2004 05:27

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 14:41.


vBulletin, Copyright © 2000 - 2010, Jelsoft Enterprises Ltd.