Help with Dungeon Crawl problem.

problem:
Make a program that outputs a simple grid based gameboard to the screen using either numbers or characters.
i.e.

. . . . . . . . . .
. G . . . . . . . .
. . . . . . T . . .
. . . . . . . . . .
. . . . T . . . . .
. . . . . . T . . .
. . . . . . . . . X


or

0 0 0 0 0 0 0 0 0 0
0 5 0 0 6 0 0 0 0 0
0 0 0 0 0 0 7 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 7 0 0 0 0 0 0
0 0 0 0 0 0 7 0 0 0
0 0 0 0 0 0 0 0 0 4


Allow the user (marked by G in the example) to move either up, down, left, or right each turn. If the player steps on a trap then they lose. If the make it to the treasure 'X' then they win.
My code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "stdafx.h"


#include <iostream>
#include <string>
#include <algorithm>
#include <time.h>
int main(){
	std::string grid;
	grid = "00000000000\n"
		"00000000000\n"
		"0000000000\n"
		"0000000000\n"
		"0000000000\n"
		"0000000000\n"
		"0000000000\n";
	char user = 'G';
	char trap = 'T';
	trap = grid[rand() % grid.length()];
	std::cout << user << grid << trap;
	char userChoice;
	std::cin >> userChoice;
	int n = 0;
	while (n != 71){
		while (user != trap){
			if (userChoice == 'd'){

				grid.at(n) = 0;
				n++;
				grid.at(n) = user;
				std::cout << grid;
			}
			if (userChoice == 'a'){
				grid.at(n) = 0;
				n--;
				grid.at(n) = user;
			}
		}





	}
}
Last edited on
What is the question / problem ?
Topic archived. No new replies allowed.