using System;
using System.Text;
namespace Memory_Maze
{
class Program
{
static char[,] map = new char[20, 20];
static Random random = new Random();
struct Point
{
public int x;
public int y;
/*void move(ref char[,] map, Console.)
{
}*/
}
static Point player;
static void showStartText()
{
Console.Write("~~~Memory Maze~~~\n\n");
Console.Write("How good is your short term memory? Time to put it to the test!\n\n");
Console.Write("Instructions: You will be shown a map. The 'S' is the start, and the 'F' is the end.\n\n");
Console.Write("You will be shown the maze for a few seconds, and then you must try to navigate from start to finish.\n\n");
Console.Write("To move in a direction, hit that arrow key. If you run into a wall, you lose.\n\n");
}
static void generateMap(ref char[,] map)
{
for (int x = 0; x < map.GetLength(0); ++x)
for (int y = 0; y < map.GetLength(1); ++y)
{
map[x, y] = 'W';
}
int tunnelX = 1;
int tunnelY = 1;
map[tunnelX, tunnelY] = 'S';
while (true)
{
if (random.Next(0, 2) == 1)
{
if (tunnelX + 1 < map.GetLength(0) - 1)
{
++tunnelX;
map[tunnelX, tunnelY] = ' ';
continue;
}
else
{
if (tunnelY + 1 < map.GetLength(1) - 1)
{
++tunnelY;
map[tunnelX, tunnelY] = ' ';
}
else
{
map[tunnelX, tunnelY] = 'F';
break;
}
}
}
else
{
if (tunnelY + 1 < map.GetLength(1) - 1)
{
++tunnelY;
map[tunnelX, tunnelY] = ' ';
continue;
}
else
{
if (tunnelX + 1 < map.GetLength(0) - 1)
{
++tunnelX;
map[tunnelX, tunnelY] = ' ';
}
else
{
map[tunnelX, tunnelY] = 'F';
break;
}
}
}
}
}
static void drawMap(char[,] map)
{
for (int x = 0; x < map.GetLength(0); ++x)
{
for (int y = 0; y < map.GetLength(1); ++y)
{
switch (map[x, y])
{
case 'W':
Console.ForegroundColor = ConsoleColor.Red;
break;
case 'P':
Console.ForegroundColor = ConsoleColor.Green;
break;
case 'S':
Console.ForegroundColor = ConsoleColor.Cyan;
break;
case 'F':
Console.ForegroundColor = ConsoleColor.Magenta;
break;
}
Console.Write(map[x, y]);
}
Console.Write("\n");
}
}
static bool quit()
{
while (true)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.Write("Would you like to play again? y/n\n");
Console.ForegroundColor = ConsoleColor.Green;
string input = Console.ReadLine();
Console.ForegroundColor = ConsoleColor.Gray;
if (input.ToLowerInvariant() == "y")
return false;
else if (input.ToLowerInvariant() == "n")
return true;
else
{
Console.Write("\n\nInvalid input\n\n");
continue;
}
}
}
static void Main(string[] args)
{
Program program = new Program();
Point player;
showStartText();
Console.Write("Press enter to continue.");
Console.ReadLine();
Console.Clear();
while (true)
{
generateMap(ref map);
player.x = 1;
player.y = 1;
for (int i = 6; i >= 0; --i)
{
Console.Clear();
drawMap(map);
Console.ForegroundColor = ConsoleColor.Gray;
Console.Write("\n\nYou have ");
Console.Write(i);
Console.Write(" seconds left.");
System.Threading.Thread.Sleep(1000);
}
Console.Clear();
while (true)
{
Console.Clear();
Console.Write("Press an arrow key to go that direction");
}
}
}
}
}