static void Main() { Console.BufferHeight = Console.WindowHeight = 36; Console.BufferWidth = Console.WindowWidth = 60; Console.BackgroundColor = ConsoleColor.DarkRed; Console.ForegroundColor = ConsoleColor.Black; Console.Title = "Labyrinth Of Doom"; Console.Clear(); Console.WriteLine("\n\n\n"); Console.WriteLine("{0, 15} Game: Labyrinth Of Doom ", ' '); Console.WriteLine("\n {0, 5}Target: Find the way out \n", ' '); Console.WriteLine("{0,10}Controllers: \n{0,10}Up arrow: Up Down arrow: Down \n{0,10}LEft arrow: Left \n{0,10}Right arrow: Right (believe it or not) ", " "); Console.WriteLine("\n\n Press any key to start: \n\n"); bool[][] arr = Level1Matrix.GetMatrix(); for (int i = 0; i < 15; i++) { Console.Write("{0, 19}", ' '); for (int j = 0; j < 20; j++) { Console.Write(arr[i][j] ? wallchar : mazechar); } Console.WriteLine(); } Console.ForegroundColor = ConsoleColor.Black; Console.WriteLine("\n\n {0, 13}Developed by: Svetlin Krastanov", ' '); Console.SetCursorPosition(30, 14); Console.ReadKey(); Console.Beep(800, 80); Console.Clear(); Movements.Move(); Movements.PrintBeatTheGame(); #region Music Console.Beep(440, 500); Console.Beep(440, 500); Console.Beep(440, 500); Console.Beep(349, 350); Console.Beep(523, 150); Console.Beep(440, 500); Console.Beep(349, 350); Console.Beep(523, 150); Console.Beep(440, 1000); Console.Beep(659, 500); Console.Beep(659, 500); Console.Beep(659, 500); Console.Beep(698, 350); Console.Beep(523, 150); Console.Beep(415, 500); Console.Beep(349, 350); Console.Beep(523, 150); Console.Beep(440, 1000); #endregion Console.ReadLine(); }
public static void PrintArray(int level) { Console.Write(""); bool[][] mazeLayout = Level1Matrix.GetMatrix(); switch (level) { case 1: mazeLayout = Level2Matrix.GetMatrix(); break; case 2: mazeLayout = Level3Matrix.GetMatrix(); break; case 3: mazeLayout = Level4Matrix.GetMatrix(); break; case 4: mazeLayout = Level5Matrix.GetMatrix(); break; default: break; } Console.WriteLine(""); //Make maze width Gold for (int i = 0; i < mazeLayout.Length; i++) { for (int j = 0; j < mazeLayout[i].Length; j++) { if (mazeLayout[i][j]) { Console.ForegroundColor = ConsoleColor.Black; Console.Write(wallchar); } else { if (!mazeLayout[i][j] && (j % 4 == 0)) { Console.ForegroundColor = ConsoleColor.DarkYellow; Console.Write("$"); } else { Console.Write(mazechar); } } } Console.Write("\n"); } Console.Beep(800, 100); Console.Beep(1200, 100); Console.Beep(800, 100); Console.Beep(1200, 100); Console.Beep(800, 100); Console.SetWindowSize(60, 40); }
public static void Move() { for (int level = 0; level <= 4; level++) { PrintArray(level); int counter = level; if (time == 0) { timer.Elapsed += timer_Elapsed; time++; } sec = 30; timer.Start(); //Make mask for movements bool[][] mazeLayout = Level1Matrix.GetMatrix(); switch (counter) { case 1: mazeLayout = Level2Matrix.GetMatrix(); break; case 2: mazeLayout = Level3Matrix.GetMatrix(); break; case 3: mazeLayout = Level4Matrix.GetMatrix(); break; case 4: mazeLayout = Level5Matrix.GetMatrix(); break; default: break; } Console.WriteLine(""); Console.SetCursorPosition(col, row); Console.Write("@"); Console.SetCursorPosition(col, row); #region Controls //Here it is the controls while (true) { ConsoleKeyInfo info = Console.ReadKey(true); if (info.Key == ConsoleKey.UpArrow && !mazeLayout[row - 2][col]) { Console.Write(" "); Debug.Print("W"); row--; } if (info.Key == ConsoleKey.DownArrow && !mazeLayout[row][col]) { Console.Write(" "); Debug.Print("S"); row++; } if (info.Key == ConsoleKey.LeftArrow && !mazeLayout[row - 1][col - 1]) { Console.Write(" "); Debug.Print("A"); col--; } if (info.Key == ConsoleKey.RightArrow && !mazeLayout[row - 1][col + 1]) { Console.Write(" "); Debug.Print("D"); col++; } Console.SetCursorPosition(col, row); Console.Write("@"); Console.SetCursorPosition(col, row); #endregion //Print the Colected Gold if (!mazeLayout[row][col] && (col % 4 == 0)) { gold += 5; Console.SetCursorPosition(38, 4); Console.Write("You need at least "); Console.SetCursorPosition(38, 6); Console.Write("400 gold to pass: "******"Gold: {0}", gold); Console.SetCursorPosition(38, 10); Console.SetCursorPosition(col, row); } #region If 400 gold is colected make exit avalible //Check if gold is not colectet, Exit = No no no if (gold < 400) { switch (counter) { case 0: mazeLayout[26][32] = true; break; case 1: mazeLayout[8][31] = true; break; case 2: mazeLayout[23][33] = true; break; case 3: mazeLayout[32][28] = true; break; case 5: mazeLayout[8][31] = true; break; default: break; } } // Check if gold is colectet, exit = yes yes yes else { switch (counter) { case 0: mazeLayout[26][32] = false; break; case 1: mazeLayout[8][31] = false; break; case 2: mazeLayout[23][33] = false; break; case 3: mazeLayout[32][28] = false; break; case 5: mazeLayout[8][31] = true; break; default: break; } } #endregion #region If user found exit //Check if the user found exit on first level if (col == 32 && row == 27 && counter == 0) { timer.Close(); Console.Clear(); FoundExit(); Console.ReadLine(); col = 1; row = 3; gold = 0; Console.SetCursorPosition(col, row); Console.Clear(); break; } //Check if the user found exit on second level if (col == 31 && row == 9 && counter == 1) { timer.Close(); Console.Clear(); FoundExit(); Console.ReadLine(); col = 1; row = 3; gold = 0; Console.SetCursorPosition(col, row); Console.Clear(); break; } //Check if the user found exit on third level if (col == 33 && row == 24 && counter == 2) { timer.Close(); Console.Clear(); FoundExit(); Console.ReadLine(); col = 1; row = 3; gold = 0; Console.SetCursorPosition(col, row); Console.Clear(); break; } //Check if the user found exit on four level if (col == 32 && row == 29 && counter == 3) { timer.Close(); Console.Clear(); FoundExit(); Console.ReadLine(); col = 1; row = 3; gold = 0; Console.SetCursorPosition(col, row); Console.Clear(); break; } //Check if the user found exit on five level if (col == 31 && row == 9 && counter == 4) { timer.Close(); Console.Clear(); FoundExit(); Console.ReadLine(); col = 1; row = 3; gold = 0; Console.SetCursorPosition(col, row); Console.Clear(); break; } #endregion //If time is 0 return from begining if (sec == 0) { } } } }