Text Adventure Movement

I've been trying to make a text adventure game where your position is determined by a changing variable that represents your location. (V=0) is one room and (V=1) is a different room. Every time I try to run to execute the code my compiler crashes. I'm working with a compiler that's on iPad.
#include <iostream>
#include <string>
using namespace std;
int main()
{
string M;
//vertical intervle defines position on one dimentional map
string V=0;
cin >> M;
if (M="NORTH")
{
V=V+1;
}

else if (M="SOUTH")
{
V=V-1;
}

if (V=0)
{
cout << "Dude you're south" << endl;
cin >> M;
}
if (V=1)
{
cout << "Dude you're north" << endl;
cin >> M;
}
}
I was able to get it to run when I did that and turned V into an int but it still wouldn't work properly. It will display "Dude you're south!" but it won't change when I type, "NORTH."
You start with V = 0 (which should be an int). If you move NORTH, V becomes 1 and you're going to execute lines 18-19. In other words, you have a very small map (2 rows in your grid, 0 and 1).

Normally you would do a boundary check by checking that V is >= 0 and V < NROWS, where NROWS is the number of rows in your grid.

PLEASE USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post.
http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <> formatting button.
Last edited on
Topic archived. No new replies allowed.