Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with ASCII map drawer...

Status
Not open for further replies.

eyesrglazed

Programmer
Jul 14, 2005
20
0
0
US
Ok. I am transferring the method I use for a graphing calculator game I wrote over to C++. IMy only problem right now it getting the map to read...

Does anyone know why this doesn't work???

Code:
#include <iostream>

using namespace std;

int main()
{
	int map[9][16] = 
	{
		{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
		{ 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 3, 1, 1},
		{ 1, 3, 0, 0, 0, 0, 2, 2,-1, 0, 0, 2, 0, 2, 0, 1},
		{ 1, 0, 0, 2, 0, 2, 0, 0,-1, 1, 0, 2, 0, 0, 1, 1},
		{ 1, 1, 1, 1, 2, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1},
		{ 1, 1,-1, 0, 2, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1},
		{ 1, 3,-1,-1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
		{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
		{ 2, 8, 8,15, 3, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
	};

	//This is what it should print...
	/*
	cout << "[URL unfurl="true"]WWWWWWWWWWWWWWWW"[/URL] << endl;
	cout << "[URL unfurl="true"]WWWWWWW[/URL]  [URL unfurl="true"]WWWW:WW"[/URL] << endl;
	cout << "W:    //O  / / W" << endl;
	cout << "W  / /  OW /  WW" << endl;
	cout << "[URL unfurl="true"]WWWW/WW[/URL]  [URL unfurl="true"]WWWWWWW"[/URL] << endl;
	cout << "WWO / WW       W" << endl;
	cout << "W:OO/          W" << endl;
	cout << "[URL unfurl="true"]WWWWWWWWWWWWWWWW"[/URL] << endl;
	*/

	//And this is what it prints...
	/*
	OW/:
	OW/:
	OW/:
	OW/:
	OW/:
	OW/:
	OW/:
	OW/:
	*/

	int x = 0;
	int y = 0;

	while (x != 9)
	{
		if (map[x][y] =-1)
			cout << "O";
		if (map[x][y] = 1)
			cout << "W";
		if (map[x][y] = 2)
			cout << "/";
		if (map[x][y] = 3)
			cout << ":";
		
		y++;

		if (y = 16)
		{
			cout << endl;
			y = 0;
			x++;
		}
	}

	return 0;
}

Also, if anyone is wondering, I am using 5.0. I don't think that would contribute to the problem, though.
 
Yes, you're using = where you should be using == in all your comparisons.


--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top