Project: ASCII Roguelike Dungeon Crawler

Tools and Technology: C++

ASCII Roguelike Dungeon Crawler is a short game I started in an early programming class.

C++ code for the drawing the map.

void MapData::drawMap(void)
{

	int offsetX = 59;
	int offsetY = 1;

	for (int rows = 0; rows < MAP_HEIGHT + 1; rows++)
	{
		for (int cols = 0; cols < MAP_WIDTH + 1; cols++)
		{
			Console::SetCursorPosition(cols * 2 + offsetX, rows * 2 + offsetY);

			// Print out the "column" value (currently not used)
			Console::ForegroundColor(ConsoleColor::DarkGray);
			cout << char(197);
			Console::ResetColor();

			// Print out the Horizontal Wall type (top wall)
			if (getSquare(rows, cols)->getHWallType() == WallData::WallType::Wall_Solid)
			{
				if (cols != MAP_WIDTH)
				{
					Console::ForegroundColor(ConsoleColor::DarkGray);
					cout << char(196);
					Console::ResetColor();
				}
			}
			else if (getSquare(rows, cols)->getHWallType() == WallData::WallType::Door_Locked)
			{
				cout << '=';
			}
			else if (getSquare(rows, cols)->getHWallType() == WallData::WallType::Door_Boss)
			{
				Console::ForegroundColor(ConsoleColor::DarkMagenta);
				cout << char(219);
				Console::ResetColor();
			}
			else
			{
				cout << ' ';
			}

			Console::SetCursorPosition(cols * 2 + offsetX, rows * 2 + 1 + offsetY); //Jump the cursor down a row

			// Print out the Vertical Wall type (left wall)
			if (getSquare(rows, cols)->getVWallType() == WallData::WallType::Wall_Solid)
			{
				if (rows != MAP_HEIGHT)
				{
					Console::ForegroundColor(ConsoleColor::DarkGray);
					cout << char(179);
					Console::ResetColor();
				}
			}
			else if (getSquare(rows, cols)->getVWallType() == WallData::WallType::Door_Boss)
			{
				Console::ForegroundColor(ConsoleColor::DarkMagenta);
				cout << char(219);
				Console::ResetColor();
			}
			else
			{
				cout << ' ';
			}

			// Print out the Floor Object Type (This is whatever is sitting in the room)
			if ((getSquare(rows, cols)->getFloorObjectType() == FloorObjectData::FloorObjectType::Character_NPC) && (cols != MAP_WIDTH) && (rows != MAP_HEIGHT))
			{
				Console::ForegroundColor(ConsoleColor::Red);
				cout << '&';
				Console::ResetColor();
			}
			else if ((getSquare(rows, cols)->getFloorObjectType() == FloorObjectData::FloorObjectType::Character_NPC_Boss) && (cols != MAP_WIDTH) && (rows != MAP_HEIGHT))
			{
				Console::ForegroundColor(ConsoleColor::Magenta);
				cout << '&';
				Console::ResetColor();
			}
			else if ((getSquare(rows, cols)->getFloorObjectType() == FloorObjectData::FloorObjectType::Character_PC) && (cols != MAP_WIDTH) && (rows != MAP_HEIGHT))
			{
				Console::ForegroundColor(ConsoleColor::Cyan);
				switch (m_pcParty->getDirection())
				{
				case PlayerParty::Direction::North:
					cout << '^';
					break;
				case PlayerParty::Direction::East:
					cout << '>';
					break;
				case PlayerParty::Direction::South:
					cout << 'v';
					break;
				case PlayerParty::Direction::West:
					cout << '<';
					break;
				default:
					break;
				}
				Console::ResetColor();
			}
			else
			{
				cout << ' ';
			}
		}
		cout << endl;
	}

	// Draw enemies colleted
	Console::ForegroundColor(ConsoleColor::Red);
	Console::SetCursorPosition(offsetX, offsetY + 20);
	for (int i = 0; i < enemiesCollected; i++)
	{
		cout << "& ";
	}
	Console::ResetColor();

	drawViewport();
}