From 7fc10ca322425deeb3ca5c51cf602718b28863be Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sun, 15 Sep 2019 09:37:04 +0300 Subject: Worked on issue #59 Left out only the settings menu (2nd checkbox) --- Bitspace 2.0/Bitspace 2.0/Bitspace 2.0.csproj | 1 + Bitspace 2.0/Bitspace 2.0/Menu.cs | 87 +++++++++++++++++++++++++++ Bitspace 2.0/Bitspace 2.0/Program.cs | 2 +- 3 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 Bitspace 2.0/Bitspace 2.0/Menu.cs (limited to 'Bitspace 2.0') diff --git a/Bitspace 2.0/Bitspace 2.0/Bitspace 2.0.csproj b/Bitspace 2.0/Bitspace 2.0/Bitspace 2.0.csproj index f388bf7..0d06311 100644 --- a/Bitspace 2.0/Bitspace 2.0/Bitspace 2.0.csproj +++ b/Bitspace 2.0/Bitspace 2.0/Bitspace 2.0.csproj @@ -55,6 +55,7 @@ + diff --git a/Bitspace 2.0/Bitspace 2.0/Menu.cs b/Bitspace 2.0/Bitspace 2.0/Menu.cs new file mode 100644 index 0000000..b65ef98 --- /dev/null +++ b/Bitspace 2.0/Bitspace 2.0/Menu.cs @@ -0,0 +1,87 @@ +using System; +using Bitspace_2._0.Game_map; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Bitspace_2._0 { + public static class Menu { + private static int yPos; + + public static void StartMenu() { + yPos = 2; + while (true) { + Console.Clear(); + + Console.ForegroundColor = ConsoleColor.Gray; + Console.WriteLine("Bitspace"); + Console.WriteLine(); + Console.WriteLine(" New game"); + Console.WriteLine(" Load game (unavalable)"); + Console.WriteLine(" Settings"); + + if (!MenuCursor(2, 4)) break; + } + switch (yPos) { + case 2: ProgressMenu(); MapSizeMenu(); break; + //case 4: SettingsMenu(); break; + } + } + + private static void MapSizeMenu() { + yPos = 2; + while (true) { + Console.Clear(); + + Console.ForegroundColor = ConsoleColor.Gray; + Console.WriteLine("Choose map size:"); + Console.WriteLine(); + Console.WriteLine(" Small (5 x 10)"); + Console.WriteLine(" Medium (10 x 20)"); + Console.WriteLine(" Large (20 x 40)"); + + if (!MenuCursor(2, 4)) break; + } + switch (yPos) { + case 2: Map.Generate(5, 10); break; + case 3: Map.Generate(10, 20); break; + case 4: Map.Generate(20, 40); break; + } + + } + + private static void ProgressMenu() { + yPos = 2; + while (true) { + Console.Clear(); + + Console.ForegroundColor = ConsoleColor.Gray; + Console.WriteLine("Choose progress saving mode:"); + Console.WriteLine(); + Console.WriteLine(" Get over it! (No saving)"); + Console.WriteLine(" Fanatic (Constant saving) UNAVALABLE"); + + if (!MenuCursor(2, 3)) break; + } + switch(yPos) { + case 3: + case 2: break; + } + } + + private static bool MenuCursor(int minValue, int maxValue) { //returns false when enter is pressed + Console.ForegroundColor = ConsoleColor.Red; + Console.SetCursorPosition(0, yPos); + Console.Write('>'); + + var pressedKey = Console.ReadKey().Key; + + if (pressedKey == ConsoleKey.UpArrow && yPos > minValue) yPos--; + else if (pressedKey == ConsoleKey.DownArrow && yPos < maxValue) yPos++; + else if (pressedKey == ConsoleKey.Enter) return false; + + return true; + } + } +} diff --git a/Bitspace 2.0/Bitspace 2.0/Program.cs b/Bitspace 2.0/Bitspace 2.0/Program.cs index ccad6c6..e249b19 100644 --- a/Bitspace 2.0/Bitspace 2.0/Program.cs +++ b/Bitspace 2.0/Bitspace 2.0/Program.cs @@ -10,8 +10,8 @@ using Bitspace_2._0.Game_creatures; namespace Bitspace_2._0 { class Program { static void Main(string[] args) { - Map.Generate(20, 10); Console.CursorVisible = false; + Menu.StartMenu(); for (ulong gameTick = 0; ; gameTick++, Thread.Sleep(80)) { if (Console.KeyAvailable) { -- cgit v1.2.3