Archived

This topic is now archived and is closed to further replies.

vish40

simple text maze game

Recommended Posts

I have a programming project that i need help on. I have to create a text maze game using function calling. Following the code that I have written so far: The problem is that I dont know how to connect the room together using function. can any one please help me with this. Thank You CODE: #include <iostream> using namespace std; float room1(int answer); float room2(int answer); float room3(int answer); float room4(int answer); float room5(int answer); float room6(int answer); float room7(int answer); float room8(int answer); int main(void) { char answer; int treasure = 0; cout <<"You have Enter the Maze.\n" <<"You are in the first room.\n" <<"There are 3 exits: West, East, and South.\n" <<"Have Fun " <> answer; if(answer == ''W'') { cout << room5(answer); } if(answer == ''S'') { cout << room2(answer); } if(answer == ''E'') { cout << room1(answer); } return 0; } float room1(int answer) { cout <<"You have enter the first room of the maze!!!" << endl; cout <<"There are 2 exits in this room: West and South." <

Share this post


Link to post
Share on other sites
u are doing it all wrong...
You will never finish it that way!

create a map.

eg

struct MapInfo {
int eastConnection
int westConnection
int northConnection
int southConnection
};

MapInfo Map(100);

Basically you store all your variables of the map , including connections etc in an array.

Then depending on your position you look at the array.
and see if there are any connecting rooms
like if there arnt any other rooms, make them equal null or something

Share this post


Link to post
Share on other sites